logo

utils-std

Collection of commonly available Unix tools git clone https://anongit.hacktivis.me/git/utils-std.git/
commit: fedb08274b3858cdbdca6d497f0239498f9acd7d
parent b5f0e9cdaaa9485a0af9e2e1ece1a93d066c1737
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Sun, 15 Dec 2024 02:29:34 +0100

cmd/strings: remove memset

NULL termination is already asserted

Diffstat:

Mcmd/strings.c5+----
1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/cmd/strings.c b/cmd/strings.c @@ -10,7 +10,7 @@ #include <limits.h> /* LONG_MAX */ #include <stdio.h> /* fprintf(), BUFSIZ */ #include <stdlib.h> /* strtol() */ -#include <string.h> /* strerror(), strncmp(), memset() */ +#include <string.h> /* strerror(), strncmp() */ #include <unistd.h> /* read(), write(), close(), getopt(), optarg, optind */ size_t opt_min_strlen = 4; @@ -52,8 +52,6 @@ concat(int fd, const char *fdname) size_t write_pos = 0; size_t offset = 0; - memset(write_buf, 0, sizeof(write_buf)); - while((c = read(fd, read_buf, sizeof(read_buf))) > 0) { int read_pos = 0; @@ -82,7 +80,6 @@ concat(int fd, const char *fdname) offset += write_pos; offset++; write_pos = 0; - memset(write_buf, 0, sizeof(write_buf)); } } }