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
This commit is contained in:
@@ -152,7 +152,7 @@ collect(struct header *hp, int printheaders)
|
||||
}
|
||||
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 @@ collect(struct header *hp, int printheaders)
|
||||
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 @@ collect(struct header *hp, int printheaders)
|
||||
(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;
|
||||
}
|
||||
|
||||
+2
-1
@@ -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;
|
||||
|
||||
+5
-5
@@ -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 @@ name1(struct message *mp, int reptype)
|
||||
;
|
||||
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));
|
||||
|
||||
Reference in New Issue
Block a user