[libvirt] [PATCH] build: avoid compiler warning

Eric Blake eblake at redhat.com
Mon May 3 21:53:53 UTC 2010


On 05/03/2010 03:41 PM, Matthias Bolte wrote:
>> @@ -1277,7 +1280,7 @@ static int virFileOperationNoFork(const char *path, int openflags, mode_t mode,
>>         && (fchown(fd, uid, gid) < 0)) {
>>         ret = errno;
>>         virReportSystemError(errno, _("cannot chown '%s' to (%u, %u)"),
>> -                             path, uid, gid);
>> +                             path, (int) uid, (int) gid);
> 
> Passing int for %u? Shouldn't this be a cast to unsigned int instead?

Technically, the two should match, to cater to weirdnix systems where
signedness changes the underlying size of the data (at least, my
understanding is that C99 allows such weirdness, even though no one
produces hardware like that).  But gcc doesn't warn about
signed/unsigned mismatch, just about long/int mismatch, so the patch as
is was sufficient to silence the warning.

At any rate, you've convinced me; some uses were %u; others were %d
(which, on cygwin, has the potential to show as a negative number, since
it is entirely feasible to have a uid_t with the most significant bit
set); I'm changing all uses to be %u and cast to unsigned.  v2 patch
coming up soon.

-- 
Eric Blake   eblake at redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20100503/86053439/attachment-0001.sig>


More information about the libvir-list mailing list