2007-07-17 18:52:55

by Eric Sandeen

[permalink] [raw]
Subject: build warning in e2fsprogs...

on x86_64:

badblocks.c:995: warning: comparison is always false due to limited range of data type
badblocks.c:1008: warning: comparison is always false due to limited range of data type

due to this sort of thing:

if (*tmp || errno ||
(last_block == ULONG_MAX && errno == ERANGE)) {
com_err (program_name, 0, _("invalid blocks count - %s"),
argv[optind]);
exit (1);

last_block (and from_count) are both blk_t, or __u32... shouldn't
this be UINT_MAX instead? (though I guess at some point it *will* be 64
bits... but for now... how about the following patch...)

-Eric

-----

Fix build warning on x86_64 due to comparison of __u32 and ULONG_MAX

Signed-off-by: Eric Sandeen <[email protected]>

Index: e2fsprogs-1.40.2/misc/badblocks.c
===================================================================
--- e2fsprogs-1.40.2.orig/misc/badblocks.c
+++ e2fsprogs-1.40.2/misc/badblocks.c
@@ -992,7 +992,7 @@ int main (int argc, char ** argv)
last_block = strtoul (argv[optind], &tmp, 0);
printf("last_block = %d (%s)\n", last_block, argv[optind]);
if (*tmp || errno ||
- (last_block == ULONG_MAX && errno == ERANGE)) {
+ (last_block == UINT_MAX && errno == ERANGE)) {
com_err (program_name, 0, _("invalid blocks count - %s"),
argv[optind]);
exit (1);
@@ -1005,7 +1005,7 @@ int main (int argc, char ** argv)
from_count = strtoul (argv[optind], &tmp, 0);
printf("from_count = %d\n", from_count);
if (*tmp || errno ||
- (from_count == ULONG_MAX && errno == ERANGE)) {
+ (from_count == UINT_MAX && errno == ERANGE)) {
com_err (program_name, 0, _("invalid starting block - %s"),
argv[optind]);
exit (1);