diff mbox series

[v2,4/4] clock_settime/clock_gettime: Use __nonnull to avoid null pointer

Message ID 20220505030111.111197-5-nixiaoming@huawei.com
State New
Headers show
Series time: Use __nonnull to avoid null pointer | expand

Commit Message

Xiaoming Ni May 5, 2022, 3:01 a.m. UTC
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 <nixiaoming@huawei.com>
---
 include/time.h |  4 ++--
 time/time.h    | 11 +++++++----
 2 files changed, 9 insertions(+), 6 deletions(-)

Comments

Siddhesh Poyarekar May 5, 2022, 4:26 a.m. UTC | #1
On 05/05/2022 08:31, Xiaoming Ni via Libc-alpha wrote:
> 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 <nixiaoming@huawei.com>
> ---

LGTM.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>

Do you have commit access or do you need someone to push this for you?

Thanks,
Siddhesh
Xiaoming Ni May 5, 2022, 8:23 a.m. UTC | #2
On 2022/5/5 12:26, Siddhesh Poyarekar wrote:
> On 05/05/2022 08:31, Xiaoming Ni via Libc-alpha wrote:
>> 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 <nixiaoming@huawei.com>
>> ---
> 
> LGTM.
> 
> Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
> 
> Do you have commit access or do you need someone to push this for you?
> 
> Thanks,
> Siddhesh
> 
> .
I don't have the permission to push directly.
Can you help push this patch set?

Thanks
Xiaoming Ni
.
Siddhesh Poyarekar May 5, 2022, 12:26 p.m. UTC | #3
On 05/05/2022 13:53, Xiaoming Ni via Libc-alpha wrote:
> On 2022/5/5 12:26, Siddhesh Poyarekar wrote:
>> On 05/05/2022 08:31, Xiaoming Ni via Libc-alpha wrote:
>>> 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 <nixiaoming@huawei.com>
>>> ---
>>
>> LGTM.
>>
>> Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
>>
>> Do you have commit access or do you need someone to push this for you?
>>
>> Thanks,
>> Siddhesh
>>
>> .
> I don't have the permission to push directly.
> Can you help push this patch set?

Done, thanks.

Siddhesh
diff mbox series

Patch

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..2cf89e6222 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,
@@ -290,9 +291,11 @@  extern int __REDIRECT_NTH (clock_getres, (clockid_t __clock_id,
                                           struct timespec *__res),
                            __clock_getres64);
 extern int __REDIRECT_NTH (clock_gettime, (clockid_t __clock_id, struct
-                                           timespec *__tp), __clock_gettime64);
+                                           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