Patchwork [trivial,v2] ata: libata-eh: Remove unnecessary snprintf arithmetic

login
register
mail settings
Submitter Levente Kurusa
Date Oct. 29, 2013, 7:01 p.m.
Message ID <5270061A.3080108@linux.com>
Download mbox | patch
Permalink /patch/287025/
State Not Applicable
Delegated to: David Miller
Headers show

Comments

Levente Kurusa - Oct. 29, 2013, 7:01 p.m.
Remove an unnecessary arithmetic operation from a call to snprintf, because
the size parameter of snprintf includes the trailing null space.
Also, initialize the buffer on definition instead of a memset call.

Signed-off-by: Levente Kurusa <levex@linux.com>
---
--
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Tejun Heo - Oct. 29, 2013, 7:16 p.m.
On Tue, Oct 29, 2013 at 08:01:46PM +0100, Levente Kurusa wrote:
> Remove an unnecessary arithmetic operation from a call to snprintf, because
> the size parameter of snprintf includes the trailing null space.
> Also, initialize the buffer on definition instead of a memset call.
> 
> Signed-off-by: Levente Kurusa <levex@linux.com>

Applied to libata/for-3.13.

Thanks.

Patch

diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
index f9476fb..b7c4146 100644
--- a/drivers/ata/libata-eh.c
+++ b/drivers/ata/libata-eh.c
@@ -2394,7 +2399,7 @@  static void ata_eh_link_report(struct ata_link *link)
 	struct ata_port *ap = link->ap;
 	struct ata_eh_context *ehc = &link->eh_context;
 	const char *frozen, *desc;
-	char tries_buf[6];
+	char tries_buf[6] = "";
 	int tag, nr_failed = 0;

 	if (ehc->i.flags & ATA_EHI_QUIET)
@@ -2425,9 +2432,8 @@  static void ata_eh_link_report(struct ata_link *link)
 	if (ap->pflags & ATA_PFLAG_FROZEN)
 		frozen = " frozen";

-	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) {