From: Jakub Jelinek <jakub@redhat.com>
To: Ulrich Drepper <drepper@redhat.com>
Cc: Glibc hackers <libc-hacker@sources.redhat.com>
Subject: [PATCH] times fixes
Date: Tue, 22 Apr 2008 07:26:00 -0000 [thread overview]
Message-ID: <20080422073658.GH3726@sunsite.mff.cuni.cz> (raw)
Hi!
INTERNAL_SYSCALL_ERRNO returns positive errno numbers, not negative, so
the verification code would never trigger.
Also, if times() syscall returns -1, it is a valid value, but for times()
userland function (clock_t) -1 says an error happened and errno should
contain the error value.
2008-04-22 Jakub Jelinek <jakub@redhat.com>
* sysdeps/unix/sysv/linux/times.c (__times): Fix check for EFAULT.
Avoid returning -1, return 0 instead.
--- libc/sysdeps/unix/sysv/linux/times.c.jj 2008-04-19 18:43:26.000000000 +0200
+++ libc/sysdeps/unix/sysv/linux/times.c 2008-04-22 09:19:26.000000000 +0200
@@ -27,7 +27,7 @@ __times (struct tms *buf)
INTERNAL_SYSCALL_DECL (err);
clock_t ret = INTERNAL_SYSCALL (times, err, 1, buf);
if (INTERNAL_SYSCALL_ERROR_P (ret, err)
- && __builtin_expect (INTERNAL_SYSCALL_ERRNO (ret, err) == -EFAULT, 0))
+ && __builtin_expect (INTERNAL_SYSCALL_ERRNO (ret, err) == EFAULT, 0))
{
/* This might be an error or not. For architectures which have
no separate return value and error indicators we cannot
@@ -49,6 +49,11 @@ __times (struct tms *buf)
return an EFAULT error. Return the value given by the kernel. */
}
+ /* Return value (clock_t) -1 signals an error, but if there wasn't any,
+ return the following value. */
+ if (ret == (clock_t) -1)
+ return (clock_t) 0;
+
return ret;
}
weak_alias (__times, times)
Jakub
reply other threads:[~2008-04-22 7:26 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080422073658.GH3726@sunsite.mff.cuni.cz \
--to=jakub@redhat.com \
--cc=drepper@redhat.com \
--cc=libc-hacker@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).