[3/4] clock_adjtime: Use __nonnull to avoid null pointer

Message ID 20220428122529.108208-4-nixiaoming@huawei.com
State Superseded
Delegated to: Siddhesh Poyarekar
Headers
Series time: Use __nonnull to avoid null pointer |

Checks

Context Check Description
dj/TryBot-apply_patch success Patch applied to master at the time it was sent

Commit Message

Xiaoming Ni April 28, 2022, 12:25 p.m. UTC
  clock_adjtime()/clock_adjtime64()
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>
---
 sysdeps/unix/sysv/linux/bits/time.h         | 4 ++--
 sysdeps/unix/sysv/linux/include/sys/timex.h | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
  

Comments

Siddhesh Poyarekar May 4, 2022, 11 a.m. UTC | #1
On 28/04/2022 17:55, Xiaoming Ni via Libc-alpha wrote:
> clock_adjtime()/clock_adjtime64()
> 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>


>   sysdeps/unix/sysv/linux/bits/time.h         | 4 ++--
>   sysdeps/unix/sysv/linux/include/sys/timex.h | 2 +-
>   2 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/sysdeps/unix/sysv/linux/bits/time.h b/sysdeps/unix/sysv/linux/bits/time.h
> index efb4a014df..0485a1e181 100644
> --- a/sysdeps/unix/sysv/linux/bits/time.h
> +++ b/sysdeps/unix/sysv/linux/bits/time.h
> @@ -75,13 +75,13 @@ extern long int __sysconf (int);
>   __BEGIN_DECLS
>   
>   /* Tune a POSIX clock.  */
> -extern int clock_adjtime (__clockid_t __clock_id, struct timex *__utx) __THROW;
> +extern int clock_adjtime (__clockid_t __clock_id, struct timex *__utx) __THROW __nonnull((2));
>   
>   #ifdef __USE_TIME_BITS64
>   # if defined(__REDIRECT_NTH)
>   extern int __REDIRECT_NTH (clock_adjtime, (__clockid_t __clock_id,
>                                              struct timex *__utx),
> -                           __clock_adjtime64);
> +                           __clock_adjtime64) __nonnull((2));
>   # else
>   # define clock_adjtime __clock_adjtime64
>   # endif
> diff --git a/sysdeps/unix/sysv/linux/include/sys/timex.h b/sysdeps/unix/sysv/linux/include/sys/timex.h
> index 9d0da60640..0c0261a06d 100644
> --- a/sysdeps/unix/sysv/linux/include/sys/timex.h
> +++ b/sysdeps/unix/sysv/linux/include/sys/timex.h
> @@ -77,7 +77,7 @@ struct __timex64
>     int  :32;
>     int  :32;
>   };
> -extern int __clock_adjtime64 (const clockid_t clock_id, struct __timex64 *tx64);
> +extern int __clock_adjtime64 (const clockid_t clock_id, struct __timex64 *tx64) __nonnull((2));
>   libc_hidden_proto (__clock_adjtime64);
>   extern int ___adjtimex64 (struct __timex64 *tx64) __nonnull ((1));
>   libc_hidden_proto (___adjtimex64)
  

Patch

diff --git a/sysdeps/unix/sysv/linux/bits/time.h b/sysdeps/unix/sysv/linux/bits/time.h
index efb4a014df..0485a1e181 100644
--- a/sysdeps/unix/sysv/linux/bits/time.h
+++ b/sysdeps/unix/sysv/linux/bits/time.h
@@ -75,13 +75,13 @@  extern long int __sysconf (int);
 __BEGIN_DECLS
 
 /* Tune a POSIX clock.  */
-extern int clock_adjtime (__clockid_t __clock_id, struct timex *__utx) __THROW;
+extern int clock_adjtime (__clockid_t __clock_id, struct timex *__utx) __THROW __nonnull((2));
 
 #ifdef __USE_TIME_BITS64
 # if defined(__REDIRECT_NTH)
 extern int __REDIRECT_NTH (clock_adjtime, (__clockid_t __clock_id,
                                            struct timex *__utx),
-                           __clock_adjtime64);
+                           __clock_adjtime64) __nonnull((2));
 # else
 # define clock_adjtime __clock_adjtime64
 # endif
diff --git a/sysdeps/unix/sysv/linux/include/sys/timex.h b/sysdeps/unix/sysv/linux/include/sys/timex.h
index 9d0da60640..0c0261a06d 100644
--- a/sysdeps/unix/sysv/linux/include/sys/timex.h
+++ b/sysdeps/unix/sysv/linux/include/sys/timex.h
@@ -77,7 +77,7 @@  struct __timex64
   int  :32;
   int  :32;
 };
-extern int __clock_adjtime64 (const clockid_t clock_id, struct __timex64 *tx64);
+extern int __clock_adjtime64 (const clockid_t clock_id, struct __timex64 *tx64) __nonnull((2));
 libc_hidden_proto (__clock_adjtime64);
 extern int ___adjtimex64 (struct __timex64 *tx64) __nonnull ((1));
 libc_hidden_proto (___adjtimex64)