The branch main has been updated by kevans:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=2e47009079fc01ca05c9779d85616e1df037693c

commit 2e47009079fc01ca05c9779d85616e1df037693c
Author:     Kyle Evans <kev...@freebsd.org>
AuthorDate: 2025-05-29 20:08:49 +0000
Commit:     Kyle Evans <kev...@freebsd.org>
CommitDate: 2025-05-29 20:08:49 +0000

    mail: don't rewrite buffer sizes as much
    
    Thes buffers are arrays with a known size, just use sizeof() rather than
    rewriting their sizes -- no functional change, slightly more resilient
    against future possible errors.
    
    Reviewed by:    markj
    Sponsored by:   Klara, Inc.
    Differential Revision:  https://reviews.freebsd.org/D50582
---
 usr.bin/mail/collect.c | 11 ++++++-----
 usr.bin/mail/lex.c     |  3 ++-
 usr.bin/mail/util.c    | 10 +++++-----
 3 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/usr.bin/mail/collect.c b/usr.bin/mail/collect.c
index 97c4d499ea3a..8c308d217195 100644
--- a/usr.bin/mail/collect.c
+++ b/usr.bin/mail/collect.c
@@ -152,7 +152,7 @@ cont:
        }
        for (;;) {
                colljmp_p = 1;
-               c = readline(stdin, linebuf, LINESIZE);
+               c = readline(stdin, linebuf, sizeof(linebuf));
                colljmp_p = 0;
                if (c < 0) {
                        if (value("interactive") != NULL &&
@@ -163,7 +163,7 @@ cont:
                        break;
                }
                lastlong = longline;
-               longline = c == LINESIZE - 1;
+               longline = c == sizeof(linebuf) - 1;
                eofcount = 0;
                hadintr = 0;
                if (linebuf[0] == '.' && linebuf[1] == '\0' &&
@@ -384,11 +384,12 @@ cont:
                        (void)fflush(stdout);
                        lc = 0;
                        cc = 0;
-                       while ((rc = readline(fbuf, linebuf, LINESIZE)) >= 0) {
-                               if (rc != LINESIZE - 1)
+                       while ((rc = readline(fbuf, linebuf,
+                           sizeof(linebuf))) >= 0) {
+                               if (rc != sizeof(linebuf) - 1)
                                        lc++;
                                if ((t = putline(collf, linebuf,
-                                        rc != LINESIZE - 1)) < 0) {
+                                        rc != sizeof(linebuf) - 1)) < 0) {
                                        (void)Fclose(fbuf);
                                        goto err;
                                }
diff --git a/usr.bin/mail/lex.c b/usr.bin/mail/lex.c
index 2d86a17c13e9..1c39c876b3f1 100644
--- a/usr.bin/mail/lex.c
+++ b/usr.bin/mail/lex.c
@@ -223,7 +223,8 @@ commands(void)
                 */
                n = 0;
                for (;;) {
-                       if (readline(input, &linebuf[n], LINESIZE - n) < 0) {
+                       if (readline(input, &linebuf[n],
+                           sizeof(linebuf) - n) < 0) {
                                if (n == 0)
                                        n = -1;
                                break;
diff --git a/usr.bin/mail/util.c b/usr.bin/mail/util.c
index ce53c7108a0d..5c9a2f2f6d8e 100644
--- a/usr.bin/mail/util.c
+++ b/usr.bin/mail/util.c
@@ -135,7 +135,7 @@ hfield(const char *field, struct message *mp)
        ibuf = setinput(mp);
        if ((lc = mp->m_lines - 1) < 0)
                return (NULL);
-       if (readline(ibuf, linebuf, LINESIZE) < 0)
+       if (readline(ibuf, linebuf, sizeof(linebuf)) < 0)
                return (NULL);
        while (lc > 0) {
                if ((lc = gethfield(ibuf, linebuf, lc, &colon)) < 0)
@@ -184,7 +184,7 @@ gethfield(FILE *f, char linebuf[], int rem, char **colon)
                        ungetc(c = getc(f), f);
                        if (c != ' ' && c != '\t')
                                break;
-                       if ((c = readline(f, line2, LINESIZE)) < 0)
+                       if ((c = readline(f, line2, sizeof(line2))) < 0)
                                break;
                        rem--;
                        for (cp2 = line2; *cp2 == ' ' || *cp2 == '\t'; cp2++)
@@ -503,7 +503,7 @@ name1(struct message *mp, int reptype)
                return (cp);
        ibuf = setinput(mp);
        namebuf[0] = '\0';
-       if (readline(ibuf, linebuf, LINESIZE) < 0)
+       if (readline(ibuf, linebuf, sizeof(linebuf)) < 0)
                return (savestr(namebuf));
 newname:
        for (cp = linebuf; *cp != '\0' && *cp != ' '; cp++)
@@ -512,10 +512,10 @@ newname:
                ;
        for (cp2 = &namebuf[strlen(namebuf)];
            *cp != '\0' && *cp != ' ' && *cp != '\t' &&
-           cp2 < namebuf + LINESIZE - 1;)
+           cp2 < namebuf + sizeof(namebuf) - 1;)
                *cp2++ = *cp++;
        *cp2 = '\0';
-       if (readline(ibuf, linebuf, LINESIZE) < 0)
+       if (readline(ibuf, linebuf, sizeof(linebuf)) < 0)
                return (savestr(namebuf));
        if ((cp = strchr(linebuf, 'F')) == NULL)
                return (savestr(namebuf));

Reply via email to