From: Bob Peterson <rpeterso@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH 2/3] fsck.gfs2: Simplify bad_journalname
Date: Wed, 28 Jan 2015 08:13:01 -0500 (EST) [thread overview]
Message-ID: <1324983030.2636962.1422450781714.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: <1422373935-19184-2-git-send-email-anprice@redhat.com>
----- Original Message -----
> Remove the need for a temporary string and strncpy call by passing the
> length of the string to printf.
>
> Signed-off-by: Andrew Price <anprice@redhat.com>
> ---
> gfs2/fsck/initialize.c | 8 ++------
> 1 file changed, 2 insertions(+), 6 deletions(-)
>
> diff --git a/gfs2/fsck/initialize.c b/gfs2/fsck/initialize.c
> index 1ab078b..c052205 100644
> --- a/gfs2/fsck/initialize.c
> +++ b/gfs2/fsck/initialize.c
> @@ -1513,14 +1513,10 @@ static int init_rindex(struct gfs2_sbd *sdp)
>
> static void bad_journalname(const char *filename, int len)
> {
> - char tmp_name[64];
> -
> if (len >= 64)
> len = 63;
> - strncpy(tmp_name, filename, len);
> - tmp_name[len] = '\0';
> - log_debug(_("Journal index entry '%s' has an invalid filename.\n"),
> - tmp_name);
> + log_debug(_("Journal index entry '%.*s' has an invalid filename.\n"),
> + len, filename);
> }
>
> /**
> --
> 1.9.3
Nice trick (strangely, I've never used that construct), but we could just as well get rid of the whole function altogether.
Bob Peterson
Red Hat File Systems
next prev parent reply other threads:[~2015-01-28 13:13 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-27 15:52 [Cluster-devel] [PATCH 1/3] fsck.gfs2: Fix 'initializer element is not constant' build error Andrew Price
2015-01-27 15:52 ` [Cluster-devel] [PATCH 2/3] fsck.gfs2: Simplify bad_journalname Andrew Price
2015-01-28 13:13 ` Bob Peterson [this message]
2015-01-28 15:14 ` Andrew Price
2015-01-27 15:52 ` [Cluster-devel] [PATCH 3/3] gfs2-utils build: Add a configure script summary Andrew Price
2015-01-28 13:13 ` Bob Peterson
2015-01-28 13:09 ` [Cluster-devel] [PATCH 1/3] fsck.gfs2: Fix 'initializer element is not constant' build error Bob Peterson
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=1324983030.2636962.1422450781714.JavaMail.zimbra@redhat.com \
--to=rpeterso@redhat.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.