[ovs-dev] [PATCH 06/11] ovn-nbctl: Don't die in parse_direction().

Ben Pfaff blp at ovn.org
Mon Jul 23 22:33:26 UTC 2018


On Tue, Jul 17, 2018 at 03:34:10PM +0200, Jakub Sitnicki wrote:
> Let the caller handle the error. This prepares us for reporting errors
> in daemon mode.
> 
> Signed-off-by: Jakub Sitnicki <jkbs at redhat.com>

I got a lot of "possibly uninitialized" warnings from GCC for this one:

    ../ovn/utilities/ovn-nbctl.c: In function ‘nbctl_qos_del’:
    ../ovn/utilities/ovn-nbctl.c:2068:17: error: ‘direction’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
                 if (strcmp(direction, ls->qos_rules[i]->direction)) {
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ../ovn/utilities/ovn-nbctl.c: In function ‘nbctl_acl_add’:
    ../ovn/utilities/ovn-nbctl.c:1739:5: error: ‘direction’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
         nbrec_acl_set_direction(acl, direction);
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ../ovn/utilities/ovn-nbctl.c: In function ‘nbctl_acl_del’:
    ../ovn/utilities/ovn-nbctl.c:1829:17: error: ‘direction’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
                 if (strcmp(direction, acls[i]->direction)) {
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ../ovn/utilities/ovn-nbctl.c: In function ‘nbctl_qos_add’:
    ../ovn/utilities/ovn-nbctl.c:1994:5: error: ‘direction’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
         nbrec_qos_set_direction(qos, direction);
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ../ovn/utilities/ovn-nbctl.c: At top level:

I think it's wrong but the following incremental solved it so I folded
it in:

diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c
index c18fa28256af..a4a533740cb9 100644
--- a/ovn/utilities/ovn-nbctl.c
+++ b/ovn/utilities/ovn-nbctl.c
@@ -1680,6 +1680,7 @@ parse_direction(const char *arg, const char **direction_p)
     } else if (arg[0] == 'f') {
         *direction_p = "from-lport";
     } else {
+        *direction_p = NULL;
         return xasprintf("%s: direction must be \"to-lport\" or "
                          "\"from-lport\"", arg);
     }

Thanks,

Ben.


More information about the dev mailing list