[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 New
Headers show
Series
  • Add types, and some fixes
Related show

Commit Message

H.J. Lu via Libc-alpha Sept. 25, 2020, 7:31 a.m.
Signed-off-by: Alejandro Colomar <colomar.6.4.3@gmail.com>

---
 man2/seccomp.2 | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

-- 
2.28.0

Comments

H.J. Lu via Libc-alpha Sept. 25, 2020, 9:25 a.m. | #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,

>      };

>  

> 



-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/

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,
     };