[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Compiler Warning vasnprintf.c (L5107: comparison between signed and
From: |
Eric Blake |
Subject: |
Re: Compiler Warning vasnprintf.c (L5107: comparison between signed and unsigned int) |
Date: |
Thu, 11 Sep 2014 14:52:32 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.7.0 |
On 09/11/2014 02:20 PM, Paul Eggert wrote:
> On 09/11/2014 01:05 PM, Дилян Палаузов wrote:
>> vasnprintf.c: In function ‘vasnprintf’:
>> vasnprintf.c:5107:35: warning: comparison between signed and unsigned
>> integer expressions [-Wsign-compare]
>> if (count < maxlen
>> ^
>>
>> count is int (signed) and maxlen is size_t (<=> unsigned) (lines 4935
>> and 4936).
>
> Sure, but 'count' is nonnegative, so the comparison is numerically
> correct and there is no bug here.
>
> As a general rule gnulib doesn't worry about pacifying gcc
> -Wsign-compare, which issues too many false alarms like this.
While we don't mind easy-to-maintain patches that silence rare warnings,
we are reluctant to dirty up the code base to silence warnings such as
-Wsign-compare that have a very HIGH signal-to-noise ratio. That's why
many gnulib clients, such as coreutils, have explicitly taken to
compiling with two sets of warning flags, a looser set for gnulib code,
and a stricter set for the policies that are enforced on the
package-local code. I'd suggest that you look into that approach for
your project rather than hoping that gnulib will make vasnprintf.c
compile warning-free for all the various warning combinations out there.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature