[Pkg-wmaker-commits] [wmcube] 38/67: debian/patches: (fix_-Wunused-result.patch) Fix compiler warnings.

Doug Torrance dtorrance-guest at moszumanska.debian.org
Tue Aug 25 03:22:17 UTC 2015


This is an automated email from the git hooks/post-receive script.

dtorrance-guest pushed a commit to branch master
in repository wmcube.

commit da7af4baafb336f169719564058f85a052ed7bb5
Author: Doug Torrance <dtorrance at monmouthcollege.edu>
Date:   Tue Jan 13 17:22:33 2015 -0600

    debian/patches: (fix_-Wunused-result.patch) Fix compiler warnings.
---
 debian/patches/fix_-Wunused-result.patch | 86 ++++++++++++++++++++++++++++++++
 debian/patches/series                    |  1 +
 2 files changed, 87 insertions(+)

diff --git a/debian/patches/fix_-Wunused-result.patch b/debian/patches/fix_-Wunused-result.patch
new file mode 100644
index 0000000..5dde6e6
--- /dev/null
+++ b/debian/patches/fix_-Wunused-result.patch
@@ -0,0 +1,86 @@
+Description: Fix -Wunused-result compiler warnings.
+ Also add a space at the end of the format reading line and plane coordinates.
+ Otherwise, we get a false positive in object files ending in a newline.
+Author: Doug Torrance <dtorrance at monmouthcollege.edu>
+Last-Update: 2015-01-13
+
+--- a/wmcube/wmcube.c
++++ b/wmcube/wmcube.c
+@@ -992,7 +992,8 @@
+ 		exit(0);
+ 	}
+ 
+-	fscanf(fp,"%s",tmp);
++	if (fscanf(fp,"%s",tmp) < 1)
++		printf("WARNING: Could not read first line of object-file (%s).\n",filename);
+ 	
+ 	if (strcmp(tmp,"WMCUBE_COORDINATES") != 0) {
+ 		printf("\nError in objectfile: it must start with WMCUBE_COORDINATES\n\n");
+@@ -1000,13 +1001,15 @@
+ 		exit(0);
+ 	}
+ 
+-	fscanf(fp,"%s",tmp);
++	if (fscanf(fp,"%s",tmp) < 1)
++		printf("WARNING: Could not read second line of object-file (%s).\n",filename);
+ 
+ 	while ((strcmp(tmp,"WMCUBE_LINES") != 0) && (strcmp(tmp,"WMCUBE_PLANES") != 0)) {		
+ 
+ 	 	matrix = (float **)realloc(matrix,(i+1)*sizeof(float *)); mem_alloc_error(matrix);
+ 		matrix[i] = (float *)malloc(3*sizeof(float)); mem_alloc_error(matrix[i]);
+-		fscanf(fp,"%f %f %f",&matrix[i][0],&matrix[i][1],&matrix[i][2]);
++		if (fscanf(fp,"%f %f %f",&matrix[i][0],&matrix[i][1],&matrix[i][2]) < 3 )
++			printf("WARNING: Could not read coordinates in object-file (%s).\n",filename);
+ 		//printf("\n%d: %f %f %f",atoi(tmp), matrix[i][0],matrix[i][1],matrix[i][2]);
+ 
+ 		if (atoi(tmp) != (++i)) { 
+@@ -1016,7 +1019,8 @@
+ 			fclose(fp);
+ 			exit(0);
+ 		}
+-		fscanf(fp,"%s",tmp);
++		if (fscanf(fp,"%s",tmp) < 1)
++			printf("WARNING: Could not read next line of object-file (%s).\n",filename);
+ 
+ 		if (feof(fp)) {
+ 			printf("\nError in objectfile: you must have a section WMCUBE_LINES or WMCUBE_PLANES\n\n");
+@@ -1034,7 +1038,8 @@
+ 		while (1) {
+ 		
+ 			cline = (int *)realloc(cline,(i+2)*sizeof(int)); mem_alloc_error(cline);
+-			fscanf(fp,"%d %d",&cline[i],&cline[i+1]);
++			if (fscanf(fp,"%d %d ",&cline[i],&cline[i+1]) < 2)
++				printf("WARNING: Could not read line coordinates in object-file (%s).\n",filename);
+ 			i += 2;
+ 			//printf("\n%d %d",cline[i-2],cline[i-1]);
+ 			if (feof(fp)) break;
+@@ -1054,7 +1059,8 @@
+ 		while (1) {	
+ 			planes = (int **)realloc(planes,(i+1)*sizeof(int *)); mem_alloc_error(planes);
+ 			planes[i] = (int *)malloc(3*sizeof(int)); mem_alloc_error(planes[i]);
+-			fscanf(fp,"%d %d %d",&planes[i][0],&planes[i][1],&planes[i][2]);
++			if (fscanf(fp,"%d %d %d ",&planes[i][0],&planes[i][1],&planes[i][2]) < 3)
++				printf("WARNING: Could not read plane coordinates in object-file (%s).\n",filename);
+ 			//printf("\n%d: %d %d %d",i,planes[i][0],planes[i][1],planes[i][2]);
+ 
+ 			planes[i][0]--; planes[i][1]--; planes[i][2]--;
+@@ -1131,7 +1137,8 @@
+ 		return 0;
+ 
+ 	for (i = -2; i < which_cpu; i++) {
+-		fscanf(fp, "%5s %31s %31s %31s %31s %31s %31s %31s %31s", cpuid, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp);
++		if (fscanf(fp, "%5s %31s %31s %31s %31s %31s %31s %31s %31s", cpuid, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp) < 1)
++			fprintf(stderr, "WARNING: could not read cpuid from /proc/stat\n");
+         }
+ 
+ 	if (strcmp(check_cpu,cpuid) != 0) {
+@@ -1154,7 +1161,8 @@
+ 	fp = fopen("/proc/stat","rt");
+ 
+ 	for (i = -2; i < which_cpu; i++) {
+-		fscanf(fp,"%5s %u %u %u %u %31s %31s %31s %31s", cpuid, &cpu, &nice, &system, &idle, tmp, tmp, tmp, tmp);
++		if (fscanf(fp,"%5s %u %u %u %u %31s %31s %31s %31s", cpuid, &cpu, &nice, &system, &idle, tmp, tmp, tmp, tmp) < 5)
++			fprintf(stderr, "WARNING: could not read statistics from /proc/stat\n");
+ 	}
+ 
+ 	fclose(fp);
diff --git a/debian/patches/series b/debian/patches/series
index 90f7a36..8d38ace 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,3 +1,4 @@
 30_bts-386850_fix_smp.patch
 40_bts-357072_long_uptime_fix.patch
 update_makefile.patch
+fix_-Wunused-result.patch

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-wmaker/wmcube.git



More information about the Pkg-wmaker-commits mailing list