mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Viacheslav Dubeyko <slava@dubeyko.com>
To: Xiongfeng Wang <wangxiongfeng2@huawei.com>,
	linux-fsdevel@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, arnd@arndb.de
Subject: Re: [PATCH] fs/hfsplus: use memcpy() instead of strncpy()
Date: Mon, 08 Jan 2018 09:56:26 -0800	[thread overview]
Message-ID: <1515434186.7215.17.camel@dubeyko.com> (raw)
In-Reply-To: <1515413857-48430-1-git-send-email-wangxiongfeng2@huawei.com>

On Mon, 2018-01-08 at 20:17 +0800, Xiongfeng Wang wrote:
> From: Xiongfeng Wang <xiongfeng.wang@linaro.org>
> 
> gcc-8 reports
> 
> inlined from 'copy_name' at fs/hfsplus/xattr.c:416:3:
> ./include/linux/string.h:245:9: warning: '__builtin_strncpy' output
> truncated before terminating nul copying 4 bytes from a string of the
> same length [-Wstringop-truncation]
> 
> Since we don't need to copy '\0', we can just use memcpy() to avoid
> this
> warning.
> 

If the gcc-8 emits the warning then the suggested change makes sense.
Looks good.

Reviewed-by: Vyacheslav Dubeyko <slava@dubeyko.com>

Thanks,
Vyacheslav Dubeyko.


> Signed-off-by: Xiongfeng Wang <xiongfeng.wang@linaro.org>
> ---
>  fs/hfsplus/xattr.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/hfsplus/xattr.c b/fs/hfsplus/xattr.c
> index e538b75..0dc8a65 100644
> --- a/fs/hfsplus/xattr.c
> +++ b/fs/hfsplus/xattr.c
> @@ -413,7 +413,7 @@ static int copy_name(char *buffer, const char
> *xattr_name, int name_len)
>  	int offset = 0;
>  
>  	if (!is_known_namespace(xattr_name)) {
> -		strncpy(buffer, XATTR_MAC_OSX_PREFIX,
> XATTR_MAC_OSX_PREFIX_LEN);
> +		memcpy(buffer, XATTR_MAC_OSX_PREFIX,
> XATTR_MAC_OSX_PREFIX_LEN);
>  		offset += XATTR_MAC_OSX_PREFIX_LEN;
>  		len += XATTR_MAC_OSX_PREFIX_LEN;
>  	}

      reply	other threads:[~2018-01-08 17:56 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-08 12:17 Xiongfeng Wang
2018-01-08 17:56 ` Viacheslav Dubeyko [this message]

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=1515434186.7215.17.camel@dubeyko.com \
    --to=slava@dubeyko.com \
    --cc=arnd@arndb.de \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=wangxiongfeng2@huawei.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®