arrfab / rpms / glibc

Forked from rpms/glibc 5 years ago
Clone

Blame SOURCES/glibc-rh1505492-unused-13.patch

147e83
commit 49051f8ea4551229fa656eba04031af51a5491c5
147e83
Author: Joseph Myers <joseph@codesourcery.com>
147e83
Date:   Thu Nov 27 16:01:04 2014 +0000
147e83
147e83
    Fix libio/bug-ungetwc1.c warning.
147e83
    
147e83
    This patch fixes a warning "variable 'wc' set but not used" in
147e83
    libio/bug-ungetwc1.c.
147e83
    
147e83
    The test didn't verify much about the results of the functions it
147e83
    called.  This patch makes it check the result of getwc (thereby fixing
147e83
    the warning), check end of file does not arrive too late in the getwc
147e83
    loop, and check EOF is no longer set after ungetwc.
147e83
    
147e83
    Tested for x86_64.
147e83
    
147e83
            * libio/bug-ungetwc1.c (do_test): Verify results of getwc and
147e83
            feof.
147e83
147e83
diff --git a/libio/bug-ungetwc1.c b/libio/bug-ungetwc1.c
147e83
index 8ed6acd175e86858..56a3d336ae89d69f 100644
147e83
--- a/libio/bug-ungetwc1.c
147e83
+++ b/libio/bug-ungetwc1.c
147e83
@@ -53,8 +53,22 @@ do_test (void)
147e83
   /* Read from the file. */
147e83
   fp = fopen (fname, "r");
147e83
 
147e83
+  size_t i = 0;
147e83
   while (!feof (fp))
147e83
-    wc = getwc (fp);
147e83
+    {
147e83
+      wc = getwc (fp);
147e83
+      if (i >= sizeof (write_chars))
147e83
+	{
147e83
+	  printf ("Did not get end-of-file when expected.\n");
147e83
+	  return 1;
147e83
+	}
147e83
+      else if (wc != (write_chars[i] ? write_chars[i] : WEOF))
147e83
+	{
147e83
+	  printf ("Unexpected %lu from getwc.\n", (unsigned long int) wc);
147e83
+	  return 1;
147e83
+	}
147e83
+      i++;
147e83
+    }
147e83
   printf ("\nThe end-of-file indicator is set.\n");
147e83
 
147e83
   /* Unget a wide character. */
147e83
@@ -63,7 +77,10 @@ do_test (void)
147e83
 
147e83
   /* Check the end-of-file indicator. */
147e83
   if (feof (fp))
147e83
-    printf ("The end-of-file indicator is still set.\n");
147e83
+    {
147e83
+      printf ("The end-of-file indicator is still set.\n");
147e83
+      return 1;
147e83
+    }
147e83
   else
147e83
     printf ("The end-of-file flag is cleared.\n");
147e83