diff mbox series

[13/26] Linux: getrandom syscall number is always available

Message ID ac0ba6febb01f1f794d2067d80906539f9a10b9d.1581279333.git.fweimer@redhat.com
State New
Headers show
Series Linux cleanups enabled by built-in system call tables | expand

Commit Message

Florian Weimer Feb. 9, 2020, 8:20 p.m. UTC
Due to the built-in tables, __NR_getrandom is always defined.
---
 sysdeps/unix/sysv/linux/getentropy.c |  9 ---------
 sysdeps/unix/sysv/linux/getrandom.c  | 13 -------------
 2 files changed, 22 deletions(-)

Comments

Adhemerval Zanella Feb. 27, 2020, 11:20 p.m. UTC | #1
On 09/02/2020 17:20, Florian Weimer wrote:
> Due to the built-in tables, __NR_getrandom is always defined.

LGTM, thanks. 

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>

> ---
>  sysdeps/unix/sysv/linux/getentropy.c |  9 ---------
>  sysdeps/unix/sysv/linux/getrandom.c  | 13 -------------
>  2 files changed, 22 deletions(-)
> 
> diff --git a/sysdeps/unix/sysv/linux/getentropy.c b/sysdeps/unix/sysv/linux/getentropy.c
> index 5d0b8d10c1..2f3a4e4692 100644
> --- a/sysdeps/unix/sysv/linux/getentropy.c
> +++ b/sysdeps/unix/sysv/linux/getentropy.c
> @@ -21,7 +21,6 @@
>  #include <errno.h>
>  #include <unistd.h>
>  
> -#ifdef __NR_getrandom
>  /* Write LENGTH bytes of randomness starting at BUFFER.  Return 0 on
>     success and -1 on failure.  */
>  int
> @@ -63,11 +62,3 @@ getentropy (void *buffer, size_t length)
>      }
>    return 0;
>  }
> -#else
> -int
> -getentropy (void *buffer, size_t length)
> -{
> -  __set_errno (ENOSYS);
> -  return -1;
> -}
> -#endif

Ok..

> diff --git a/sysdeps/unix/sysv/linux/getrandom.c b/sysdeps/unix/sysv/linux/getrandom.c
> index 309beadf72..63b8d36bf4 100644
> --- a/sysdeps/unix/sysv/linux/getrandom.c
> +++ b/sysdeps/unix/sysv/linux/getrandom.c
> @@ -21,7 +21,6 @@
>  #include <unistd.h>
>  #include <sysdep-cancel.h>
>  
> -#ifdef __NR_getrandom
>  /* Write up to LENGTH bytes of randomness starting at BUFFER.
>     Return the number of bytes written, or -1 on error.  */
>  ssize_t
> @@ -29,17 +28,5 @@ __getrandom (void *buffer, size_t length, unsigned int flags)
>  {
>    return SYSCALL_CANCEL (getrandom, buffer, length, flags);
>  }
> -#else
> -/* Always provide a definition, even if the kernel headers lack the
> -   system call number. */
> -ssize_t
> -__getrandom (void *buffer, size_t length, unsigned int flags)
> -{
> -  /* Ideally, we would add a cancellation point here, but we currently
> -     cannot do so inside libc.  */
> -  __set_errno (ENOSYS);
> -  return -1;
> -}
> -#endif
>  libc_hidden_def (__getrandom)
>  weak_alias (__getrandom, getrandom)
>
diff mbox series

Patch

diff --git a/sysdeps/unix/sysv/linux/getentropy.c b/sysdeps/unix/sysv/linux/getentropy.c
index 5d0b8d10c1..2f3a4e4692 100644
--- a/sysdeps/unix/sysv/linux/getentropy.c
+++ b/sysdeps/unix/sysv/linux/getentropy.c
@@ -21,7 +21,6 @@ 
 #include <errno.h>
 #include <unistd.h>
 
-#ifdef __NR_getrandom
 /* Write LENGTH bytes of randomness starting at BUFFER.  Return 0 on
    success and -1 on failure.  */
 int
@@ -63,11 +62,3 @@  getentropy (void *buffer, size_t length)
     }
   return 0;
 }
-#else
-int
-getentropy (void *buffer, size_t length)
-{
-  __set_errno (ENOSYS);
-  return -1;
-}
-#endif
diff --git a/sysdeps/unix/sysv/linux/getrandom.c b/sysdeps/unix/sysv/linux/getrandom.c
index 309beadf72..63b8d36bf4 100644
--- a/sysdeps/unix/sysv/linux/getrandom.c
+++ b/sysdeps/unix/sysv/linux/getrandom.c
@@ -21,7 +21,6 @@ 
 #include <unistd.h>
 #include <sysdep-cancel.h>
 
-#ifdef __NR_getrandom
 /* Write up to LENGTH bytes of randomness starting at BUFFER.
    Return the number of bytes written, or -1 on error.  */
 ssize_t
@@ -29,17 +28,5 @@  __getrandom (void *buffer, size_t length, unsigned int flags)
 {
   return SYSCALL_CANCEL (getrandom, buffer, length, flags);
 }
-#else
-/* Always provide a definition, even if the kernel headers lack the
-   system call number. */
-ssize_t
-__getrandom (void *buffer, size_t length, unsigned int flags)
-{
-  /* Ideally, we would add a cancellation point here, but we currently
-     cannot do so inside libc.  */
-  __set_errno (ENOSYS);
-  return -1;
-}
-#endif
 libc_hidden_def (__getrandom)
 weak_alias (__getrandom, getrandom)