bug-gnulib
[Top][All Lists]
Advanced

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

Re: [PATCH] vasnprintf: avoid a warning from gcc -Wsign-compare


From: Bruno Haible
Subject: Re: [PATCH] vasnprintf: avoid a warning from gcc -Wsign-compare
Date: Thu, 16 Jun 2011 00:32:44 +0200
User-agent: KMail/1.9.9

Hi Jim,

We discussed -Wsign-compare on 2008-12-09, without a real conclusion.
<http://lists.gnu.org/archive/html/bug-gnulib/2008-12/msg00069.html>.

> I'm using -Wsign-compare in iwhd, and this is the sole warning

But when I build all of gnulib (excluding libunistring and git-merge-changelog)
with gcc 4.3.1, I get warnings in the following locations:

argv-iter.c:102
ftoastr.c:135
fatal-signal.c:196
fatal-signal.c:216
ftoastr.c:135
get-rusage-data.c:255
idpriv-drop.c:92
idpriv-drop.c:93
idpriv-drop.c:93
idpriv-drop.c:113
idpriv-drop.c:114
idpriv-drop.c:114
idpriv-droptemp.c:82
idpriv-droptemp.c:83
idpriv-droptemp.c:83
idpriv-droptemp.c:101
idpriv-droptemp.c:102
idpriv-droptemp.c:102
idpriv-droptemp.c:167
idpriv-droptemp.c:168
idpriv-droptemp.c:168
idpriv-droptemp.c:186
idpriv-droptemp.c:187
idpriv-droptemp.c:187
ftoastr.c:135
mbmemcasecoll.c:70
mbmemcasecoll.c:108
mbscspn.c:38
parse-datetime.y:1122
passfd.c:86
wait-process.c:138
fnmatch_loop.c:852
strftime.c:981
strftime.c:996
read-file.c:63
rijndael-api-fst.c:473
rijndael-api-fst.c:508
vasnprintf.c:4517
vasnprintf.c:5092

and similarly with gcc 4.6.0:

argv-iter.c:102:32
csharpcomp.c:143:23
csharpcomp.c:294:23
csharpcomp.c:479:23
csharpexec.c:140:23
ftoastr.c:135:17
fatal-signal.c:196:19
fatal-signal.c:216:21
ftoastr.c:135:17
get-rusage-data.c:255:35
idpriv-drop.c:91:17
idpriv-drop.c:92:22
idpriv-drop.c:93:18
idpriv-drop.c:112:17
idpriv-drop.c:113:22
idpriv-drop.c:114:18
idpriv-droptemp.c:81:17
idpriv-droptemp.c:82:22
idpriv-droptemp.c:83:18
idpriv-droptemp.c:100:17
idpriv-droptemp.c:101:22
idpriv-droptemp.c:102:18
idpriv-droptemp.c:166:17
idpriv-droptemp.c:167:22
idpriv-droptemp.c:168:18
idpriv-droptemp.c:185:17
idpriv-droptemp.c:186:22
idpriv-droptemp.c:187:18
javacomp.c:260:19
javacomp.c:342:19
javacomp.c:413:19
javacomp.c:468:19
javacomp.c:576:23
javacomp.c:658:23
javaexec.c:169:25
ftoastr.c:135:17
mbmemcasecoll.c:70:19
mbmemcasecoll.c:108:28
mbscspn.c:38:42
parse-datetime.y:1122:28
passfd.c:86:31
wait-process.c:138:20
fnmatch_loop.c:852:34
strftime.c:981:25
strftime.c:996:25
rijndael-api-fst.c:473:24
rijndael-api-fst.c:508:24
vasnprintf.c:4517:42
vasnprintf.c:5091:35

We don't gain much by fixing 1 warning out of 39.

In coreutils 8.12, -Wsign-compare is not enabled in configure.ac. I guess
that you will come to the same conclusion for iwhd sooner or later.

And by the way, you can selectively use different compiler options in a
gnulib subdirectory than in the main package, by using the gnulib-tool
option '--makefile-name'.

> -                        if (count < maxlen
> +                        if ((size_t) count < maxlen

Since 'count' is an 'int', is it safer to cast it to 'unsigned int'
and let the compiler do the rest. (In case 'size_t' is smaller than 'int'.)

Bruno
-- 
In memoriam Robert Stethem <http://en.wikipedia.org/wiki/Robert_Stethem>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]