Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/ftp ftp: remove unnecessary variable assignments



details:   https://anonhg.NetBSD.org/src/rev/f2ea1646faff
branches:  trunk
changeset: 1023128:f2ea1646faff
user:      lukem <lukem%NetBSD.org@localhost>
date:      Thu Aug 26 06:23:24 2021 +0000

description:
ftp: remove unnecessary variable assignments

Remove assignment to error in initconn(); it's not tested anywhere after the
initial use, so no need to set it before goto bad.

(Looks like copypasta from the initial addition of the code in rev 1.48.)

diffstat:

 usr.bin/ftp/ftp.c |  21 ++++-----------------
 1 files changed, 4 insertions(+), 17 deletions(-)

diffs (118 lines):

diff -r 2b738e5bac3c -r f2ea1646faff usr.bin/ftp/ftp.c
--- a/usr.bin/ftp/ftp.c Thu Aug 26 06:16:29 2021 +0000
+++ b/usr.bin/ftp/ftp.c Thu Aug 26 06:23:24 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ftp.c,v 1.173 2021/08/26 06:16:29 lukem Exp $  */
+/*     $NetBSD: ftp.c,v 1.174 2021/08/26 06:23:24 lukem Exp $  */
 
 /*-
  * Copyright (c) 1996-2021 The NetBSD Foundation, Inc.
@@ -92,7 +92,7 @@
 #if 0
 static char sccsid[] = "@(#)ftp.c      8.6 (Berkeley) 10/27/94";
 #else
-__RCSID("$NetBSD: ftp.c,v 1.173 2021/08/26 06:16:29 lukem Exp $");
+__RCSID("$NetBSD: ftp.c,v 1.174 2021/08/26 06:23:24 lukem Exp $");
 #endif
 #endif /* not lint */
 
@@ -1381,13 +1381,11 @@
                        if (data_addr.su_family != AF_INET) {
                                fputs(
     "Passive mode AF mismatch. Shouldn't happen!\n", ttyout);
-                               error = 1;
                                goto bad;
                        }
                        if (code / 10 == 22 && code != 227) {
                                fputs("wrong server: return code must be 227\n",
                                        ttyout);
-                               error = 1;
                                goto bad;
                        }
                        error = sscanf(pasv, "%u,%u,%u,%u,%u,%u",
@@ -1396,10 +1394,8 @@
                        if (error != 6) {
                                fputs(
 "Passive mode address scan failure. Shouldn't happen!\n", ttyout);
-                               error = 1;
                                goto bad;
                        }
-                       error = 0;
                        memset(&data_addr, 0, sizeof(data_addr));
                        data_addr.su_family = AF_INET;
                        data_addr.su_len = sizeof(struct sockaddr_in);
@@ -1416,7 +1412,6 @@
                        if (code / 10 == 22 && code != 228) {
                                fputs("wrong server: return code must be 228\n",
                                        ttyout);
-                               error = 1;
                                goto bad;
                        }
                        switch (data_addr.su_family) {
@@ -1429,17 +1424,14 @@
                                if (error != 9) {
                                        fputs(
 "Passive mode address scan failure. Shouldn't happen!\n", ttyout);
-                                       error = 1;
                                        goto bad;
                                }
                                if (af != 4 || hal != 4 || pal != 2) {
                                        fputs(
 "Passive mode AF mismatch. Shouldn't happen!\n", ttyout);
-                                       error = 1;
                                        goto bad;
                                }
 
-                               error = 0;
                                memset(&data_addr, 0, sizeof(data_addr));
                                data_addr.su_family = AF_INET;
                                data_addr.su_len = sizeof(struct sockaddr_in);
@@ -1467,17 +1459,14 @@
                                if (error != 21) {
                                        fputs(
 "Passive mode address scan failure. Shouldn't happen!\n", ttyout);
-                                       error = 1;
                                        goto bad;
                                }
                                if (af != 6 || hal != 16 || pal != 2) {
                                        fputs(
 "Passive mode AF mismatch. Shouldn't happen!\n", ttyout);
-                                       error = 1;
                                        goto bad;
                                }
 
-                               error = 0;
                                memset(&data_addr, 0, sizeof(data_addr));
                                data_addr.su_family = AF_INET6;
                                data_addr.su_len = sizeof(struct sockaddr_in6);
@@ -1500,7 +1489,8 @@
                                break;
 #endif
                        default:
-                               error = 1;
+                               fputs("Unknown passive mode AF.\n", ttyout);
+                               goto bad;
                        }
                } else if (strcmp(pasvcmd, "EPSV") == 0) {
                        char delim[4];
@@ -1509,20 +1499,17 @@
                        if (code / 10 == 22 && code != 229) {
                                fputs("wrong server: return code must be 229\n",
                                        ttyout);
-                               error = 1;
                                goto bad;
                        }
                        if (sscanf(pasv, "%c%c%c%d%c", &delim[0],
                                        &delim[1], &delim[2], &port[1],
                                        &delim[3]) != 5) {
                                fputs("parse error!\n", ttyout);
-                               error = 1;
                                goto bad;
                        }
                        if (delim[0] != delim[1] || delim[0] != delim[2]
                         || delim[0] != delim[3]) {
                                fputs("parse error!\n", ttyout);
-                               error = 1;
                                goto bad;
                        }
                        data_addr = hisctladdr;



Home | Main Index | Thread Index | Old Index