hfsplus: Replace strncpy with memcpy
Subsystems (2)
PATCH 1/1 hfsplus: Replace strncpy with memcpy
Function strncpy was used to copy a fixed size buffer. Since NUL-terminating string is not required here, prefer a memcpy function. The generated code (ppc32) remains the same.
Silence the following warning triggered using W=1:
fs/hfsplus/xattr.c:410:3: warning: 'strncpy' output truncated before terminating nul copying 4 bytes from a string of the same length [-Wstringop-truncation]
--- fs/hfsplus/xattr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/hfsplus/xattr.c +1 -1
@@ -407,7 +407,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 ; }
Signature · 1 line
2.20.1
Quoted 28 lines · Mathieu Malaterre
Function strncpy was used to copy a fixed size buffer. Since NUL-terminating string is not required here, prefer a memcpy function.
The generated code (ppc32) remains the same.Silence the following warning triggered using W=1:
fs/hfsplus/xattr.c:410:3: warning: 'strncpy' output truncated before terminating nul copying 4 bytes from a string of the same length [-Wstringop-truncation]Signed-off-by Mathieu Malaterre <[email protected]>---
fs/hfsplus/xattr.c | 2 +-1 file changed, 1 insertion(+), 1 deletion(-)fs/hfsplus/xattr.c +0
-0@@ -407,7 +407,7 @@ static int copy_name(char *buffer, const char *xattr_name, int name_len) int offset = 0;
if (!is_known_namespace(xattr_name)) {fs/hfsplus/xattr.c +0
-1- strncpy(buffer, XATTR_MAC_OSX_PREFIX,
XATTR_MAC_OSX_PREFIX_LEN);fs/hfsplus/xattr.c +1
-0+ memcpy(buffer, XATTR_MAC_OSX_PREFIX,
Quoted 4 lines
XATTR_MAC_OSX_PREFIX_LEN);
offset +=XATTR_MAC_OSX_PREFIX_LEN; len +=XATTR_MAC_OSX_PREFIX_LEN; }
Looks good. I don't see any troubles here.
Thanks,
Vyacheslav Dubeyko.