[4.1] b8d70b0 Polish

Poul-Henning Kamp phk at FreeBSD.org
Fri Sep 4 15:54:50 CEST 2015


commit b8d70b078bcf403402644f69259c7f7cdb463662
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Sat Jul 11 20:19:24 2015 +0000

    Polish

diff --git a/bin/varnishtest/vtc.c b/bin/varnishtest/vtc.c
index f44d220..1309df0 100644
--- a/bin/varnishtest/vtc.c
+++ b/bin/varnishtest/vtc.c
@@ -438,8 +438,8 @@ cmd_shell(CMD_ARGS)
 	r = system(av[1]);
 	s = WEXITSTATUS(r);
 	if (s != 0)
-		vtc_log(vl, 0, "CMD '%s' failed with status %d",
-		    av[1], s);
+		vtc_log(vl, 0, "CMD '%s' failed with status %d (%s)",
+		    av[1], s, strerror(errno));
 }
 
 /**********************************************************************
@@ -635,7 +635,7 @@ exec_file(const char *fn, const char *script, const char *tmpdir,
 	FILE *f;
 	struct extmacro *m;
 
-	signal(SIGPIPE, SIG_IGN);
+	(void)signal(SIGPIPE, SIG_IGN);
 
 	vtc_loginit(logbuf, loglen);
 	vltop = vtc_logopen("top");
diff --git a/bin/varnishtest/vtc_process.c b/bin/varnishtest/vtc_process.c
index 157bfa9..fffe9bf 100644
--- a/bin/varnishtest/vtc_process.c
+++ b/bin/varnishtest/vtc_process.c
@@ -43,8 +43,6 @@
 
 #include "vtc.h"
 
-#include "vss.h"
-
 struct process {
 	unsigned		magic;
 #define PROCESS_MAGIC		0x1617b43e
@@ -225,7 +223,7 @@ process_start(struct process *p)
  */
 
 static void
-process_wait(struct process *p)
+process_wait(const struct process *p)
 {
 	void *v;
 
@@ -238,37 +236,34 @@ process_wait(struct process *p)
  */
 
 static void
-process_kill(struct process *p, const char *sig)
+process_kill(const struct process *p, const char *sig)
 {
-	int s, l;
+	int s;
 	char buf[64];
 
 	CHECK_OBJ_NOTNULL(p, PROCESS_MAGIC);
 	AN(sig);
 
-	if (!p->running || !p->pid) {
+	if (!p->running || !p->pid)
 		vtc_log(p->vl, 0, "Cannot signal a non-running process");
-		return;
-	}
 
-	vtc_log(p->vl, 4, "CMD: kill -%s %d", sig, p->pid);
+	bprintf(buf, "kill -%s %d", sig, p->pid);
+	vtc_log(p->vl, 4, "CMD: %s", buf);
 
-	l = snprintf(buf, sizeof buf, "kill -%s %d", sig, p->pid);
-	AN(l < sizeof buf);
 	s = system(buf);
 	if (s != 0)
 		vtc_log(p->vl, 0, "Failed to send signal (exit status: %d)", s);
 }
 
 static inline void
-process_stop(struct process *p)
+process_stop(const struct process *p)
 {
 
 	process_kill(p, "TERM");
 }
 
 static inline void
-process_terminate(struct process *p)
+process_terminate(const struct process *p)
 {
 
 	process_kill(p, "TERM");
@@ -282,14 +277,12 @@ process_terminate(struct process *p)
  */
 
 static void
-process_write(struct process *p, const char *text)
+process_write(const struct process *p, const char *text)
 {
 	int r, len;
 
-	if (!p->running || !p->pid) {
+	if (!p->running || !p->pid)
 		vtc_log(p->vl, 0, "Cannot write to a non-running process");
-		return;
-	}
 
 	len = strlen(text);
 	vtc_log(p->vl, 4, "Writing %d bytes", len);
@@ -303,10 +296,8 @@ static void
 process_close(struct process *p)
 {
 
-	if (!p->running || !p->pid) {
+	if (!p->running || !p->pid)
 		vtc_log(p->vl, 0, "Cannot close on a non-running process");
-		return;
-	}
 
 	AZ(close(p->fds[1]));
 	p->fds[1] = -1;



More information about the varnish-commit mailing list