Bug#508046: ccache warning fixes for gcc-4.3

2009-01-17 Thread Y Giridhar Appaji Nag
# Bcc: control
tags 508046 + pending
thanks

On 08/12/07 10:56 +, William S Fulton said ...
> The following patch cleans up gcc-4.3 warnings:

Thank you for the patch William.  I've committed it to Debian ccache git
as 15_gcc4.3_warnings.diff and it will be available in the next upload
to the archive.

Cheers,

Giridhar

-- 
Y Giridhar Appaji Nag | http://appaji.net/


signature.asc
Description: Digital signature


Bug#508046: ccache warning fixes for gcc-4.3

2008-12-07 Thread William S Fulton

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.0 +0100
+++ ccache-2.4/ccache.c	2008-12-07 10:28:24.0 +
@@ -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.0 +0100
+++ ccache-2.4/stats.c	2008-12-07 10:28:24.0 +
@@ -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.0 +0100
+++ ccache-2.4/util.c	2008-12-07 10:28:24.0 +
@@ -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");