The branch stable/15 has been updated by des:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=1e7d914ffcbee31a410822d002cc2650ca1076f3

commit 1e7d914ffcbee31a410822d002cc2650ca1076f3
Author:     Dag-Erling Smørgrav <[email protected]>
AuthorDate: 2026-08-17 16:04:35 +0000
Commit:     Dag-Erling Smørgrav <[email protected]>
CommitDate: 2026-08-27 06:33:50 +0000

    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:          cf74b63d61b4 ("yes: Completely overengineer")
    MFC after:      1 week
    Sponsored by:   Klara, Inc.
    Reviewed by:    kevans
    Differential Revision:  https://reviews.freebsd.org/D58890
    
    (cherry picked from commit 557ba0c2a5138ce026c0ea9cb02f374f97378b7c)
---
 usr.bin/yes/yes.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/usr.bin/yes/yes.c b/usr.bin/yes/yes.c
index 86022c82f453..66bb01d4de47 100644
--- a/usr.bin/yes/yes.c
+++ b/usr.bin/yes/yes.c
@@ -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;
        }
 
        /*

Reply via email to