patch: unused variables

Werner Almesberger almesber@lrc.epfl.ch
Wed Aug 23 00:27:00 GMT 2000


Here's a patch that eliminates a few unused variable warnings.

Some of my changes are of the controversial type
#ifdef SOMETHING
int foo;
#endif

An alternative would be to define a macro __UNUSED or such that becomes 
__attribute__((unused)) with GCC, nothing with other compilers, leave 
the variables in, and flag them with __UNUSED. Probably overkill, but 
if somebody really hates those mini-ifdefs, I'll make a patch with
__UNUSED.

- Werner

---------------------------------- ChangeLog ----------------------------------

2000-08-23  Werner Almesberger  <Werner.Almesberger@epfl.ch>
	* libc/stdio/stdio.c (__swrite): declare "oldmode" only if it's
	used later (ifdef __SCLE)
	* libc/stdio/vfscanf.c (__svfscanf): declare "state" only if it's
	used later (ifdef MB_CAPABLE)
	* libc/string/memset.c (memset): removed unused variables "count"
	and "unaligned_addr"
	* libc/locale/locale.c (_setlocale_r): declare "lc_ctype" and
	"last_lc_ctype" only of they're used later (ifdef MB_CAPABLE)
	* libc/unix/getpwent.c (getpwnam): removed unused variables "uid"
	and "gid"

------------------------------------ patch ------------------------------------

--- orig/newlib/libc/stdio/stdio.c	Wed May 24 01:51:54 2000
+++ src/newlib/libc/stdio/stdio.c	Wed Aug 23 09:00:17 2000
@@ -66,7 +66,10 @@
      int n;
 {
   register FILE *fp = (FILE *) cookie;
-  int w, oldmode=0;
+  int w;
+#ifdef __SCLE
+  int oldmode=0;
+#endif
 
   if (fp->_flags & __SAPP)
     (void) _lseek_r (fp->_data, fp->_file, (off_t) 0, SEEK_END);
--- orig/newlib/libc/stdio/vfscanf.c	Mon Apr 17 19:10:16 2000
+++ src/newlib/libc/stdio/vfscanf.c	Wed Aug 23 09:01:13 2000
@@ -116,7 +116,9 @@
   char ccltab[256];		/* character class table for %[...] */
   char buf[BUF];		/* buffer for numeric conversions */
   char *lptr;                   /* literal pointer */
+#ifdef MB_CAPABLE
   int state = 0;                /* value to keep track of multibyte state */
+#endif
 
   short *sp;
   int *ip;
--- orig/newlib/libc/string/memset.c	Thu Feb 17 20:39:48 2000
+++ src/newlib/libc/string/memset.c	Wed Aug 23 09:01:52 2000
@@ -56,10 +56,9 @@
   return m;
 #else
   char *s = (char *) m;
-  int count, i;
+  int i;
   unsigned long buffer;
   unsigned long *aligned_addr;
-  unsigned char *unaligned_addr;
 
   if (!TOO_SMALL (n) && !UNALIGNED (m))
     {
--- orig/newlib/libc/locale/locale.c	Thu Feb 17 20:39:46 2000
+++ src/newlib/libc/locale/locale.c	Wed Aug 23 09:02:34 2000
@@ -110,9 +110,6 @@
        int category _AND
        _CONST char *locale)
 {
-  static char lc_ctype[8] = "C";
-  static char last_lc_ctype[8] = "C";
-
 #ifndef MB_CAPABLE
   if (locale)
     { 
@@ -123,6 +120,9 @@
     }
   return "C";
 #else
+  static char lc_ctype[8] = "C";
+  static char last_lc_ctype[8] = "C";
+
   if (locale)
     {
       if (category != LC_CTYPE) 
--- orig/newlib/libc/unix/getpwent.c	Thu Feb 17 20:39:51 2000
+++ src/newlib/libc/unix/getpwent.c	Wed Aug 23 09:05:22 2000
@@ -22,7 +22,6 @@
      const char *name;
 {
   FILE *fp;
-  int uid, gid;
   char buf[1024];
 
   if ((fp = fopen ("/etc/passwd", "r")) == NULL)

-- 
  _________________________________________________________________________
 / Werner Almesberger, ICA, EPFL, CH       werner.almesberger@ica.epfl.ch /
/_IN_N_032__Tel_+41_21_693_6621__Fax_+41_21_693_6610_____________________/


More information about the Newlib mailing list