r3076 - trunk/varnish-cache/bin/varnishtest

phk at projects.linpro.no phk at projects.linpro.no
Mon Aug 11 10:31:08 CEST 2008


Author: phk
Date: 2008-08-11 10:31:08 +0200 (Mon, 11 Aug 2008)
New Revision: 3076

Modified:
   trunk/varnish-cache/bin/varnishtest/vtc.c
   trunk/varnish-cache/bin/varnishtest/vtc_log.c
Log:
Eliminate <err.h> usage.

Inspired by:	Solaris patch from Theo Schlossnagle



Modified: trunk/varnish-cache/bin/varnishtest/vtc.c
===================================================================
--- trunk/varnish-cache/bin/varnishtest/vtc.c	2008-08-11 08:21:41 UTC (rev 3075)
+++ trunk/varnish-cache/bin/varnishtest/vtc.c	2008-08-11 08:31:08 UTC (rev 3076)
@@ -32,7 +32,6 @@
 #include <fcntl.h>
 #include <stdlib.h>
 #include <unistd.h>
-#include <err.h>
 
 #include "libvarnish.h"
 #include "vsb.h"
@@ -57,13 +56,17 @@
 	int fd;
 
 	fd = open(fn, O_RDONLY);
-	if (fd < 0)
-		err(1, "Cannot open %s", fn);
+	if (fd < 0) {
+		fprintf(stderr, "Cannot open %s: %s", fn, strerror(errno));
+		exit (1);
+	}
 	buf = malloc(sz);
 	assert(buf != NULL);
 	s = read(fd, buf, sz - 1);
-	if (s <= 0) 
-		err(1, "Cannot read %s", fn);
+	if (s <= 0) {
+		fprintf(stderr, "Cannot read %s: %s", fn, strerror(errno));
+		exit (1);
+	}
 	AZ(close (fd));
 	assert(s < sz);		/* XXX: increase MAX_FILESIZE */
 	buf[s] = '\0';
@@ -175,7 +178,8 @@
 			for (tn = 0; token_s[tn] != NULL; tn++)
 				fprintf(stderr, "%s ", token_s[tn]);
 			fprintf(stderr, "\n");
-			errx(1, "Unknown command: \"%s\"", token_s[0]);
+			fprintf(stderr, "Unknown command: \"%s\"", token_s[0]);
+			exit (1);
 		}
 	
 		assert(cp->cmd != NULL);

Modified: trunk/varnish-cache/bin/varnishtest/vtc_log.c
===================================================================
--- trunk/varnish-cache/bin/varnishtest/vtc_log.c	2008-08-11 08:21:41 UTC (rev 3075)
+++ trunk/varnish-cache/bin/varnishtest/vtc_log.c	2008-08-11 08:31:08 UTC (rev 3076)
@@ -32,7 +32,6 @@
 #include <fcntl.h>
 #include <stdlib.h>
 #include <unistd.h>
-#include <err.h>
 #include <pthread.h>
 #include <stdarg.h>
 




More information about the varnish-commit mailing list