From be209c0a4e4d93c24e6374e798c3a1abf0685be4 Mon Sep 17 00:00:00 2001 From: Sebastien GODARD Date: Fri, 20 Jul 2018 17:20:36 +0200 Subject: [PATCH] sar.c: Fix gcc warning about possible variables overlap MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Fix gcc warning: sar.c: In function ‘write_stats_avg’: sar.c:372:2: warning: ‘strcpy’ accessing 1 byte at offsets [0, 64] and [0, 128] may overlap 1 byte at offset 0 [-Wrestrict] strcpy(timestamp[!curr], timestamp[curr]); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Sebastien GODARD --- sar.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sar.c b/sar.c index f2e4306..b387887 100644 --- a/sar.c +++ b/sar.c @@ -369,7 +369,7 @@ void write_stats_avg(int curr, int read_from_file, unsigned int act_id) strncpy(timestamp[curr], _("Average:"), TIMESTAMP_LEN); timestamp[curr][TIMESTAMP_LEN - 1] = '\0'; - strcpy(timestamp[!curr], timestamp[curr]); + memcpy(timestamp[!curr], timestamp[curr], TIMESTAMP_LEN); /* Test stdout */ TEST_STDOUT(STDOUT_FILENO); -- 2.40.0