Package: ccache
Version: 2.4-15

The following patch cleans up gcc-4.3 warnings:

$ make -s
ccache.c: In function ‘tmp_string’:
ccache.c:146: warning: ignoring return value of ‘asprintf’, declared with attribute warn_unused_result
util.c: In function ‘x_asprintf’:
util.c:151: warning: ignoring return value of ‘vasprintf’, declared with attribute warn_unused_result
stats.c: In function ‘write_stats’:
stats.c:94: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result


diff -Naur ccache-2.4-orig/ccache.c ccache-2.4/ccache.c
--- ccache-2.4-orig/ccache.c	2004-09-13 11:38:30.000000000 +0100
+++ ccache-2.4/ccache.c	2008-12-07 10:28:24.000000000 +0000
@@ -143,7 +143,9 @@
 		gethostname(hostname, sizeof(hostname)-1);
 #endif
 		hostname[sizeof(hostname)-1] = 0;
-		asprintf(&ret, "%s.%u", hostname, (unsigned)getpid());
+		if (asprintf(&ret, "%s.%u", hostname, (unsigned)getpid()) == -1) {
+			fatal("could not allocate tmp_string");
+		}
 	}
 
 	return ret;
diff -Naur ccache-2.4-orig/stats.c ccache-2.4/stats.c
--- ccache-2.4-orig/stats.c	2004-09-13 11:38:30.000000000 +0100
+++ ccache-2.4/stats.c	2008-12-07 10:28:24.000000000 +0000
@@ -91,7 +91,7 @@
 	if (len >= (int)sizeof(buf)-1) fatal("stats too long?!");
 
 	lseek(fd, 0, SEEK_SET);
-	write(fd, buf, len);
+	if (write(fd, buf, len) == -1) fatal("could not write stats");
 }
 
 
diff -Naur ccache-2.4-orig/util.c ccache-2.4/util.c
--- ccache-2.4-orig/util.c	2004-09-13 11:38:30.000000000 +0100
+++ ccache-2.4/util.c	2008-12-07 10:28:24.000000000 +0000
@@ -148,7 +148,9 @@
 
 	*ptr = NULL;
 	va_start(ap, format);
-	vasprintf(ptr, format, ap);
+	if (vasprintf(ptr, format, ap) == -1) {
+		fatal("out of memory in x_asprintf");
+	}
 	va_end(ap);
 	
 	if (!ptr) fatal("out of memory in x_asprintf");

Reply via email to