lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <b6b76d67-6ece-1677-6006-2b7495db94fe@gmail.com>
Date:   Fri, 11 Sep 2020 10:04:26 +0200
From:   "Michael Kerrisk (man-pages)" <mtk.manpages@...il.com>
To:     Alejandro Colomar <colomar.6.4.3@...il.com>
Cc:     mtk.manpages@...il.com, linux-man@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH 14/24] fread.3: Move ARRAY_SIZE logic into macro

Hi Alex,

On 9/10/20 11:13 PM, Alejandro Colomar wrote:
> Signed-off-by: Alejandro Colomar <colomar.6.4.3@...il.com>

I don't have strong feelings for or against this patch. I guess
it does make the code more expressive, which is good. Patch applied.

Thanks,

Michael

> ---
>  man3/fread.3 | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/man3/fread.3 b/man3/fread.3
> index 4c5dc3dbc..8e71e620e 100644
> --- a/man3/fread.3
> +++ b/man3/fread.3
> @@ -136,6 +136,8 @@ Class: 0x02
>  #include <stdio.h>
>  #include <stdlib.h>
>  
> +#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
> +
>  int
>  main(void)
>  {
> @@ -147,9 +149,7 @@ main(void)
>  
>      unsigned char buffer[4];
>  
> -    size_t ret =
> -        fread(buffer, sizeof(buffer) / sizeof(*buffer), sizeof(*buffer),
> -              fp);
> +    size_t ret = fread(buffer, ARRAY_SIZE(buffer), sizeof(*buffer), fp);
>      if (ret != sizeof(*buffer)) {
>          fprintf(stderr, "fread() failed: %zu\en", ret);
>          exit(EXIT_FAILURE);
> 


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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