From 921a055f5ea6b68f16db585e985eb24b4c32be2c Mon Sep 17 00:00:00 2001 From: Raju Chakraborty Date: Mon, 18 Nov 2013 14:33:13 +0000 Subject: fipvlan fails on powerpc fipvlan fails to execute properly on powerpc architecture. # fipvlan -a Try 'fipvlan --help' for more information # # fipvlan --create --start eth1 Try 'fipvlan --help' for more information # In power pc systems, when there are no more arguments to be parsed, getopt_long should return -1. But gdb output shows that it c is 255 whereas in intel system it shows -1 properly. "char" must not be trusted when signing is important! Different arches (and even different gcc versions on the same arch) may default char to signed or unsigned. Ideally, a portable program should always use signed char or unsigned char when it depends on the signedness of an object. But many programs have been written to use plain char and expect it to be signed, or expect it to be unsigned, depending on the machines they were written for. In this case the variable c is expected to behave as signed and hence using signed would be the safe option. http://gcc.gnu.org/onlinedocs/gcc-4.8.1/gcc/C-Dialect-Options.html Signed-off-by: Raju Chakraborty Signed-off-by: Robert Love --- fipvlan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fipvlan.c b/fipvlan.c index 6f8cf39..e51358f 100644 --- a/fipvlan.c +++ b/fipvlan.c @@ -471,7 +471,7 @@ static void help(int status) static void parse_cmdline(int argc, char **argv) { - char c; + signed char c; while (1) { c = getopt_long(argc, argv, GETOPT_STR, long_options, NULL); -- 1.8.1.4