From: Mike Frysinger Date: Tue, 5 Jan 2010 04:15:32 +0000 (-0500) Subject: e2freefrag: Fix getopt bug on machines with unsigned chars X-Git-Tag: v1.41.13~45 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=b887f08f959fa3ef4ead9b6e2fd71becf4877a40;p=tools%2Fe2fsprogs.git e2freefrag: Fix getopt bug on machines with unsigned chars The getopt() function returns an int, not a char. On systems where the default char is unsigned (like ppc), we get weird behavior where -1 is truncated to 0xff but compared to (int)-1. Also fix this same bug for two test programs, test_rel and iscan, which aren't currently used at the moment. Addresses-Gentoo-Bug: #299386 Signed-off-by: Mike Frysinger Signed-off-by: Theodore Ts'o --- diff --git a/e2fsck/iscan.c b/e2fsck/iscan.c index e9fa076..84e2cc1 100644 --- a/e2fsck/iscan.c +++ b/e2fsck/iscan.c @@ -51,7 +51,7 @@ static void usage(void) static void PRS(int argc, char *argv[]) { int flush = 0; - char c; + int c; #ifdef MTRACE extern void *mallwatch; #endif diff --git a/misc/e2freefrag.c b/misc/e2freefrag.c index e0b0696..50bb986 100644 --- a/misc/e2freefrag.c +++ b/misc/e2freefrag.c @@ -259,7 +259,8 @@ int main(int argc, char *argv[]) ext2_filsys fs = NULL; char *device_name; char *progname; - char c, *end; + char *end; + int c; add_error_table(&et_ext2_error_table); progname = argv[0]; diff --git a/tests/progs/test_rel.c b/tests/progs/test_rel.c index e6997b6..954a722 100644 --- a/tests/progs/test_rel.c +++ b/tests/progs/test_rel.c @@ -713,7 +713,7 @@ void main(int argc, char **argv) int retval; int sci_idx; const char *usage = "Usage: test_rel [-R request] [-f cmd_file]"; - char c; + int c; char *request = 0; int exit_status = 0; char *cmd_file = 0;