From patchwork Wed Jun 22 08:49:25 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Huang X-Patchwork-Id: 2152 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 8449223F4D for ; Wed, 22 Jun 2011 08:49:27 +0000 (UTC) Received: from mail-vx0-f180.google.com (mail-vx0-f180.google.com [209.85.220.180]) by fiordland.canonical.com (Postfix) with ESMTP id 4C581A1842F for ; Wed, 22 Jun 2011 08:49:27 +0000 (UTC) Received: by vxd7 with SMTP id 7so659880vxd.11 for ; Wed, 22 Jun 2011 01:49:26 -0700 (PDT) Received: by 10.52.175.197 with SMTP id cc5mr542306vdc.287.1308732566685; Wed, 22 Jun 2011 01:49:26 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.52.183.130 with SMTP id em2cs123204vdc; Wed, 22 Jun 2011 01:49:26 -0700 (PDT) Received: by 10.216.142.133 with SMTP id i5mr446654wej.43.1308732565798; Wed, 22 Jun 2011 01:49:25 -0700 (PDT) Received: from mail-wy0-f178.google.com (mail-wy0-f178.google.com [74.125.82.178]) by mx.google.com with ESMTPS id y21si841667weq.139.2011.06.22.01.49.25 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 22 Jun 2011 01:49:25 -0700 (PDT) Received-SPF: neutral (google.com: 74.125.82.178 is neither permitted nor denied by best guess record for domain of jim.huang@linaro.org) client-ip=74.125.82.178; Authentication-Results: mx.google.com; spf=neutral (google.com: 74.125.82.178 is neither permitted nor denied by best guess record for domain of jim.huang@linaro.org) smtp.mail=jim.huang@linaro.org Received: by wya21 with SMTP id 21so491914wya.37 for ; Wed, 22 Jun 2011 01:49:25 -0700 (PDT) MIME-Version: 1.0 Received: by 10.216.69.205 with SMTP id n55mr459867wed.35.1308732565256; Wed, 22 Jun 2011 01:49:25 -0700 (PDT) Received: by 10.216.12.71 with HTTP; Wed, 22 Jun 2011 01:49:25 -0700 (PDT) Date: Wed, 22 Jun 2011 16:49:25 +0800 Message-ID: Subject: [PATCH android/bionic] time: Improve C99 compliance From: Jim Huang To: linaro-dev Cc: patches Quote from Linux Programmer's Manual: "If t is non-NULL, the return value is also stored in the memory pointed to by t." Code Review: https://review.source.android.com/#change,23998 >From 30a19b9cdbe509d62c7d4c5df9a6daab13ff8857 Mon Sep 17 00:00:00 2001 From: Jim Huang Date: Thu, 16 Jun 2011 22:40:10 +0800 Subject: [PATCH 2/2] time: Improve C99 compliance Quote from Linux Programmer's Manual: "If t is non-NULL, the return value is also stored in the memory pointed to by t." Change-Id: I8cb66b67e5f34c536ce2f0db76a6dc337c42ea3f --- libc/unistd/time.c | 11 +++++++---- 1 files changed, 7 insertions(+), 4 deletions(-) diff --git a/libc/unistd/time.c b/libc/unistd/time.c index 13d7366..7b450c7 100644 --- a/libc/unistd/time.c +++ b/libc/unistd/time.c @@ -34,12 +34,15 @@ time_t time(time_t *t) { struct timeval tt; + time_t ret; if (gettimeofday(&tt, (struct timezone *)0) < 0) - return (-1); - if (t) - *t = (time_t)tt.tv_sec; - return (tt.tv_sec); + ret = -1; + else + ret = tt.tv_sec; + if (t != NULL) + *t = ret; + return ret; } -- 1.7.5.4