[PATCH (2) 27/34] shm_open.3: Use sizeof consistently

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>From d3f439e697c9a384cad55e84a584493088eb4291 Mon Sep 17 00:00:00 2001
From: Alejandro Colomar <colomar.6.4.3@xxxxxxxxx>
Date: Thu, 3 Sep 2020 21:55:48 +0200
Subject: [PATCH 27/34] shm_open.3: 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>
---
 man3/shm_open.3 | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/man3/shm_open.3 b/man3/shm_open.3
index bba4eb826..24cc6a403 100644
--- a/man3/shm_open.3
+++ b/man3/shm_open.3
@@ -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)
-- 
2.28.0



[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux