s390/tape: fix stringop-truncation gcc 8 warnings
authorVasily Gorbik <gor@linux.ibm.com>
Mon, 18 Jun 2018 20:49:32 +0000 (22:49 +0200)
committerMartin Schwidefsky <schwidefsky@de.ibm.com>
Mon, 2 Jul 2018 09:25:02 +0000 (11:25 +0200)
Use strlcpy to make sure strings are NUL-terminated. Fixes the following
gcc 8 warning:

inlined from 'register_tape_dev' at drivers/s390/char/tape_class.c:57:2:
./include/linux/string.h:246:9: warning: '__builtin_strncpy' specified
bound 32 equals destination size [-Wstringop-truncation]

Acked-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
drivers/s390/char/tape_class.c

index a071024..e403edf 100644 (file)
@@ -54,10 +54,10 @@ struct tape_class_device *register_tape_dev(
        if (!tcd)
                return ERR_PTR(-ENOMEM);
 
-       strncpy(tcd->device_name, device_name, TAPECLASS_NAME_LEN);
+       strlcpy(tcd->device_name, device_name, TAPECLASS_NAME_LEN);
        for (s = strchr(tcd->device_name, '/'); s; s = strchr(s, '/'))
                *s = '!';
-       strncpy(tcd->mode_name, mode_name, TAPECLASS_NAME_LEN);
+       strlcpy(tcd->mode_name, mode_name, TAPECLASS_NAME_LEN);
        for (s = strchr(tcd->mode_name, '/'); s; s = strchr(s, '/'))
                *s = '!';