From: Bob Peterson Date: Wed, 28 Jan 2015 08:13:01 -0500 (EST) Subject: [Cluster-devel] [PATCH 2/3] fsck.gfs2: Simplify bad_journalname In-Reply-To: <1422373935-19184-2-git-send-email-anprice@redhat.com> References: <1422373935-19184-1-git-send-email-anprice@redhat.com> <1422373935-19184-2-git-send-email-anprice@redhat.com> Message-ID: <1324983030.2636962.1422450781714.JavaMail.zimbra@redhat.com> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit ----- 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 > --- > 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