Re: [PATCH] blockjob: avoid 32-bit compilation warning

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

 



On 09/08/2014 08:55 AM, Eric Blake wrote:

> Forcing the left side of the < to be ull instead of ul shuts up
> the 32-bit compiler while still protecting 64-bit code from overflow.

>                   * ullong bytes/s; make sure we don't overflow */
> -                if (bandwidth > ULLONG_MAX >> 20) {
> +                if (bandwidth + 0ULL > ULLONG_MAX >> 20) {

On IRC, several people suggested that I write this with an explicit cast:

if ((unsigned long long) bandwidth > ULLONG_MAX >> 20) {

rather than my shorthand of an identity operation used to coerce types
via promotion rules.  If you feel strongly in favor of one of the two
approaches, or strongly about avoiding needless churn now that the patch
is already pushed, speak up now; if not, I'll probably make the change
to use an explicit cast later today.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
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]