Re: [libvirt] [PATCH] build: avoid compiler warning

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

 



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@xxxxxxxxxx    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]