[git commit master] remove two checks for gettimeofday error
Khem Raj
raj.khem at gmail.com
Tue Feb 2 23:30:00 UTC 2010
On Tue, Feb 2, 2010 at 2:09 PM, Denys Vlasenko <vda.linux at googlemail.com> wrote:
>
> commit: http://git.uclibc.org/uClibc/commit/?id=1043d24e77f82d729996fe8192b078e567b16113
> branch: http://git.uclibc.org/uClibc/commit/?id=refs/heads/master
>
> Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
> ---
> libc/misc/time/ftime.c | 6 ++++--
> libc/sysdeps/linux/common/clock_gettime.c | 10 ++++++----
> 2 files changed, 10 insertions(+), 6 deletions(-)
>
> diff --git a/libc/misc/time/ftime.c b/libc/misc/time/ftime.c
> index b227386..ff78d41 100644
> --- a/libc/misc/time/ftime.c
> +++ b/libc/misc/time/ftime.c
> @@ -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.
> + */
posix says
"If tzp is not a null pointer, the behavior is unspecified."
where tzp is second parameter above.
Should second param be null for linux ?
> + gettimeofday (&tv, &tz);
>
> timebuf->time = tv.tv_sec;
> timebuf->millitm = (tv.tv_usec + 999) / 1000;
> diff --git a/libc/sysdeps/linux/common/clock_gettime.c b/libc/sysdeps/linux/common/clock_gettime.c
> index 888cd64..d3755a7 100644
> --- a/libc/sysdeps/linux/common/clock_gettime.c
> +++ b/libc/sysdeps/linux/common/clock_gettime.c
> @@ -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:
> --
> 1.6.3.3
>
> _______________________________________________
> uClibc-cvs mailing list
> uClibc-cvs at uclibc.org
> http://lists.busybox.net/mailman/listinfo/uclibc-cvs
>
More information about the uClibc
mailing list