Building with clang-10 results in 2 warnings/errors associated with
with trying to convert 0x7fffffff to a floating point value.
tcmain.c:240:18: error: implicit conversion from 'int' to 'float'
changes value from
2147483647 to
2147483648 [-Werror,
-Wimplicit-int-float-conversion]
if ((total > 0x7fffffff) || (total < 0)) /* Don't go over 2G */
and the same conversion warning on the statement on the following line:
total = 0x7fffffff;
Use floating point and decimal constants instead of the hex constants.
For the test, use
2147483648.0 which is cleanly represented by a float.
Change the comparison in the test from '>' to '>='.
If the total value exceeds 2G, just assign the max value directly to the
return variable.
Change-Id: I79b2afa006496a756bd7b50976050c24827aa027
Reviewed-on: https://gerrit.openafs.org/14277
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
total *= 1024.0;
total += 0.5; /* Round up */
- if ((total > 0x7fffffff) || (total < 0)) /* Don't go over 2G */
- total = 0x7fffffff;
+ if ((total >= 2147483648.0) || (total < 0)) /* Don't go over 2G */
+ *number = 2147483647;
+ else
+ *number = total;
- *number = total;
return (0);
}