www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2011/06/23/10:16:15

X-Authentication-Warning: delorie.com: mail set sender to djgpp-workers-bounces using -f
X-Recipient: djgpp-workers AT delorie DOT com
X-Authenticated: #27081556
X-Provags-ID: V01U2FsdGVkX188kMdv0108rAOi86dJNkfsXKB7ajnC6D4DZ2DnSd
rrBgSgWLGpNUml
From: Juan Manuel Guerrero <juan DOT guerrero AT gmx DOT de>
To: djgpp-workers AT delorie DOT com
Subject: Fixing some unused-but-set-variable errors.
Date: Thu, 23 Jun 2011 16:10:43 +0200
User-Agent: KMail/1.9.10
MIME-Version: 1.0
Message-Id: <201106231610.43900.juan.guerrero@gmx.de>
X-Y-GMX-Trusted: 0
Reply-To: djgpp-workers AT delorie DOT com

To fix this issue I have include sys/cdefs.h.  In that header the _ATTRIBUTE
macro is defined.  I have prefered to use the macro instead of explicitly
adding __attribute__((__unused__)) to the variable definitions or casting them
to void.  It should be noted that in sys/cdefs.h the _ATTRIBUTE macro is
defined without checking for the gcc version. I do not know if all gcc
versions that shall be able to compile DJGPP's libc support the __attribute__
functionality.  Probably some version checking needs to be done in the header.

In those files where the variables are really set but never used I have removed
them.  Every where else I have marked them as __unused__.  Please note that I
only fixed those files that stops the compiler.  There are a lot of warnings
more to be fixed.

As usual suggestions, objection, comments are welcome.


Regards,
Juan M. Guerrero



2011-06-23  Juan Manuel Guerrero  <juan DOT guerrero AT gmx DOT de>

	* src/libc/ansi/stdio/doprnt.c: Fix unused-but-set error/warning.

	* src/libc/compat/stdlib/random.c: Fix unused-but-set error/warning.

	* src/libc/fsext/fse_zero.c: Fix unused-but-set error/warning.

	* src/utils/getconf.c: Fix unused-but-set error/warning.





diff -aprNU3 djgpp.orig/src/libc/ansi/stdio/doprnt.c djgpp/src/libc/ansi/stdio/doprnt.c
--- djgpp.orig/src/libc/ansi/stdio/doprnt.c	2008-06-08 00:25:36 +0000
+++ djgpp/src/libc/ansi/stdio/doprnt.c	2011-06-23 15:16:22 +0000
@@ -1,3 +1,4 @@
+/* Copyright (C) 2011 DJ Delorie, see COPYING.DJ for details */
 /* Copyright (C) 2008 DJ Delorie, see COPYING.DJ for details */
 /* Copyright (C) 2003 DJ Delorie, see COPYING.DJ for details */
 /* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */
@@ -21,6 +22,7 @@
 #include <libc/file.h>
 #include <libc/local.h>
 #include <libc/ieee.h>
+#include <sys/cdefs.h>
 
 static char decimal_point;
 static char thousands_sep;
