Re: [patch] memusage.1, bind.2, eventfd.2, futex.2, open_by_handle_at.2, perf_event_open.2, poll.2, signalfd.2, sysctl.2, timerfd_create.2, bsearch.3, cmsg.3, getaddrinfo.3, getaddrinfo_a.3 getgrouplist.3, insque.3, malloc_info.3, mbsinit.3, mbstowcs.3, pthread_create.3, pthread_setaffinity_np.3, queue.3, rtnetlink.3, shm_open.3, strptime.3, tsearch.3, aio.7, fanotify.7, inotify.7, unix.7: Use sizeof consistently

Michael Kerrisk (man-pages)
2020-08-25T12:35:12Z

Hi Alex,

On 8/25/20 2:21 PM, Alejandro Colomar wrote:
> This is the patch for (1) as numbered in the previous replies:
>
> -----------------------------------------------------------------------
>>From b0880bd0485d9abc93bcb3055342ec328240b7cf Mon Sep 17 00:00:00 2001
> From: Alejandro Colomar <colomar.6.4.3@gmail.com>
> Date: Tue, 25 Aug 2020 14:14:21 +0200
> Subject: [PATCH] getgrouplist.3, inotify.7: Use sizeof consistently
>
> Use ``sizeof`` consistently through all the examples in the following
> way:
>
> - Never use a space after ``sizeof``, and always use parentheses around
> the argument.
>
> Rationale:
>
> https://www.kernel.org/doc/html/v5.8/process/coding-style.html#spaces

Patch applied, but I had to fix up the title line, which got taken
from the mail subject line. Probably best to send subsequent patches
as new mails, rather than as replies to this thread.

Thanks,

Michael

> Signed-off-by: Alejandro Colomar <colomar.6.4.3@gmail.com>
> ---
> man3/getgrouplist.3 | 2 +-
> man7/inotify.7 | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/man3/getgrouplist.3 b/man3/getgrouplist.3
> index 61c88f75f..aea52d999 100644
> --- a/man3/getgrouplist.3
> +++ b/man3/getgrouplist.3
> @@ -164,7 +164,7 @@ main(int argc, char *argv[])
>
> ngroups = atoi(argv[2]);
>
> - groups = malloc(ngroups * sizeof (gid_t));
> + groups = malloc(ngroups * sizeof(gid_t));
> if (groups == NULL) {
> perror("malloc");
> exit(EXIT_FAILURE);
> diff --git a/man7/inotify.7 b/man7/inotify.7
> index e60d9c82b..9b2d7a4e5 100644
> --- a/man7/inotify.7
> +++ b/man7/inotify.7
> @@ -952,7 +952,7 @@ handle_events(int fd, int *wd, int argc, char* argv[])
>
> /* Read some events. */
>
> - len = read(fd, buf, sizeof buf);
> + len = read(fd, buf, sizeof(buf));
> if (len == \-1 && errno != EAGAIN) {
> perror("read");
> 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/