Hello Alex, On 9/3/20 12:23 PM, Alejandro Colomar wrote: > Hi Michael, > > Continuing with the series, this is the first of the last set of > patches: (2).1 as numbered in previous emails. I must admit that I don't care too much either way on this. That is to say, I'm not sure one way is any clearer than the other. However, I have applied the patch. In passing, I note that there is a clarity issue that I do find more significant though: the repeated calculations in the malloc() and printf() calls. So I changed that: https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/commit/?id=15fc4aab1f22c2d4f62ab7f74bbb844942708633 Thanks, Michael > ------------------------------------------------------------------------ >>From ad5f958ed68079791d6e35f9d70ca5ec2a72c43b Mon Sep 17 00:00:00 2001 > From: Alejandro Colomar <colomar.6.4.3@xxxxxxxxx> > Date: Thu, 3 Sep 2020 12:11:18 +0200 > Subject: [PATCH] memusage.1: Use sizeof consistently > > Use ``sizeof`` consistently through all the examples in the following > way: > > - Use the name of the variable instead of its type as argument for > ``sizeof``. > > Rationale: > https://www.kernel.org/doc/html/v5.8/process/coding-style.html#allocating-memory > > Signed-off-by: Alejandro Colomar <colomar.6.4.3@xxxxxxxxx> > --- > man1/memusage.1 | 12 ++++++------ > 1 file changed, 6 insertions(+), 6 deletions(-) > > diff --git a/man1/memusage.1 b/man1/memusage.1 > index fa1987c79..a03468442 100644 > --- a/man1/memusage.1 > +++ b/man1/memusage.1 > @@ -247,8 +247,8 @@ main(int argc, char *argv[]) > int i, j; > int *p; > > - printf("malloc: %zd\en", sizeof(int) * 100); > - p = malloc(sizeof(int) * 100); > + printf("malloc: %zd\en", sizeof(*p) * 100); > + p = malloc(sizeof(*p) * 100); > > for (i = 0; i < CYCLES; i++) { > if (i < CYCLES / 2) > @@ -256,11 +256,11 @@ main(int argc, char *argv[]) > else > j--; > > - printf("realloc: %zd\en", sizeof(int) * (j * 50 + 110)); > - p = realloc(p, sizeof(int) * (j * 50 + 100)); > + printf("realloc: %zd\en", sizeof(*p) * (j * 50 + 110)); > + p = realloc(p, sizeof(*p) * (j * 50 + 100)); > > - printf("realloc: %zd\en", sizeof(int) * ((j+1) * 150 + 110)); > - p = realloc(p, sizeof(int) * ((j + 1) * 150 + 110)); > + printf("realloc: %zd\en", sizeof(*p) * ((j+1) * 150 + 110)); > + p = realloc(p, sizeof(*p) * ((j + 1) * 150 + 110)); > } > > free(p); > -- Michael Kerrisk Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ Linux/UNIX System Programming Training: http://man7.org/training/