Code

src/oping.c: Fix a compiler warning about uninitialized variables.
authorFlorian Forster <octo@verplant.org>
Wed, 16 Feb 2011 08:45:35 +0000 (09:45 +0100)
committerFlorian Forster <octo@verplant.org>
Wed, 16 Feb 2011 08:45:35 +0000 (09:45 +0100)
Some verions of GGC don't notice that usage_qos_exit() won't return and
complain about the variables "prec" and "class" being used uninitalized.
This commit adds the "noreturn" attribute to that function and
initializes the variables. Thanks to James Bromberger for reporting this
problem.

src/oping.c

index 7058ac0480ac82d6bd5cb5f700fb2c8d51a1d4c6..5ecfdbfa2cbeb16a165502943064262ce56c1020 100644 (file)
@@ -273,6 +273,7 @@ static void usage_exit (const char *name, int status) /* {{{ */
        exit (status);
 } /* }}} void usage_exit */
 
+__attribute__((noreturn))
 static void usage_qos_exit (const char *arg, int status) /* {{{ */
 {
        if (arg != 0)
@@ -334,8 +335,8 @@ static int set_opt_send_qos (const char *opt) /* {{{ */
                        && (strlen (opt) == 4))
        {
                uint8_t dscp;
-               uint8_t class;
-               uint8_t prec;
+               uint8_t class = 0;
+               uint8_t prec = 0;
 
                /* There are four classes, AF1x, AF2x, AF3x, and AF4x. */
                if (opt[2] == '1')