Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1720221

[PATCH 07/14] vme: fake: Improve five size determinations in fake_init()

From SF Markus Elfring <elfring@users.sourceforge.net>
Newsgroups linux.kernel
Subject [PATCH 07/14] vme: fake: Improve five size determinations in fake_init()
Date 2017-08-25 18:10 +0200
Message-ID <uiplf-6dJ-1@gated-at.bofh.it> (permalink)
References <uip1T-5RV-11@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 25 Aug 2017 09:46:13 +0200

Replace the specification of data structures by pointer dereferences
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/vme/bridges/vme_fake.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/vme/bridges/vme_fake.c b/drivers/vme/bridges/vme_fake.c
index 6ceea5e9fd8b..39f84df44557 100644
--- a/drivers/vme/bridges/vme_fake.c
+++ b/drivers/vme/bridges/vme_fake.c
@@ -1075,11 +1075,11 @@ static int __init fake_init(void)
 	/* If we want to support more than one bridge at some point, we need to
 	 * dynamically allocate this so we get one per device.
 	 */
-	fake_bridge = kzalloc(sizeof(struct vme_bridge), GFP_KERNEL);
+	fake_bridge = kzalloc(sizeof(*fake_bridge), GFP_KERNEL);
 	if (fake_bridge == NULL) {
 		retval = -ENOMEM;
 		goto err_struct;
 	}
 
-	fake_device = kzalloc(sizeof(struct fake_driver), GFP_KERNEL);
+	fake_device = kzalloc(sizeof(*fake_device), GFP_KERNEL);
 	if (fake_device == NULL) {
@@ -1104,6 +1104,5 @@ static int __init fake_init(void)
 	/* Add master windows to list */
 	INIT_LIST_HEAD(&fake_bridge->master_resources);
 	for (i = 0; i < FAKE_MAX_MASTER; i++) {
-		master_image = kmalloc(sizeof(struct vme_master_resource),
-				GFP_KERNEL);
+		master_image = kmalloc(sizeof(*master_image), GFP_KERNEL);
 		if (master_image == NULL) {
@@ -1131,6 +1130,5 @@ static int __init fake_init(void)
 	/* Add slave windows to list */
 	INIT_LIST_HEAD(&fake_bridge->slave_resources);
 	for (i = 0; i < FAKE_MAX_SLAVE; i++) {
-		slave_image = kmalloc(sizeof(struct vme_slave_resource),
-				GFP_KERNEL);
+		slave_image = kmalloc(sizeof(*slave_image), GFP_KERNEL);
 		if (slave_image == NULL) {
@@ -1154,5 +1152,5 @@ static int __init fake_init(void)
 
 	/* Add location monitor to list */
 	INIT_LIST_HEAD(&fake_bridge->lm_resources);
-	lm = kmalloc(sizeof(struct vme_lm_resource), GFP_KERNEL);
+	lm = kmalloc(sizeof(*lm), GFP_KERNEL);
 	if (lm == NULL) {
-- 
2.14.0

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 00/14] VME: Adjustments for several function implementations SF Markus Elfring <elfring@users.sourceforge.net> - 2017-08-25 17:50 +0200
  [PATCH 01/14] vme: Delete 11 error messages for a failed memory  allocation SF Markus Elfring <elfring@users.sourceforge.net> - 2017-08-25 18:00 +0200
  [PATCH 02/14] vme: Improve 11 size determinations SF Markus Elfring <elfring@users.sourceforge.net> - 2017-08-25 18:00 +0200
  [PATCH 03/14] vme: Move an assignment in vme_new_dma_list() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-08-25 18:00 +0200
  [PATCH 04/14] vme: Adjust 48 checks for null pointers SF Markus Elfring <elfring@users.sourceforge.net> - 2017-08-25 18:00 +0200
  [PATCH 07/14] vme: fake: Improve five size determinations in  fake_init() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-08-25 18:10 +0200
  [PATCH 05/14] vme: Return directly in two functions SF Markus Elfring <elfring@users.sourceforge.net> - 2017-08-25 18:10 +0200
  [PATCH 06/14] vme: fake: Delete an error message for a failed memory  allocation in fake_init() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-08-25 18:10 +0200
  [PATCH 08/14] vme: fake: Adjust 11 checks for null pointers SF Markus Elfring <elfring@users.sourceforge.net> - 2017-08-25 18:10 +0200
  [PATCH 09/14] vme: ca91cx42: Delete eight error messages for a failed  memory allocation SF Markus Elfring <elfring@users.sourceforge.net> - 2017-08-25 18:10 +0200
  [PATCH 10/14] vme: ca91cx42: Improve 12 size determinations SF Markus Elfring <elfring@users.sourceforge.net> - 2017-08-25 18:10 +0200
  [PATCH 13/14] vme: tsi148: Improve 17 size determinations SF Markus Elfring <elfring@users.sourceforge.net> - 2017-08-25 18:20 +0200
    Re: [PATCH 13/14] vme: tsi148: Improve 17 size determinations Martyn Welch <martyn@welchs.me.uk> - 2017-08-25 23:00 +0200
      Re: [PATCH 13/14] vme: tsi148: Improve 17 size determinations SF Markus Elfring <elfring@users.sourceforge.net> - 2017-08-26 09:10 +0200
        Re: [PATCH 13/14] vme: tsi148: Improve 17 size determinations Martyn Welch <martyn@welchs.me.uk> - 2017-08-30 21:50 +0200
          Re: [PATCH 13/14] vme: tsi148: Improve 17 size determinations SF Markus Elfring <elfring@users.sourceforge.net> - 2017-08-30 23:00 +0200
  [PATCH 11/14] vme: ca91cx42: Adjust 14 checks for null pointers SF Markus Elfring <elfring@users.sourceforge.net> - 2017-08-25 18:20 +0200
  [PATCH 12/14] vme: tsi148: Delete nine error messages for a failed  memory allocation SF Markus Elfring <elfring@users.sourceforge.net> - 2017-08-25 18:20 +0200
  [PATCH 14/14] vme: tsi148: Adjust 14 checks for null pointers SF Markus Elfring <elfring@users.sourceforge.net> - 2017-08-25 18:20 +0200
  Re: [PATCH 00/14] VME: Adjustments for several function  implementations Martyn Welch <martyn@welchs.me.uk> - 2017-08-26 00:00 +0200
    Re: [PATCH 00/14] VME: Adjustments for several function  implementations Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-26 09:10 +0200

csiph-web