butc: fix int to float conversion warning 77/14277/6
authorCheyenne Wills <cwills@sinenomine.net>
Thu, 16 Jul 2020 21:52:00 +0000 (15:52 -0600)
committerBenjamin Kaduk <kaduk@mit.edu>
Fri, 24 Jul 2020 15:52:32 +0000 (11:52 -0400)
commit37b55b30c65d0ab8c8eaabfda0dbd90829e2c46a
tree5b75f0544ba0e638217b0e191b91f7f09bad0245
parent899b1af4183fb09fd55a36e3d10ffbdb9671a47e
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>
src/butc/tcmain.c