Hey,

Attaching patch to fix lots of warnings building T2 on Ubuntu system.
The issue been discussed here:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25509

There's no need to apply patch as it is, maybe it's possible to find
better solution. So far this affects only Ubuntu and I didn't want to
loose this patch.
It's compiling fine without it though.
Any comments?

Cheers,
Aldas
Index: misc/tools-source/fl_stparse.c
===================================================================
--- misc/tools-source/fl_stparse.c	(revision 37127)
+++ misc/tools-source/fl_stparse.c	(working copy)
@@ -16,6 +16,7 @@
  */
 
 #define _GNU_SOURCE
+#define NOWARN_UNUSED_RETURN(x) if (x) {}
 
 #include <stdio.h>
 #include <unistd.h>
@@ -142,7 +143,7 @@
 		}
 
 		if ( sscanf(line, "%d chdir(\"%[^\"]", &pid, buf1) == 2 ) {
-			chdir( getproc(pid)->cwd ); chdir( buf1 );
+			NOWARN_UNUSED_RETURN(chdir( getproc(pid)->cwd )); NOWARN_UNUSED_RETURN(chdir( buf1 ));
 			setproc(pid, getcwd((char *) NULL, 0) );
 			continue;
 		}
Index: misc/tools-source/getfiles.c
===================================================================
--- misc/tools-source/getfiles.c	(revision 37127)
+++ misc/tools-source/getfiles.c	(working copy)
@@ -15,6 +15,8 @@
  * --- T2-COPYRIGHT-NOTE-END ---
  */
 
+#define NOWARN_UNUSED_RETURN(x) if (x) {}
+
 #include <stdio.h>
 #include <string.h>
 #include <sys/stat.h>
@@ -23,7 +25,7 @@
 int main(int argc, char ** argv) {
 	char *fn, buf[512], *n;
 	struct stat st;
-	if (argc > 1) chdir(argv[1]);
+	if (argc > 1) NOWARN_UNUSED_RETURN(chdir(argv[1]));
 	while ( fgets(buf, 512, stdin) != NULL &&
 					(fn = strchr(buf, ' ')) != NULL ) {
 		if ( (n = strchr(++fn, '\n')) != NULL ) *n = '\0';
Index: misc/tools-source/cmd_wrapper.c
===================================================================
--- misc/tools-source/cmd_wrapper.c	(revision 37127)
+++ misc/tools-source/cmd_wrapper.c	(working copy)
@@ -37,6 +37,8 @@
  *
  */
 
+#define NOWARN_UNUSED_RETURN(x) if (x) {}
+
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
@@ -373,8 +375,8 @@
 	
 		/* Create content of input file */
 		for (c3=0; c3<c1; c3++) {
-			write(infd, newargv[c3], strlen(newargv[c3]));
-			write(infd, "\n", 1);
+			NOWARN_UNUSED_RETURN(write(infd, newargv[c3], strlen(newargv[c3])));
+			NOWARN_UNUSED_RETURN(write(infd, "\n", 1));
 		}
 		lseek(infd, 0, SEEK_SET);
 	
@@ -397,7 +399,7 @@
 		  size_t argvsize = lseek(outfd, 0, SEEK_END);
 		  char* argvmem = malloc (argvsize + 1); /* might not have trailing \n */
 		  lseek(outfd, 0, SEEK_SET);
-		  read(outfd, argvmem, argvsize);
+		  NOWARN_UNUSED_RETURN(read(outfd, argvmem, argvsize));
 
 		  int newargc = 64;  /* initial newargv size */
 		  newargv = malloc( sizeof(char*) * newargc );
Index: misc/tools-source/fl_wrparse.c
===================================================================
--- misc/tools-source/fl_wrparse.c	(revision 37127)
+++ misc/tools-source/fl_wrparse.c	(working copy)
@@ -16,6 +16,7 @@
  */
 
 #define _GNU_SOURCE
+#define NOWARN_UNUSED_RETURN(x) if (x) {}
 
 #include <string.h>
 #include <stdio.h>
@@ -38,8 +39,8 @@
 		file = origname + (file-buf);
 	}
 	
-	getcwd(odir, FILENAME_MAX); chdir(buf);
-	getcwd(buf, FILENAME_MAX);  chdir(odir);
+	NOWARN_UNUSED_RETURN(getcwd(odir, FILENAME_MAX)); NOWARN_UNUSED_RETURN(chdir(buf));
+	NOWARN_UNUSED_RETURN(getcwd(buf, FILENAME_MAX));  NOWARN_UNUSED_RETURN(chdir(odir));
 
 	if (strcmp(buf, "/")) strcat(buf,"/");
 	strcat(buf, file);
@@ -97,7 +98,7 @@
 		}
 	}
 
-	if ( rootdir != NULL ) chdir(rootdir);
+	if ( rootdir != NULL ) NOWARN_UNUSED_RETURN(chdir(rootdir));
 
 	while ( fgets(buf, FILENAME_MAX, stdin) != NULL ) {
 
Index: misc/tools-source/getdu.c
===================================================================
--- misc/tools-source/getdu.c	(revision 37127)
+++ misc/tools-source/getdu.c	(working copy)
@@ -15,6 +15,8 @@
  * --- T2-COPYRIGHT-NOTE-END ---
  */
 
+#define NOWARN_UNUSED_RETURN(x) if (x) {}
+
 #include <stdio.h>
 #include <sys/stat.h>
 #include <unistd.h>
@@ -23,7 +25,7 @@
 	int size=0;
 	char fn[512];
 	struct stat st;
-	if (argc > 1) chdir(argv[1]);
+	if (argc > 1) NOWARN_UNUSED_RETURN(chdir(argv[1]));
 	while ( scanf("%*s %s",fn) == 1 ) {
 		if ( lstat(fn,&st) ) continue;
 		if ( S_ISREG(st.st_mode) ) size+=st.st_size;
Index: misc/tools-source/fl_wrapper.c.sh
===================================================================
--- misc/tools-source/fl_wrapper.c.sh	(revision 37127)
+++ misc/tools-source/fl_wrapper.c.sh	(working copy)
@@ -34,6 +34,8 @@
 
 /* Headers and prototypes */
 
+#define NOWARN_UNUSED_RETURN(x) if (x) {}
+
 #define DEBUG 0
 #define DLOPEN_LIBC 1
 #ifndef FLWRAPPER_LIBC
@@ -424,7 +426,7 @@
 	/* make sure the filename is absolute */
 	if (file[0] != '/') {
 		char cwd[PATH_MAX];
-		getcwd(cwd, PATH_MAX);
+		NOWARN_UNUSED_RETURN(getcwd(cwd, PATH_MAX));
 		snprintf(absfile, PATH_MAX, "%s/%s", cwd, file);
 		file = absfile;
 	}
@@ -510,7 +512,7 @@
     lseek(fd, 0, SEEK_END);
 
     sprintf(buf,"%s.%s:\t%s\n", cmdname, func, absfile);
-    write(fd,buf,strlen(buf));
+    NOWARN_UNUSED_RETURN(write(fd,buf,strlen(buf)));
 
 	close(fd);
 #if DEBUG == 1
----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[email protected] with a subject of: unsubscribe t2

Reply via email to