yes: Avoid static initialization

Our buffer is half a megabyte, but we are only initializing the first
two bytes.  Switching from static to dynamic initialization moves it
from .data to .bss, greatly reducing the size of the binary.

Fixes:		cf74b63d61 ("yes: Completely overengineer")
MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	kevans
Differential Revision:	https://reviews.freebsd.org/D58890
This commit is contained in:
Dag-Erling Smørgrav committed 2026-08-17 18:04:35 +02:00
1 parent f370d9e4d5
commit 557ba0c2a5
1 file changed
+7 -3
+7 -3
View File
@@ -55,9 +55,9 @@
int
main(int argc, char **argv)
{
static char buf[MAXBUF] = EXP;
char *end = buf + sizeof(buf), *exp, *pos = buf + EXPLEN;
size_t buflen, explen = EXPLEN;
static char buf[MAXBUF];
char *end = buf + sizeof(buf), *exp, *pos;
size_t buflen, explen;
ssize_t wlen = 0;
if (caph_limit_stdio() < 0 || caph_enter() < 0)
@@ -83,6 +83,10 @@ main(int argc, char **argv)
pos = end - 2;
*pos++ = '\n';
explen = pos - buf;
} else {
memcpy(buf, EXP, EXPLEN);
pos = buf + EXPLEN;
explen = EXPLEN;
}
/*