@@ -117,7 +119,7 @@ _doprnt(const char *fmt0, va_list argp,
   char *t;			/* buffer pointer */
   long double _ldouble;		/* double and long double precision arguments
 				   %L.[aAeEfFgG] */
-  unsigned long long _ulonglong=0; /* integer arguments %[diouxX] */
+  unsigned long long _ulonglong = 0; /* integer arguments %[diouxX] */
   int base;			/* base for [diouxX] conversion */
   int dprec;			/* decimal precision in [diouxX] */
   int fieldsz;			/* field size expanded by sign, etc */
@@ -1323,7 +1325,7 @@ __traverse_argument_list(int index_of_ar
   const char *fmt = fmt0;
   int arg_index = 0, prec_index = 0, list_index;
   int ch, flags, n = index_of_arg_to_be_fetched + 1;
-  unsigned long long _ulonglong;  /* discard value retrieved by ARG() */
+  unsigned long long _ulonglong _ATTRIBUTE(__unused__);  /* discard value retrieved by ARG() */
 
 
   for (list_index = 1; list_index < n;)
diff -aprNU3 djgpp.orig/src/libc/compat/stdlib/random.c djgpp/src/libc/compat/stdlib/random.c
--- djgpp.orig/src/libc/compat/stdlib/random.c	2007-12-11 07:27:38 +0000
+++ djgpp/src/libc/compat/stdlib/random.c	2011-06-23 15:25:42 +0000
@@ -1,3 +1,4 @@
+/* Copyright (C) 2011 DJ Delorie, see COPYING.DJ for details */
 /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
 /* This is file RANDOM.C */
 /* This file may have been modified by DJ Delorie (Jan 1995).  If so,
@@ -178,7 +179,7 @@ static  long		*end_ptr		= (long*) &randt
 int
 srandom(int x)
 {
-  int i, j;
+  int i;
 
   if (rand_type == TYPE_0)
   {
@@ -186,7 +187,6 @@ srandom(int x)
   }
   else
   {
-    j = 1;
     state[ 0 ] = x;
     for (i = 1; i < rand_deg; i++)
     {
diff -aprNU3 djgpp.orig/src/libc/fsext/fse_zero.c djgpp/src/libc/fsext/fse_zero.c
--- djgpp.orig/src/libc/fsext/fse_zero.c	2003-03-08 00:43:18 +0000
+++ djgpp/src/libc/fsext/fse_zero.c	2011-06-23 15:36:32 +0000
@@ -1,3 +1,4 @@
+/* Copyright (C) 2011 DJ Delorie, see COPYING.DJ for details */
 /* Copyright (C) 2003 DJ Delorie, see COPYING.DJ for details */
 /* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */
 /* Copyright (C) 2001 DJ Delorie, see COPYING.DJ for details */
@@ -20,6 +21,7 @@
 #include <sys/stat.h>
 #include <sys/fsext.h>
 #include <sys/xdevices.h>
+#include <sys/cdefs.h>
 
 static const char DEV_ZERO_PATH[] = "/dev/zero";
 static const char DEV_FULL_PATH[] = "/dev/full";
@@ -177,26 +179,26 @@ match_dev_path (const char *filename, co
 static int
 dev_fsext (__FSEXT_Fnumber n, int *rv, va_list args)
 {
-  int          emul         = 0; /* Emulated call? 1 => yes, 0 = no. */
-  int          fd           = 0;
-  DEV_DATA    *data         = NULL;
-  char        *filename     = NULL;
-  char        *new_filename = NULL;
-  int          open_mode    = 0;
-  int          perm         = 0;
-  mode_t       mode         = 0;
-  void        *buf          = NULL;
-  size_t       buflen       = 0;
-  off_t        offset       = 0;
-  offset_t     lloffset     = 0;
-  uid_t        owner        = 0;
-  gid_t        group        = 0;
-  int          whence       = 0;
-  struct stat *sbuf         = NULL;
-  int          cmd          = 0;
-  int          iparam       = 0;
+  int          emul                            = 0; /* Emulated call? 1 => yes, 0 = no. */
+  int          fd                              = 0;
+  DEV_DATA    *data                            = NULL;
+  char        *filename                        = NULL;
+  char        *new_filename                    = NULL;
+  int          open_mode                       = 0;
+  int          perm     _ATTRIBUTE(__unused__) = 0;
+  mode_t       mode     _ATTRIBUTE(__unused__) = 0;
+  void        *buf                             = NULL;
+  size_t       buflen                          = 0;
+  off_t        offset   _ATTRIBUTE(__unused__) = 0;
+  offset_t     lloffset _ATTRIBUTE(__unused__) = 0;
+  uid_t        owner    _ATTRIBUTE(__unused__) = 0;
+  gid_t        group    _ATTRIBUTE(__unused__) = 0;
+  int          whence   _ATTRIBUTE(__unused__) = 0;
+  struct stat *sbuf                            = NULL;
+  int          cmd                             = 0;
+  int          iparam                          = 0;
 #ifdef DJGPP_SUPPORTS_FIONBIO_NOW
-  int         *piparam      = NULL;
+  int         *piparam                         = NULL;
 #endif /* DJGPP_SUPPORTS_FIONBIO_NOW */
 
   switch(n) {
diff -aprNU3 djgpp.orig/src/utils/getconf.c djgpp/src/utils/getconf.c
--- djgpp.orig/src/utils/getconf.c	2001-07-13 08:41:06 +0000
+++ djgpp/src/utils/getconf.c	2011-06-23 15:44:58 +0000
@@ -1,3 +1,4 @@
+/* Copyright (C) 2011 DJ Delorie, see COPYING.DJ for details */
 /* Copyright (C) 2001 DJ Delorie, see COPYING.DJ for details */
 
 #include <unistd.h>
@@ -6,6 +7,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <errno.h>
+#include <sys/cdefs.h>
 
 #define constant_var 0
 #define confstr_var  1
@@ -154,7 +156,7 @@ int main(int argc, char *argv[])
 
     case confstr_var:
     {
-      size_t buf_len, ret;
+      size_t buf_len, ret _ATTRIBUTE(__unused__);
       char *buf;
 
       buf_len = confstr(var->value, 0, 0);

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019