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

login
register
mail settings
Submitter Levente Kurusa
Date Oct. 29, 2013, 6:38 p.m.
Message ID <527000AE.8060506@linux.com>
Download mbox | patch
Permalink /patch/287021/
State Not Applicable
Delegated to: David Miller
Headers show

Comments

Levente Kurusa - Oct. 29, 2013, 6:38 p.m.
Remove an unnecessary arithmetic operation from a call to snprintf, because
the size parameter of snprintf includes the trailing null byte.

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, 6:53 p.m.
Hello,

On Tue, Oct 29, 2013 at 07:38:38PM +0100, Levente Kurusa wrote:
> Remove an unnecessary arithmetic operation from a call to snprintf, because
> the size parameter of snprintf includes the trailing null byte.
> 
> Signed-off-by: Levente Kurusa <levex@linux.com>
> ---
> 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
> @@ -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.
Levente Kurusa - Oct. 29, 2013, 6:58 p.m.
2013-10-29 19:53 keltezéssel, Tejun Heo írta:
> Hello,
> 
> On Tue, Oct 29, 2013 at 07:38:38PM +0100, Levente Kurusa wrote:
>> Remove an unnecessary arithmetic operation from a call to snprintf, because
>> the size parameter of snprintf includes the trailing null byte.
>>
>> Signed-off-by: Levente Kurusa <levex@linux.com>
>> ---
>> 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
>> @@ -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?

Sure, sending v2 in a moment.

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