Skip to contentSkip to conversation

hpsa: Change memset using sizeof(ptr) to sizeof(*ptr)

RFC PATCH In review Joe Perches 2 participants 2 messages May 9, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 hpsa: Change memset using sizeof(ptr) to sizeof(*ptr)

Not at all sure this is correct or appropriate to change, but this seems odd.

Found via coccinelle script

@@
type T;
T* ptr;
expression E1;
@@

* memset(E1, 0, sizeof(ptr));

---
 drivers/scsi/hpsa.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/scsi/hpsa.c +1 -1
index 415ad4f..c8d97b4 100644
@@ -1308,7 +1308,7 @@ static void hpsa_scsi_do_simple_cmd_with_retry(struct ctlr_info *h,
 	int retry_count = 0;
 
 	do {
-		memset(c->err_info, 0, sizeof(c->err_info));
+		memset(c->err_info, 0, sizeof(*c->err_info));
 		hpsa_scsi_do_simple_cmd_core(h, c);
 		retry_count++;
 	} while (check_for_unit_attention(h, c) && retry_count <= 3);
#1 lore raw
Quoted 4 lines · Joe Perches

Not at all sure this is correct or appropriate to change, but this seems odd.

Found via coccinelle script

Ack.

-- steve

Quoted 28 lines

@@
type T;
T* ptr;
expression E1;
@@

* memset(E1, 0, sizeof(ptr));

---
 drivers/scsi/hpsa.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/scsi/hpsa.c +1 -1
index 415ad4f..c8d97b4 100644
@@ -1308,7 +1308,7 @@ static void hpsa_scsi_do_simple_cmd_with_retry(struct ctlr_info *h,
 	int retry_count = 0;
 
 	do {
-		memset(c->err_info, 0, sizeof(c->err_info));
+		memset(c->err_info, 0, sizeof(*c->err_info));
 		hpsa_scsi_do_simple_cmd_core(h, c);
 		retry_count++;
 	} while (check_for_unit_attention(h, c) && retry_count <= 3);