----- 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 <anpr...@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

Reply via email to