diff mbox series

[09/10] seccomp.2: Use ARRAY_SIZE() macro instead of raw sizeof division

Message ID 20200925073140.173394-10-colomar.6.4.3@gmail.com
State Not Applicable
Headers show
Series Add types, and some fixes | expand

Commit Message

Alejandro Colomar Sept. 25, 2020, 7:31 a.m. UTC
Signed-off-by: Alejandro Colomar <colomar.6.4.3@gmail.com>
---
 man2/seccomp.2 | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Michael Kerrisk \(man-pages\) Sept. 25, 2020, 9:25 a.m. UTC | #1
On 9/25/20 9:31 AM, Alejandro Colomar wrote:
> Signed-off-by: Alejandro Colomar <colomar.6.4.3@gmail.com>

Thanks, Alex. Patch applied.

Cheers,

Michael

> ---
>  man2/seccomp.2 | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/man2/seccomp.2 b/man2/seccomp.2
> index d6b856c32..82eb04dc6 100644
> --- a/man2/seccomp.2
> +++ b/man2/seccomp.2
> @@ -1051,6 +1051,7 @@ cecilia
>  #include <sys/prctl.h>
>  
>  #define X32_SYSCALL_BIT 0x40000000
> +#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
>  
>  static int
>  install_filter(int syscall_nr, int t_arch, int f_errno)
> @@ -1101,7 +1102,7 @@ install_filter(int syscall_nr, int t_arch, int f_errno)
>      };
>  
>      struct sock_fprog prog = {
> -        .len = sizeof(filter) / sizeof(filter[0]),
> +        .len = ARRAY_SIZE(filter),
>          .filter = filter,
>      };
>  
>
diff mbox series

Patch

diff --git a/man2/seccomp.2 b/man2/seccomp.2
index d6b856c32..82eb04dc6 100644
--- a/man2/seccomp.2
+++ b/man2/seccomp.2
@@ -1051,6 +1051,7 @@  cecilia
 #include <sys/prctl.h>
 
 #define X32_SYSCALL_BIT 0x40000000
+#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
 
 static int
 install_filter(int syscall_nr, int t_arch, int f_errno)
@@ -1101,7 +1102,7 @@  install_filter(int syscall_nr, int t_arch, int f_errno)
     };
 
     struct sock_fprog prog = {
-        .len = sizeof(filter) / sizeof(filter[0]),
+        .len = ARRAY_SIZE(filter),
         .filter = filter,
     };