Mesa (mesa_7_6_branch): progs/demos: Silence warn_unused_result warnings.

Vinson Lee vlee at kemper.freedesktop.org
Sat Dec 26 09:09:30 UTC 2009


Module: Mesa
Branch: mesa_7_6_branch
Commit: e81fe088f447b959b354fadf0d73fcc7ac7c468d
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=e81fe088f447b959b354fadf0d73fcc7ac7c468d

Author: Vinson Lee <vlee at vmware.com>
Date:   Sat Dec 26 01:08:26 2009 -0800

progs/demos: Silence warn_unused_result warnings.

---

 progs/demos/geartrain.c |   21 ++++++++++++++++-----
 progs/demos/isosurf.c   |    8 +++++---
 progs/demos/terrain.c   |    5 ++++-
 3 files changed, 25 insertions(+), 9 deletions(-)

diff --git a/progs/demos/geartrain.c b/progs/demos/geartrain.c
index 8fe405e..e6567dd 100644
--- a/progs/demos/geartrain.c
+++ b/progs/demos/geartrain.c
@@ -25,6 +25,7 @@
  */
 
 
+#include <assert.h>
 #include <math.h>
 #include <stdlib.h>
 #include <GL/glut.h>
@@ -129,8 +130,10 @@ Clear_Buffers ()
 static void
 LoadTriplet (TDA A)
 {
+    int result;
     Clear_Buffers ();
-    fscanf (mainfile, "%s %s %s %s", Buf1, Buf2, Buf3, Buf4);
+    result = fscanf (mainfile, "%s %s %s %s", Buf1, Buf2, Buf3, Buf4);
+    assert(result != EOF);
     A[0] = atof (Buf2);
     A[1] = atof (Buf3);
     A[2] = atof (Buf4);
@@ -140,8 +143,10 @@ LoadTriplet (TDA A)
 static void
 LoadReal (float *a)
 {
+    int result;
     Clear_Buffers ();
-    fscanf (mainfile, "%s %s", Buf1, Buf2);
+    result = fscanf (mainfile, "%s %s", Buf1, Buf2);
+    assert(result != EOF);
     *a = atof (Buf2);
 }
 
@@ -149,8 +154,10 @@ LoadReal (float *a)
 static void
 LoadInteger (int *a)
 {
+    int result;
     Clear_Buffers ();
-    fscanf (mainfile, "%s %s", Buf1, Buf2);
+    result = fscanf (mainfile, "%s %s", Buf1, Buf2);
+    assert(result != EOF);
     *a = atoi (Buf2);
 }
 
@@ -158,8 +165,10 @@ LoadInteger (int *a)
 static void
 LoadText (char *a)
 {
+    int result;
     Clear_Buffers ();
-    fscanf (mainfile, "%s %s", Buf1, Buf2);
+    result = fscanf (mainfile, "%s %s", Buf1, Buf2);
+    assert(result != EOF);
     strcpy (a, Buf2);
 }
 
@@ -177,8 +186,10 @@ getdata (char filename[])
 
     do
     {
+	int result;
 	Clear_Buffers ();
-	fscanf (mainfile, "%s", Buf1);
+	result = fscanf (mainfile, "%s", Buf1);
+	(void) result;
 	if (ferror (mainfile))
 	{
 	    printf ("\nError opening file !\n");
diff --git a/progs/demos/isosurf.c b/progs/demos/isosurf.c
index 2e9dff1..dd56965 100644
--- a/progs/demos/isosurf.c
+++ b/progs/demos/isosurf.c
@@ -132,9 +132,11 @@ static void read_surface( char *filename )
 
    numverts = 0;
    while (!feof(f) && numverts<maxverts) {
-      fscanf( f, "%f %f %f  %f %f %f",
-	      &data[numverts][0], &data[numverts][1], &data[numverts][2],
-	      &data[numverts][3], &data[numverts][4], &data[numverts][5] );
+      int result;
+      result = fscanf( f, "%f %f %f  %f %f %f",
+	               &data[numverts][0], &data[numverts][1], &data[numverts][2],
+	               &data[numverts][3], &data[numverts][4], &data[numverts][5] );
+      (void) result;
       numverts++;
    }
    numverts--;
diff --git a/progs/demos/terrain.c b/progs/demos/terrain.c
index be78ea4..9ba7b61 100644
--- a/progs/demos/terrain.c
+++ b/progs/demos/terrain.c
@@ -8,6 +8,7 @@
  * based on a Mikael SkiZoWalker's (MoDEL) / France (Skizo at Hol.Fr) demo
  */
 
+#include <assert.h>
 #include <stdio.h>
 #include <math.h>
 #include <stdlib.h>
@@ -559,12 +560,14 @@ loadpic(void)
    FILE *FilePic;
    int i, tmp;
    GLenum gluerr;
+   size_t result;
 
    if ((FilePic = fopen("terrain.dat", "r")) == NULL) {
       fprintf(stderr, "Error loading terrain.dat\n");
       exit(-1);
    }
-   fread(bufferter, 256 * 256, 1, FilePic);
+   result = fread(bufferter, 256 * 256, 1, FilePic);
+   assert(result == 1);
    fclose(FilePic);
 
    for (i = 0; i < (256 * 256); i++) {




More information about the mesa-commit mailing list