• M
    esx: Simplify goto usage · 041aac86
    Matthias Bolte 提交于
    Eliminate almost all backward jumps by replacing this common pattern:
    
    int
    some_random_function(void)
    {
        int result = 0;
        ...
    
      cleanup:
        <unconditional cleanup code>
        return result;
    
      failure:
        <cleanup code in case of an error>
        result = -1;
        goto cleanup
    }
    
    with this simpler pattern:
    
    int
    some_random_function(void)
    {
        int result = -1;
        ...
        result = 0;
    
      cleanup:
        if (result < 0) {
            <cleanup code in case of an error>
        }
    
        <unconditional cleanup code>
        return result;
    }
    
    Add a bool success variable in functions that don't have a int result
    that can be used for the new pattern.
    
    Also remove some unnecessary memsets in error paths.
    041aac86
esx_util.c 13.4 KB