OSDN Git Service

remove two checks for gettimeofday error
authorDenys Vlasenko <vda.linux@googlemail.com>
Tue, 2 Feb 2010 22:09:16 +0000 (23:09 +0100)
committerDenys Vlasenko <vda.linux@googlemail.com>
Tue, 2 Feb 2010 22:09:16 +0000 (23:09 +0100)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
libc/misc/time/ftime.c
libc/sysdeps/linux/common/clock_gettime.c

index b227386..ff78d41 100644 (file)
@@ -25,8 +25,10 @@ int ftime(struct timeb *timebuf)
        struct timeval tv;
        struct timezone tz;
 
-       if (gettimeofday (&tv, &tz) < 0)
-               return -1;
+       /* In Linux, gettimeofday fails only on bad parameter.
+        * We know that here parameters aren't bad.
+        */
+       gettimeofday (&tv, &tz);
 
        timebuf->time = tv.tv_sec;
        timebuf->millitm = (tv.tv_usec + 999) / 1000;
index 888cd64..d3755a7 100644 (file)
@@ -23,10 +23,12 @@ int clock_gettime(clockid_t clock_id, struct timespec* tp)
 
        switch (clock_id) {
                case CLOCK_REALTIME:
-                       retval = gettimeofday(&tv, NULL);
-                       if (retval == 0) {
-                               TIMEVAL_TO_TIMESPEC(&tv, tp);
-                       }
+                       /* In Linux, gettimeofday fails only on bad parameter.
+                        * We know that here parameter isn't bad.
+                        */
+                       gettimeofday(&tv, NULL);
+                       TIMEVAL_TO_TIMESPEC(&tv, tp);
+                       retval = 0;
                        break;
 
                default: