From f6ea4d25e95972f482e14cdcefaa0789e6158d35 Mon Sep 17 00:00:00 2001 From: Vasily Gorbik Date: Mon, 18 Jun 2018 16:50:42 +0200 Subject: [PATCH] s390: fix gcc 8 stringop-truncation warnings in proc handlers 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 Signed-off-by: Vasily Gorbik Signed-off-by: Martin Schwidefsky --- arch/s390/appldata/appldata_base.c | 5 ++--- arch/s390/kernel/topology.c | 3 +-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/arch/s390/appldata/appldata_base.c b/arch/s390/appldata/appldata_base.c index ee6a9c387c87..25c1399b0787 100644 --- a/arch/s390/appldata/appldata_base.c +++ b/arch/s390/appldata/appldata_base.c @@ -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; diff --git a/arch/s390/kernel/topology.c b/arch/s390/kernel/topology.c index 4b6e0397f66d..33ebb423c613 100644 --- a/arch/s390/kernel/topology.c +++ b/arch/s390/kernel/topology.c @@ -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; -- 2.30.2