Skip to contentSkip to conversation

ata: libata-eh: Remove unnecessary snprintf arithmetic

PATCH Superseded Levente Kurusa 2 participants 3 messages Oct 29, 2013 libata

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ata: libata-eh: Remove unnecessary snprintf arithmetic

Remove an unnecessary arithmetic operation from a call to snprintf, because the size parameter of snprintf includes the trailing null byte.

---

drivers/ata/libata-eh.c +1 -1
index f9476fb..b7c4146 100644
@@ -2427,7 +2434,7 @@ static void ata_eh_link_report(struct ata_link *link)
 
 	memset(tries_buf, 0, sizeof(tries_buf));
 	if (ap->eh_tries < ATA_EH_MAX_TRIES)
-		snprintf(tries_buf, sizeof(tries_buf) - 1, " t%d",
+		snprintf(tries_buf, sizeof(tries_buf), " t%d",
 			 ap->eh_tries);
 
 	if (ehc->i.dev) {
#1 lore raw

Hello,

drivers/ata/libata-eh.c static void ata_eh_link_report(struct ata_link *link) · line 2435

Quoted 12 lines · Levente Kurusa

Remove an unnecessary arithmetic operation from a call to snprintf, because the size parameter of snprintf includes the trailing null byte.

---

drivers/ata/libata-eh.c +0 -0
index f9476fb..b7c4146 100644
@@ -2427,7 +2434,7 @@ static void ata_eh_link_report(struct ata_link *link)
 
 	memset(tries_buf, 0, sizeof(tries_buf));

While at it, can you please remove the above and just initialize the buffer to "" on definition?

Thanks.

Signature · 1 line
tejun
#2 lore raw

2013-10-29 19:53 keltezéssel, Tejun Heo írta:

Quoted 14 lines

Hello,

Quoted 11 lines · Levente Kurusa

Remove an unnecessary arithmetic operation from a call to snprintf, because the size parameter of snprintf includes the trailing null byte.

---

drivers/ata/libata-eh.c +0 -0
index f9476fb..b7c4146 100644
@@ -2427,7 +2434,7 @@ static void ata_eh_link_report(struct ata_link *link)
 
Quoted 4 lines

drivers/ata/libata-eh.c static void ata_eh_link_report(struct ata_link *link) · line 2435

Quoted 1 line
drivers/ata/libata-eh.c +0 -0
 	memset(tries_buf, 0, sizeof(tries_buf));

While at it, can you please remove the above and just initialize the buffer to "" on definition?

Sure, sending v2 in a moment.

Signature · 2 lines
Regards,
Levente Kurusa