[PATCH 10/16] scp: Simplify code now that the user name is never `NULL'

Michael Witten mfwitten at gmail.com
Tue Dec 8 06:59:12 AWST 2015


Date: Fri, 6 Nov 2015 23:13:25 -0000
The variables with the name `remuser' cannot hold the value `NULL'; this commit
removes the code that handles that case.
---
 scp.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/scp.c b/scp.c
index a19d28f..0adb590 100644
--- a/scp.c
+++ b/scp.c
@@ -175,10 +175,8 @@ static void
 arg_setup(char *host, const char *remuser, char *cmd)
 {
 	replacearg(&args, 0, "%s", ssh_program);
-	if (remuser != NULL) {
-		addargs(&args, "-l");
-		addargs(&args, "%s", remuser);
-	}
+	addargs(&args, "-l");
+	addargs(&args, "%s", remuser);
 	addargs(&args, "%s", host);
 	addargs(&args, "%s", cmd);
 }
@@ -192,7 +190,7 @@ do_cmd(char *host, const char *remuser, char *cmd, int *fdin, int *fdout, int ar
 		fprintf(stderr,
 		    "Executing: program %s, host %s, user %s, command %s\n",
 		    ssh_program, host,
-		    remuser ? remuser : "(unspecified)", cmd);
+		    remuser, cmd);
 
 	/*
 	 * Reserve two descriptors so that the real pipes won't get
@@ -258,11 +256,9 @@ do_cmd(char *host, const char *remuser, char *cmd, int *fdin, int *fdout, int ar
 	args.list[args.num-1]=NULL;
 	args.num--;
 	/* pop user */
-	if (remuser != NULL) {
-		xfree(args.list[args.num-1]);
-		args.list[args.num-1]=NULL;
-		args.num--;
-	}
+	xfree(args.list[args.num-1]);
+	args.list[args.num-1]=NULL;
+	args.num--;
 #endif
 
 	/* Parent.  Close the other side, and return the local side. */
-- 
2.4.3



More information about the Dropbear mailing list