]> git.ipfire.org Git - thirdparty/man-pages.git/commitdiff
shm_open.3: Use sizeof consistently
authorAlejandro Colomar <colomar.6.4.3@gmail.com>
Thu, 3 Sep 2020 19:55:48 +0000 (21:55 +0200)
committerMichael Kerrisk <mtk.manpages@gmail.com>
Sat, 5 Sep 2020 12:49:42 +0000 (14:49 +0200)
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@gmail.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
man3/shm_open.3

index bba4eb8266394b39442fa270febd4ea2c514054d..24cc6a40320c180de6298620f5e66b6319bb5e4f 100644 (file)
@@ -382,7 +382,7 @@ main(int argc, char *argv[])
 
     /* Map the object into the caller\(aqs address space */
 
-    struct shmbuf *shmp = mmap(NULL, sizeof(struct shmbuf),
+    struct shmbuf *shmp = mmap(NULL, sizeof(*shmp),
                                PROT_READ | PROT_WRITE,
                                MAP_SHARED, fd, 0);
     if (shmp == MAP_FAILED)
@@ -471,7 +471,7 @@ main(int argc, char *argv[])
     if (fd == \-1)
         errExit("shm_open");
 
-    struct shmbuf *shmp = mmap(NULL, sizeof(struct shmbuf),
+    struct shmbuf *shmp = mmap(NULL, sizeof(*shmp),
                                PROT_READ | PROT_WRITE,
                                MAP_SHARED, fd, 0);
     if (shmp == MAP_FAILED)