]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
s390: fix gcc 8 stringop-truncation warnings in proc handlers
authorVasily Gorbik <gor@linux.ibm.com>
Mon, 18 Jun 2018 14:50:42 +0000 (16:50 +0200)
committerMartin Schwidefsky <schwidefsky@de.ibm.com>
Mon, 2 Jul 2018 09:24:53 +0000 (11:24 +0200)
arch/s390/kernel/topology.c:591:3: warning: 'strncpy' output truncated
before terminating nul copying 2 bytes from a string of the same length
[-Wstringop-truncation]
   strncpy(buf, topology_is_enabled() ? "1\n" : "0\n", ARRAY_SIZE(buf));

arch/s390/appldata/appldata_base.c:326:3: warning: 'strncpy' output truncated
before terminating nul copying 2 bytes from a string of the same length
[-Wstringop-truncation]
   strncpy(buf, ops->active ? "1\n" : "0\n", ARRAY_SIZE(buf));

arch/s390/appldata/appldata_base.c:217:3: warning: 'strncpy' output truncated
before terminating nul copying 2 bytes from a string of the same length
[-Wstringop-truncation]
   strncpy(buf, appldata_timer_active ? "1\n" : "0\n", ARRAY_SIZE(buf));

To avoid the warning, just reuse memcpy.

Reviewed-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
arch/s390/appldata/appldata_base.c
arch/s390/kernel/topology.c

index ee6a9c387c8796cb8bc035c052d0806f6cec4dae..25c1399b07876acdbca37701b374f714f909e9f6 100644 (file)
@@ -214,8 +214,7 @@ appldata_timer_handler(struct ctl_table *ctl, int write,
                return 0;
        }
        if (!write) {
-               strncpy(buf, appldata_timer_active ? "1\n" : "0\n",
-                       ARRAY_SIZE(buf));
+               memcpy(buf, appldata_timer_active ? "1\n" : "0\n", ARRAY_SIZE(buf));
                len = strnlen(buf, ARRAY_SIZE(buf));
                if (len > *lenp)
                        len = *lenp;
@@ -323,7 +322,7 @@ appldata_generic_handler(struct ctl_table *ctl, int write,
                return 0;
        }
        if (!write) {
-               strncpy(buf, ops->active ? "1\n" : "0\n", ARRAY_SIZE(buf));
+               memcpy(buf, ops->active ? "1\n" : "0\n", ARRAY_SIZE(buf));
                len = strnlen(buf, ARRAY_SIZE(buf));
                if (len > *lenp)
                        len = *lenp;
index 4b6e0397f66d634738af71bc748e0b4a30177f7b..33ebb423c6133df761a26924801c226e967b77ba 100644 (file)
@@ -588,8 +588,7 @@ static int topology_ctl_handler(struct ctl_table *ctl, int write,
                return 0;
        }
        if (!write) {
-               strncpy(buf, topology_is_enabled() ? "1\n" : "0\n",
-                       ARRAY_SIZE(buf));
+               memcpy(buf, topology_is_enabled() ? "1\n" : "0\n", ARRAY_SIZE(buf));
                len = strnlen(buf, ARRAY_SIZE(buf));
                if (len > *lenp)
                        len = *lenp;