butc: fix int to float conversion warning

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>
This commit is contained in:
Cheyenne Wills 2020-07-16 15:52:00 -06:00 committed by Benjamin Kaduk
parent 899b1af418
commit 37b55b30c6

View File

@ -237,10 +237,11 @@ atocl(char *numstring, char crunit, afs_int32 *number)
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;
return (0);
}