Linux filesystem development
 help / color / mirror / Atom feed
From: Jean Delvare <khali@linux-fr.org>
To: Andries Brouwer <aeb@cwi.nl>
Cc: linux-fsdevel@vger.kernel.org
Subject: [PATCH] partitions: Prefer strlcpy() over snprintf()
Date: Thu, 10 Jul 2008 13:30:04 +0200	[thread overview]
Message-ID: <20080710133004.26c0b991@hyperion.delvare> (raw)

Subject: partitions: Prefer strlcpy() over snprintf()

strlcpy is faster than snprintf when you don't use the returned value.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Cc: Andries Brouwer <aeb@cwi.nl>
---
This patch was already sent on:
 * 2008-05-09

 fs/partitions/check.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- linux-2.6.26-rc1.orig/fs/partitions/check.c	2008-05-09 17:35:37.000000000 +0200
+++ linux-2.6.26-rc1/fs/partitions/check.c	2008-05-09 17:39:13.000000000 +0200
@@ -123,7 +123,7 @@ static int (*check_part[])(struct parsed
 char *disk_name(struct gendisk *hd, int part, char *buf)
 {
 	if (!part)
-		snprintf(buf, BDEVNAME_SIZE, "%s", hd->disk_name);
+		strlcpy(buf, hd->disk_name, BDEVNAME_SIZE);
 	else if (isdigit(hd->disk_name[strlen(hd->disk_name)-1]))
 		snprintf(buf, BDEVNAME_SIZE, "%sp%d", hd->disk_name, part);
 	else


-- 
Jean Delvare

             reply	other threads:[~2008-07-10 11:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-10 11:30 Jean Delvare [this message]
2008-07-10 12:28 ` [PATCH] partitions: Prefer strlcpy() over snprintf() Andries E. Brouwer
2008-07-10 13:03   ` Jean Delvare

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080710133004.26c0b991@hyperion.delvare \
    --to=khali@linux-fr.org \
    --cc=aeb@cwi.nl \
    --cc=linux-fsdevel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox