Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: usr.sbin/ldpd warns about uninitialized object



On Sun, Dec 12, 2010 at 11:49:11PM +0100, Piotr Meyer wrote:
> I typically compile system (i386) with -O2 and usr.sbin/ldpd/fsm.c generate
> following warning (due to uninitialized variables check, enabled by -O greater
> than 0):
> 
> cc1: warnings being treated as errors
> /usr/src/usr.sbin/ldpd/fsm.c: In function 'run_ldp_hello':

Thanks to Christos for patching it, but similar issue is also in
ldp_command.c. I patched it in following way, but I'm not sure,
isn't this style too defensive?


--- ldp_command.c.orig  2010-12-13 19:29:12.000000000 +0100
+++ ldp_command.c       2010-12-14 11:48:16.000000000 +0100
@@ -284,7 +284,7 @@
 int
 command_match(struct com_func *cf, int s, char *orig, char *next)
 {
-       int i, matched = 0, last_match;
+       int i, matched = 0, last_match = -1;

        if (orig == NULL || orig[0] == '\0') {
                send_prompt(s);
@@ -317,6 +317,13 @@
                return 0;
        }

+    /* Never should be true, due to previous !matched */
+    if (last_match == -1) {
+        writestr(s, "Internal error: last_match not set. Use ? for help\n");
+        send_prompt(s);
+        return 0;
+    }
+
        if(cf[last_match].func(s, next) != 0)
                send_prompt(s);
        return 1;



Regardless of style - it's working, but some time after that, build process 
stops in another place:

/usr/src/tests/rump/rumpvfs/t_p2kifs.c: In function 'atfu_makecn_body':
/usr/src/tests/rump/rumpvfs/t_p2kifs.c:82: warning: call to 
__builtin___strcpy_chk will always overflow destination buffer

-- 
Piotr 'aniou' Meyer


Home | Main Index | Thread Index | Old Index