From patchwork Thu Apr 28 12:25:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiaoming Ni X-Patchwork-Id: 53312 X-Patchwork-Delegate: siddhesh@gotplt.org Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1A68D385734E for ; Thu, 28 Apr 2022 12:29:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1A68D385734E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1651148964; bh=ELeZUx+e9PPeU0jiGAfYsWXvcRXl2FAbwdusOJB+jFc=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=afS/XsbZblWaaQ3l1HlecoIE4HkpBdCrEEEyT8HkvW5fKxOd7SQJ/Q7NXOqroX1if Ftua1D+m72pW61+z7zt7SvZTmGvq0VgUXUHCY0Kv8kAVvw2reWrMTzfSvGqEsAgyyQ VSeDC2kGXMJmzLTkhm0qS9zDXWX4yXr0YvawMYbA= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by sourceware.org (Postfix) with ESMTPS id E02DE385737A for ; Thu, 28 Apr 2022 12:25:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E02DE385737A Received: from canpemm500006.china.huawei.com (unknown [172.30.72.56]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4Kpvq06G4TzCsPY; Thu, 28 Apr 2022 20:21:00 +0800 (CST) Received: from use12-sp2.huawei.com (10.67.189.174) by canpemm500006.china.huawei.com (7.192.105.130) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 28 Apr 2022 20:25:34 +0800 To: , , , , , Subject: [PATCH 4/4] clock_settime/clock_gettime: Use __nonnull to avoid null pointer Date: Thu, 28 Apr 2022 20:25:29 +0800 Message-ID: <20220428122529.108208-5-nixiaoming@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220428122529.108208-1-nixiaoming@huawei.com> References: <20220428122529.108208-1-nixiaoming@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.189.174] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To canpemm500006.china.huawei.com (7.192.105.130) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-13.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_MANYTO, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Xiaoming Ni via Libc-alpha From: Xiaoming Ni Reply-To: Xiaoming Ni Cc: libc-alpha@sourceware.org, wangle6@huawei.com, nixiaoming@huawei.com Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" clock_settime() clock_settime64() clock_gettime() clock_gettime64() Add __nonnull((2)) to avoid null pointer access. Link: https://sourceware.org/bugzilla/show_bug.cgi?id=27662 Link: https://sourceware.org/bugzilla/show_bug.cgi?id=29084 Signed-off-by: Xiaoming Ni --- include/time.h | 4 ++-- time/time.h | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/include/time.h b/include/time.h index 127347eb90..a64eff54f5 100644 --- a/include/time.h +++ b/include/time.h @@ -166,7 +166,7 @@ libc_hidden_proto (__timegm64) # define __clock_settime64 __clock_settime #else extern int __clock_settime64 (clockid_t clock_id, - const struct __timespec64 *tp); + const struct __timespec64 *tp) __nonnull((2)); libc_hidden_proto (__clock_settime64) #endif @@ -324,7 +324,7 @@ extern int __clock_nanosleep_time64 (clockid_t clock_id, int flags, const struct __timespec64 *req, struct __timespec64 *rem); libc_hidden_proto (__clock_nanosleep_time64) -extern int __clock_gettime64 (clockid_t clock_id, struct __timespec64 *tp); +extern int __clock_gettime64 (clockid_t clock_id, struct __timespec64 *tp) __nonnull((2)); libc_hidden_proto (__clock_gettime64) extern int __timespec_get64 (struct __timespec64 *ts, int base); libc_hidden_proto (__timespec_get64) diff --git a/time/time.h b/time/time.h index 847ac3f8c0..26f276f147 100644 --- a/time/time.h +++ b/time/time.h @@ -276,11 +276,12 @@ extern int nanosleep (const struct timespec *__requested_time, extern int clock_getres (clockid_t __clock_id, struct timespec *__res) __THROW; /* Get current value of clock CLOCK_ID and store it in TP. */ -extern int clock_gettime (clockid_t __clock_id, struct timespec *__tp) __THROW; +extern int clock_gettime (clockid_t __clock_id, struct timespec *__tp) + __THROW __nonnull((2)); /* Set clock CLOCK_ID to value TP. */ extern int clock_settime (clockid_t __clock_id, const struct timespec *__tp) - __THROW; + __THROW __nonnull((2)); # else # ifdef __REDIRECT extern int __REDIRECT (nanosleep, (const struct timespec *__requested_time, @@ -291,8 +292,10 @@ extern int __REDIRECT_NTH (clock_getres, (clockid_t __clock_id, __clock_getres64); extern int __REDIRECT_NTH (clock_gettime, (clockid_t __clock_id, struct timespec *__tp), __clock_gettime64); + __nonnull((2)); extern int __REDIRECT_NTH (clock_settime, (clockid_t __clock_id, const struct - timespec *__tp), __clock_settime64); + timespec *__tp), __clock_settime64) + __nonnull((2)); # else # define nanosleep __nanosleep64 # define clock_getres __clock_getres64