Re: ftpd(8): remove useless parameter of get_line()

2021-05-17 Thread Chris Cappuccio
Jan Klemkow [j.klem...@wemelug.de] wrote:
> Hi,
> 
> This diff removes the useless FILE* parameter of get_line().  In every
> call this parameter is always "stdin".  Thus, we can replace ever use of
> the variable iop with stdin.
> 
> Like every other diff, I tested this diff with the ftpd regression
> tests.
> 
> OK?
> 

looks fine to me



ftpd(8): remove useless parameter of get_line()

2021-05-16 Thread Jan Klemkow
Hi,

This diff removes the useless FILE* parameter of get_line().  In every
call this parameter is always "stdin".  Thus, we can replace ever use of
the variable iop with stdin.

Like every other diff, I tested this diff with the ftpd regression
tests.

OK?

bye,
Jan

Index: extern.h
===
RCS file: /cvs/src/libexec/ftpd/extern.h,v
retrieving revision 1.21
diff -u -p -r1.21 extern.h
--- extern.h15 Jan 2020 22:06:59 -  1.21
+++ extern.h16 May 2021 15:36:27 -
@@ -69,7 +69,7 @@ void  dologout(int);
 void   fatal(char *);
 intftpd_pclose(FILE *, pid_t);
 FILE   *ftpd_ls(const char *, pid_t *);
-int get_line(char *, int, FILE *);
+int get_line(char *, int);
 void   ftpdlogwtmp(char *, char *, char *);
 void   lreply(int, const char *, ...);
 void   makedir(char *);
Index: ftpcmd.y
===
RCS file: /cvs/src/libexec/ftpd/ftpcmd.y,v
retrieving revision 1.69
diff -u -p -r1.69 ftpcmd.y
--- ftpcmd.y4 Mar 2020 20:17:48 -   1.69
+++ ftpcmd.y16 May 2021 15:38:07 -
@@ -1089,10 +1089,9 @@ lookup(p, cmd)
  * get_line - a hacked up version of fgets to ignore TELNET escape codes.
  */
 int
-get_line(s, n, iop)
+get_line(s, n)
char *s;
int n;
-   FILE *iop;
 {
int c;
char *cs;
@@ -,21 +1110,21 @@ get_line(s, n, iop)
if (c == 0)
tmpline[0] = '\0';
}
-   while ((c = getc(iop)) != EOF) {
+   while ((c = getc(stdin)) != EOF) {
c &= 0377;
if (c == IAC) {
-   if ((c = getc(iop)) != EOF) {
+   if ((c = getc(stdin)) != EOF) {
c &= 0377;
switch (c) {
case WILL:
case WONT:
-   c = getc(iop);
+   c = getc(stdin);
printf("%c%c%c", IAC, DONT, 0377);
(void) fflush(stdout);
continue;
case DO:
case DONT:
-   c = getc(iop);
+   c = getc(stdin);
printf("%c%c%c", IAC, WONT, 0377);
(void) fflush(stdout);
continue;
@@ -1144,7 +1143,7 @@ get_line(s, n, iop)
 * This prevents the command to be split up into
 * multiple commands.
 */
-   while (c != '\n' && (c = getc(iop)) != EOF)
+   while (c != '\n' && (c = getc(stdin)) != EOF)
;
return (-2);
}
@@ -1204,7 +1203,7 @@ yylex()
 
case CMD:
(void) alarm((unsigned) timeout);
-   n = get_line(cbuf, sizeof(cbuf)-1, stdin);
+   n = get_line(cbuf, sizeof(cbuf)-1);
if (n == -1) {
reply(221, "You could at least say goodbye.");
dologout(0);
Index: ftpd.c
===
RCS file: /cvs/src/libexec/ftpd/ftpd.c,v
retrieving revision 1.229
diff -u -p -r1.229 ftpd.c
--- ftpd.c  15 Jan 2020 22:06:59 -  1.229
+++ ftpd.c  16 May 2021 15:44:17 -
@@ -2179,7 +2179,7 @@ myoob(void)
if (!transflag)
return;
cp = tmpline;
-   ret = get_line(cp, sizeof(tmpline)-1, stdin);
+   ret = get_line(cp, sizeof(tmpline)-1);
if (ret == -1) {
reply(221, "You could at least say goodbye.");
dologout(0);