Source-Changes-HG archive

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

[src/trunk]: src/sbin/ping6 Rework to be avoid a conditional assignment which...



details:   https://anonhg.NetBSD.org/src/rev/e0ec92f10805
branches:  trunk
changeset: 331749:e0ec92f10805
user:      matt <matt%NetBSD.org@localhost>
date:      Fri Aug 22 20:54:29 2014 +0000

description:
Rework to be avoid a conditional assignment which results in:
sbin/ping6/ping6.c:1879:8: error: 'cbit.skip' may be used uninitialized in this function [-Werror=maybe-uninitialized]
    cur += ntohs(cbit.skip) * 32;

diffstat:

 sbin/ping6/ping6.c |  14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)

diffs (56 lines):

diff -r 154b801549c8 -r e0ec92f10805 sbin/ping6/ping6.c
--- a/sbin/ping6/ping6.c        Fri Aug 22 20:01:16 2014 +0000
+++ b/sbin/ping6/ping6.c        Fri Aug 22 20:54:29 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ping6.c,v 1.82 2013/10/19 01:09:16 christos Exp $      */
+/*     $NetBSD: ping6.c,v 1.83 2014/08/22 20:54:29 matt Exp $  */
 /*     $KAME: ping6.c,v 1.164 2002/11/16 14:05:37 itojun Exp $ */
 
 /*
@@ -77,7 +77,7 @@
 #else
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: ping6.c,v 1.82 2013/10/19 01:09:16 christos Exp $");
+__RCSID("$NetBSD: ping6.c,v 1.83 2014/08/22 20:54:29 matt Exp $");
 #endif
 #endif
 
@@ -125,6 +125,7 @@
 #include <fcntl.h>
 #include <math.h>
 #include <signal.h>
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -1844,6 +1845,7 @@
        }
 
        while (cp < end) {
+               size_t skip = 0;
                clen = (size_t)(end - cp);
                if ((ni->ni_flags & NI_SUPTYPE_FLAG_COMPRESS) == 0) {
                        if (clen == 0 || clen > MAXQTYPES / 8 ||
@@ -1860,8 +1862,8 @@
                                return;
                        cp += sizeof(cbit);
                        clen = ntohs(cbit.words) * sizeof(v);
-                       if (cur + clen * 8 + (u_long)ntohs(cbit.skip) * 32 >
-                           MAXQTYPES)
+                       skip = (size_t)ntohs(cbit.skip) * 32;
+                       if (cur + clen * 8 + skip > MAXQTYPES)
                                return;
                }
 
@@ -1874,9 +1876,7 @@
                b = pr_bitrange(0, (int)(cur + off * 8), b);
 
                cp += clen;
-               cur += clen * 8;
-               if ((ni->ni_flags & NI_SUPTYPE_FLAG_COMPRESS) != 0)
-                       cur += ntohs(cbit.skip) * 32;
+               cur += clen * 8 + skip;
        }
 }
 



Home | Main Index | Thread Index | Old Index