From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5990 invoked by alias); 22 Apr 2008 07:26:57 -0000 Received: (qmail 5972 invoked by uid 22791); 22 Apr 2008 07:26:56 -0000 X-Spam-Check-By: sourceware.org Received: from sunsite.ms.mff.cuni.cz (HELO sunsite.mff.cuni.cz) (195.113.15.26) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 22 Apr 2008 07:26:39 +0000 Received: from sunsite.mff.cuni.cz (localhost.localdomain [127.0.0.1]) by sunsite.mff.cuni.cz (8.13.8/8.13.8) with ESMTP id m3M7axAk009738; Tue, 22 Apr 2008 09:36:59 +0200 Received: (from jakub@localhost) by sunsite.mff.cuni.cz (8.13.8/8.13.8/Submit) id m3M7axJg009737; Tue, 22 Apr 2008 09:36:59 +0200 Date: Tue, 22 Apr 2008 07:26:00 -0000 From: Jakub Jelinek To: Ulrich Drepper Cc: Glibc hackers Subject: [PATCH] times fixes Message-ID: <20080422073658.GH3726@sunsite.mff.cuni.cz> Reply-To: Jakub Jelinek Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.2.2i Mailing-List: contact libc-hacker-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-hacker-owner@sourceware.org X-SW-Source: 2008-04/txt/msg00002.txt.bz2 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 * 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