]> www.infradead.org Git - mtd-utils.git/commitdiff
tests: jittertest: fix set of compiler warnings
authorAndy Shevchenko <ext-andriy.shevchenko@nokia.com>
Tue, 5 Apr 2011 14:32:29 +0000 (17:32 +0300)
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Tue, 5 Apr 2011 14:41:02 +0000 (17:41 +0300)
- time() was used without prototype.
- the return value of read() and write() wasn't checked
- classificator in printf() was wrong for argument of size_t type

Don't continue to read the /proc/profile in case when write was failed.

Signed-off-by: Andy Shevchenko <ext-andriy.shevchenko@nokia.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
tests/jittertest/JitterTest.c

index fcf8e0df3428235dbd05d2d83a35fb0f9fe4db62..76371e8d84d1c1007305837a14cc2ac8c97fa51c 100644 (file)
@@ -82,6 +82,7 @@
 #include <string.h>     /* strcpy, strcmp */
 #include <stdlib.h>     /* exit, atol, atoi */
 #include <sys/time.h>   /* setitimer, settimeofday, gettimeofday */
+#include <time.h>      /* time */
 #include <signal.h>     /* signal */
 #include <sched.h>      /* sched_setscheduler, sched_get_priority_min,*/
 /*   sched_get_priority_max */
@@ -475,7 +476,11 @@ void doGrabKProfile(int jitterusec, char *fileName)
 
     while((readBytes = read(fdProfile, readBuf, sizeof(readBuf))) > 0)
     {
-        write(fdSnapshot, readBuf, readBytes);
+       int writeBytes = write(fdSnapshot, readBuf, readBytes);
+       if (writeBytes != readBytes) {
+               perror("write error");
+               break;
+       }
     }
 
     close(fdSnapshot);
@@ -650,7 +655,9 @@ void AlarmHandler(
         if(DoRead)
         {
 
-            read(Fd2, tmpBuf, 1);
+           cntr = read(Fd2, tmpBuf, 1);
+           if (cntr < 0)
+               perror("read error");
             lseek(Fd2, 0, SEEK_SET); /* back to start */
         }
 
@@ -1032,7 +1039,7 @@ int Write(int fd, void *buf, size_t bytes, int lineNo)
     if(err < bytes)
     {
 
-        printf("Write Error at line %i! Wanted to write %i bytes, but wrote only %i bytes.\n",
+        printf("Write Error at line %i! Wanted to write %zu bytes, but wrote only %i bytes.\n",
                lineNo, bytes, err);
         perror("Write did not complete. Error. Bye:"); /* show error from errno. */
        exit(1);