[ag-automation] [patch 1/2] fix sign compare warnings

Robert Schwebel r.schwebel at pengutronix.de
Sat May 12 01:01:48 CEST 2007


On Sat, May 12, 2007 at 12:48:07AM +0200, Robert Schwebel wrote:
> On Sat, May 12, 2007 at 12:11:15AM +0200, Robert Schwebel wrote:
> > This patch adds -Wsign-compare and fixes the resulting warnings.
> 
> Uhm, ... something went wrong with this one. There are no warnings any
> more, but cyclictes also doesn't run any more :-)

Updated patch below. The check for > ARRAY_SIZE(clocksource) was wrong
anyway.

Robert
-- 
 Dipl.-Ing. Robert Schwebel | http://www.pengutronix.de
 Pengutronix - Linux Solutions for Science and Industry
   Handelsregister:  Amtsgericht Hildesheim, HRA 2686
     Hannoversche Str. 2, 31134 Hildesheim, Germany
   Phone: +49-5121-206917-0 |  Fax: +49-5121-206917-9


This patch adds -Wsign-compare and fixes the resulting warnings.

Signed-off-by: Robert Schwebel <r.schwebel at pengutronix.de>

---
 Makefile     |    2 +-
 cyclictest.c |   10 +++++-----
 2 files changed, 6 insertions(+), 6 deletions(-)

Index: cyclictest.c
===================================================================
--- cyclictest.c.orig
+++ cyclictest.c
@@ -117,7 +117,7 @@ static int kernvar(int mode, char *name,
 			}
 		} else if (mode == O_WRONLY) {
 			snprintf(buffer, sizeof(buffer), "%d\n", *value);
-			if (write(procfilepath, buffer, strlen(buffer))
+			if ((size_t)write(procfilepath, buffer, strlen(buffer))
 			    == strlen(buffer))
 				retval = 0;
 		}
@@ -393,8 +393,8 @@ static int timermode  = TIMER_ABSTIME;
 static int use_system;
 static int priority;
 static int num_threads = 1;
-static int max_cycles;
-static int clocksel = 0;
+static unsigned long max_cycles;
+static unsigned int clocksel = 0;
 static int verbose;
 static int quiet;
 static int interval = 1000;
@@ -439,7 +439,7 @@ static void process_options (int argc, c
 		case 'd': distance = atoi(optarg); break;
 		case 'f': ftrace = 1; break;
 		case 'i': interval = atoi(optarg); break;
-		case 'l': max_cycles = atoi(optarg); break;
+		case 'l': max_cycles = atol(optarg); break;
 		case 'n': use_nanosleep = MODE_CLOCK_NANOSLEEP; break;
 		case 'p': priority = atoi(optarg); break;
 		case 'q': quiet = 1; break;
@@ -451,7 +451,7 @@ static void process_options (int argc, c
 		}
 	}
 
-	if (clocksel < 0 || clocksel > ARRAY_SIZE(clocksources))
+	if (clocksel >= ARRAY_SIZE(clocksources))
 		error = 1;
 
 	if (priority < 0 || priority > 99)
Index: Makefile
===================================================================
--- Makefile.orig
+++ Makefile
@@ -1,6 +1,6 @@
 
 TARGET=cyclictest
-FLAGS= -Wall -Wno-nonnull -O2
+FLAGS= -Wall -Wno-nonnull -Wsign-compare -O2
 LIBS = -lpthread -lrt
 
 all: cyclictest.c
 




More information about the ag-automation mailing list