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

Eric Blake eblake at redhat.com
Mon Sep 8 15:43:05 UTC 2014


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

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


More information about the libvir-list mailing list