]> git.ipfire.org Git - thirdparty/libvirt.git/commit
esx: Simplify goto usage
authorMatthias Bolte <matthias.bolte@googlemail.com>
Wed, 19 May 2010 20:59:32 +0000 (22:59 +0200)
committerMatthias Bolte <matthias.bolte@googlemail.com>
Wed, 26 May 2010 23:32:25 +0000 (01:32 +0200)
commit041aac864833ba37405f39746a35cf25d9ae68b2
tree1894074fbdc3622e2cbb9ea17af8a6968f473c1d
parent8b0cd87696387c3e4303340248454516a2c3867b
esx: Simplify goto usage

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.
src/esx/esx_driver.c
src/esx/esx_storage_driver.c
src/esx/esx_util.c
src/esx/esx_vi.c
src/esx/esx_vi_methods.c
src/esx/esx_vi_types.c
src/esx/esx_vmx.c