Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 20 Jul 2003 22:06:02 +0200 (CEST)
From:      Lukas Ertl <l.ertl@univie.ac.at>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   bin/54672: [PATCH] fix gcc 3.3 compiler warning for ifconfig(8)
Message-ID:  <200307202006.h6KK62li015250@korben.in.tern>
Resent-Message-ID: <200307202010.h6KKA1bG078715@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         54672
>Category:       bin
>Synopsis:       [PATCH] fix gcc 3.3 compiler warning for ifconfig(8)
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Jul 20 13:10:00 PDT 2003
>Closed-Date:
>Last-Modified:
>Originator:     Lukas Ertl
>Release:        FreeBSD 5.1-CURRENT i386
>Organization:
Vienna University Computer Center
>Environment:
System: FreeBSD korben 5.1-CURRENT FreeBSD 5.1-CURRENT #4: Mon Jul 14 22:28:43 CEST 2003 le@korben:/usr/obj/usr/src/sys/KORBEN i386


	
>Description:

When compiling ifconfig(8), gcc-3.3 emits the following warning:

cc -O -pipe -march=athlon -DUSE_IF_MEDIA -DINET6 -DUSE_VLANS -DUSE_IEEE80211 -DUSE_MAC -DNS -Wall -Wmissing-prototypes -Wcast-qual -Wwrite-strings  -Wnested-externs -I..   -DRESCUE  -c /usr/src/sbin/ifconfig/ifconfig.c
/usr/src/sbin/ifconfig/ifconfig.c: In function `setatrange':
/usr/src/sbin/ifconfig/ifconfig.c:1692: warning: comparison is always false due to limited range of data type
/usr/src/sbin/ifconfig/ifconfig.c:1692: warning: comparison is always false due to limited range of data type

The bogus comparison is:

    if (sscanf(range, "%hu-%hu", &first, &last) != 2
        || first == 0 || first > 0xffff
        || last == 0 || last > 0xffff || first > last)

first and last are both declared as u_short, which can't hold values larger
then 0xffff, so the comparison isn't needed.

>How-To-Repeat:
	
>Fix:


--- ifconfig.diff begins here ---
Index: sbin/ifconfig/ifconfig.c
===================================================================
RCS file: /usr/local/bsdcvs/src/sbin/ifconfig/ifconfig.c,v
retrieving revision 1.90
diff -u -u -r1.90 ifconfig.c
--- sbin/ifconfig/ifconfig.c	28 Apr 2003 16:37:38 -0000	1.90
+++ sbin/ifconfig/ifconfig.c	20 Jul 2003 20:01:02 -0000
@@ -1688,8 +1688,7 @@
 	u_short	first = 123, last = 123;
 
 	if (sscanf(range, "%hu-%hu", &first, &last) != 2
-	    || first == 0 || first > 0xffff
-	    || last == 0 || last > 0xffff || first > last)
+	    || first == 0 || last == 0 || first > last)
 		errx(1, "%s: illegal net range: %u-%u", range, first, last);
 	at_nr.nr_firstnet = htons(first);
 	at_nr.nr_lastnet = htons(last);
--- ifconfig.diff ends here ---


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200307202006.h6KK62li015250>