maint: avoid -Wstringop-truncation warnings upcoming GCC8
* src/buffer.c (gnu_add_multi_volume_header): Convert a use of
strncpy to memcpy, to avoid this warning:
In function 'strncpy',
inlined from 'gnu_add_multi_volume_header' at buffer.c:1782:3,
...
/usr/include/bits/string_fortified.h:106:10: error: '__builtin_strncpy'\
specified bound 100 equals destination size \
[-Werror=stringop-truncation]
This commit is contained in:
committed by
Sergey Poznyakoff
parent
ccef8581b8
commit
2baa531ce5
14
src/buffer.c
14
src/buffer.c
@@ -1771,15 +1771,19 @@ gnu_add_multi_volume_header (struct bufmap *map)
|
||||
{
|
||||
int tmp;
|
||||
union block *block = find_next_block ();
|
||||
size_t len = strlen (map->file_name);
|
||||
|
||||
if (strlen (map->file_name) > NAME_FIELD_SIZE)
|
||||
WARN ((0, 0,
|
||||
_("%s: file name too long to be stored in a GNU multivolume header, truncated"),
|
||||
quotearg_colon (map->file_name)));
|
||||
if (len > NAME_FIELD_SIZE)
|
||||
{
|
||||
WARN ((0, 0,
|
||||
_("%s: file name too long to be stored in a GNU multivolume header, truncated"),
|
||||
quotearg_colon (map->file_name)));
|
||||
len = NAME_FIELD_SIZE;
|
||||
}
|
||||
|
||||
memset (block, 0, BLOCKSIZE);
|
||||
|
||||
strncpy (block->header.name, map->file_name, NAME_FIELD_SIZE);
|
||||
memcpy (block->header.name, map->file_name, len);
|
||||
block->header.typeflag = GNUTYPE_MULTIVOL;
|
||||
|
||||
OFF_TO_CHARS (map->sizeleft, block->header.size);
|
||||
|
||||
Reference in New Issue
Block a user