logo

utils-std

Collection of commonly available Unix tools git clone https://anongit.hacktivis.me/git/utils-std.git
commit: fb19516f44850e5219c3dfe0bf19b5150d34f857
parent d2c378b1e5a09ff97aaae36c3846db6309934588
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Fri, 15 Nov 2024 17:55:30 +0100

cmd/yes: use `static char` for args-less and empty-string

Helps on avoiding a weird bug with GCC where it would get random data.

Diffstat:

Mcmd/yes.c8++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/cmd/yes.c b/cmd/yes.c @@ -26,8 +26,8 @@ main(int argc, char *argv[]) if(argc == 1) { - char yes[3] = {'y', '\n', '\0'}; - args = yes; + static char str_yes[3] = {'y', '\n', '\0'}; + args = str_yes; args_len = 2; } else @@ -46,8 +46,8 @@ main(int argc, char *argv[]) if(args_len == 0) { - argv[0][0] = '\n'; - argv[0][1] = '\0'; + static char str_nl[2] = {'\n', '\0'}; + args = str_nl; args_len = 1; } else