Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 space.
Also, initialize the buffer on definition instead of a memset call.

Signed-off-by: Levente Kurusa <levex@linux.com>
Signed-off-by: Tejun Heo <tj@kernel.org>

authored by

Levente Kurusa and committed by
Tejun Heo
462098b0 6ce4eac1

+2 -3
+2 -3
drivers/ata/libata-eh.c
··· 2402 2402 struct ata_port *ap = link->ap; 2403 2403 struct ata_eh_context *ehc = &link->eh_context; 2404 2404 const char *frozen, *desc; 2405 - char tries_buf[6]; 2405 + char tries_buf[6] = ""; 2406 2406 int tag, nr_failed = 0; 2407 2407 2408 2408 if (ehc->i.flags & ATA_EHI_QUIET) ··· 2433 2433 if (ap->pflags & ATA_PFLAG_FROZEN) 2434 2434 frozen = " frozen"; 2435 2435 2436 - memset(tries_buf, 0, sizeof(tries_buf)); 2437 2436 if (ap->eh_tries < ATA_EH_MAX_TRIES) 2438 - snprintf(tries_buf, sizeof(tries_buf) - 1, " t%d", 2437 + snprintf(tries_buf, sizeof(tries_buf), " t%d", 2439 2438 ap->eh_tries); 2440 2439 2441 2440 if (ehc->i.dev) {