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