From 87ef72e1260fee0882a0dcdb8d329b268f09ca0c Mon Sep 17 00:00:00 2001 From: Igor Pashev Date: Wed, 30 Oct 2019 14:11:05 +0200 Subject: Use memcpy instead of strncpy MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix warning: ‘strncpy’ output truncated before terminating nul copying 3 bytes from a string of the same length [-Werror=stringop-truncation] --- brainfuck.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/brainfuck.c b/brainfuck.c index 69dae83..fb15282 100644 --- a/brainfuck.c +++ b/brainfuck.c @@ -418,17 +418,17 @@ optimize_code () } /* - * FIXME valid while we use finite integers + * FIXME valid while we use finite integers */ substr = new_code; while (NULL != (substr = strstr (substr, "[-]"))) { - strncpy (substr, "Z ", 3); /* [-] set current cell to 0 */ + memcpy (substr, "Z ", 3); /* [-] set current cell to 0 */ } substr = new_code; while (NULL != (substr = strstr (substr, "[+]"))) { - strncpy (substr, "Z ", 3); /* [-] set current cell to 0 */ + memcpy (substr, "Z ", 3); /* [-] set current cell to 0 */ } free (code); -- cgit v1.2.3