mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
While assembling the volume label, strncpy() is used. As we don't care
about NUL termination of the strings here, safely replace strncpy() with
memcpy() and get rid of the following compile warnings:
fdasd.c: In function ‘fdasd_write_vtoc_labels’:
fdasd.c:1324:4: warning: ‘strncpy’ output truncated before terminating
nul copying 44 bytes from a string of the same length
[-Wstringop-truncation]
strncpy(ch, "LINUX.V "
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
" ", 44);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fdasd.c:1332:4: warning: ‘strncpy’ output truncated before terminating
nul copying 5 bytes from a string of the same length
[-Wstringop-truncation]
strncpy(c1, ".PART", 5);
^~~~~~~~~~~~~~~~~~~~~~~
In function ‘fdasd_write_vtoc_labels’,
inlined from ‘fdasd_write_labels’ at fdasd.c:1399:3:
fdasd.c:1329:4: warning: ‘strncpy’ output may be truncated copying 6
bytes from a string of length 6 [-Wstringop-truncation]
strncpy(c1, volser, VOLSER_LENGTH);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fdasd.c:1336:4: warning: ‘strncpy’ output may be truncated copying 5
bytes from a string of length 5 [-Wstringop-truncation]
strncpy(c1, dsno, 5);
^~~~~~~~~~~~~~~~~~~~
fdasd.c:1340:4: warning: ‘strncpy’ output truncated before terminating
nul copying as many bytes from a string as its length
[-Wstringop-truncation]
strncpy(c1, dsname, strlen(dsname)); /* We don't want \0 */
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fdasd.c:1313:4: warning: ‘strncpy’ output may be truncated copying 31
bytes from a string of length 44 [-Wstringop-truncation]
strncpy(c1, s2, 31);
^~~~~~~~~~~~~~~~~~~
In function ‘fdasd_change_part_type’,
inlined from ‘main’ at fdasd.c:3000:4:
fdasd.c:1639:3: warning: ‘strncpy’ output may be truncated copying 6
bytes from a string of length 19 [-Wstringop-truncation]
strncpy(ch, str, 6);
^~~~~~~~~~~~~~~~~~~
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>