r2409 - trunk/varnish-cache/lib/libvarnish

phk at projects.linpro.no phk at projects.linpro.no
Wed Jan 30 11:20:54 CET 2008


Author: phk
Date: 2008-01-30 11:20:54 +0100 (Wed, 30 Jan 2008)
New Revision: 2409

Modified:
   trunk/varnish-cache/lib/libvarnish/vpf.c
Log:
Silence FlexeLint: ignore returns, a constification and a couple of asserts.


Modified: trunk/varnish-cache/lib/libvarnish/vpf.c
===================================================================
--- trunk/varnish-cache/lib/libvarnish/vpf.c	2008-01-30 10:15:07 UTC (rev 2408)
+++ trunk/varnish-cache/lib/libvarnish/vpf.c	2008-01-30 10:20:54 UTC (rev 2409)
@@ -43,6 +43,7 @@
 #include "compat/strlcpy.h"
 #endif
 
+#include "libvarnish.h"		/* XXX: for assert() */
 #include "flopen.h"
 #include "vpf.h"
 
@@ -56,7 +57,7 @@
 static int _vpf_remove(struct pidfh *pfh, int freeit);
 
 static int
-vpf_verify(struct pidfh *pfh)
+vpf_verify(const struct pidfh *pfh)
 {
 	struct stat sb;
 
@@ -84,7 +85,7 @@
 
 	i = read(fd, buf, sizeof(buf) - 1);
 	error = errno;	/* Remember errno in case close() wants to change it. */
-	close(fd);
+	(void)close(fd);
 	if (i == -1)
 		return (error);
 	buf[i] = '\0';
@@ -113,8 +114,11 @@
 		    "/var/run/%s.pid", getprogname());
 	else
 #endif
+	{
+		assert(path != NULL);
 		len = snprintf(pfh->pf_path, sizeof(pfh->pf_path),
 		    "%s", path);
+	}
 	if (len >= (int)sizeof(pfh->pf_path)) {
 		free(pfh);
 		errno = ENAMETOOLONG;
@@ -144,8 +148,8 @@
 	 */
 	if (fstat(fd, &sb) == -1) {
 		error = errno;
-		unlink(pfh->pf_path);
-		close(fd);
+		(void)unlink(pfh->pf_path);
+		(void)close(fd);
 		free(pfh);
 		errno = error;
 		return (NULL);
@@ -182,15 +186,16 @@
 	 */
 	if (ftruncate(fd, 0) == -1) {
 		error = errno;
-		_vpf_remove(pfh, 0);
+		(void)_vpf_remove(pfh, 0);
 		errno = error;
 		return (-1);
 	}
 
-	snprintf(pidstr, sizeof(pidstr), "%u", getpid());
+	error = snprintf(pidstr, sizeof(pidstr), "%u", getpid());
+	assert(error < sizeof pidstr);
 	if (pwrite(fd, pidstr, strlen(pidstr), 0) != (ssize_t)strlen(pidstr)) {
 		error = errno;
-		_vpf_remove(pfh, 0);
+		(void)_vpf_remove(pfh, 0);
 		errno = error;
 		return (-1);
 	}




More information about the varnish-commit mailing list