lkml.org 
[lkml]   [2020]   [Sep]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    SubjectRe: [PATCH 14/24] fread.3: Move ARRAY_SIZE logic into macro
    From
    Date
    Hi Alex,

    On 9/10/20 11:13 PM, Alejandro Colomar wrote:
    > Signed-off-by: Alejandro Colomar <colomar.6.4.3@gmail.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/

    \
     
     \ /
      Last update: 2020-09-11 10:05    [W:11.181 / U:0.200 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site