]> git.ipfire.org Git - thirdparty/libvirt.git/commit
nwfilter: variable 'obj' must be initialized inside nwfilterBindingCreateXML().
authorJulio Faracco <jcfaracco@gmail.com>
Wed, 27 Jun 2018 02:47:53 +0000 (23:47 -0300)
committerPavel Hrdina <phrdina@redhat.com>
Thu, 28 Jun 2018 07:44:28 +0000 (09:44 +0200)
commitf8c65481d5baa279372bfa244c92527088ce70dd
treea2da23b349be37884d104594ac66d2310d5b753d
parent4ad54a417a1bbe10aeffcce783f4381d8d43f799
nwfilter: variable 'obj' must be initialized inside nwfilterBindingCreateXML().

The function nwfilterBindingCreateXML() is failing to compile due to a
conditional branch which leads to an undefined 'obj' variable. So 'obj'
must have an initial value to avoid compilation errors. See the problem:

  CC       nwfilter/libvirt_driver_nwfilter_impl_la-nwfilter_driver.lo
nwfilter/nwfilter_driver.c:752:9: error: variable 'obj' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized]
    if (virNWFilterBindingCreateXMLEnsureACL(conn, def) < 0)
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
nwfilter/nwfilter_driver.c:779:10: note: uninitialized use occurs here
    if (!obj)
         ^~~
nwfilter/nwfilter_driver.c:752:5: note: remove the 'if' if its condition is always false
    if (virNWFilterBindingCreateXMLEnsureACL(conn, def) < 0)
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
nwfilter/nwfilter_driver.c:742:33: note: initialize the variable 'obj' to silence this warning
    virNWFilterBindingObjPtr obj;
                                ^
                                 = NULL

This commit initialized 'obj' with NULL to fix the error properly.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
src/nwfilter/nwfilter_driver.c