Complete.Org: Mailing Lists: Archives: freeciv-dev: April 2004:
[Freeciv-Dev] (PR#8604) remove logdebug_suppress_warning
Home

[Freeciv-Dev] (PR#8604) remove logdebug_suppress_warning

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#8604) remove logdebug_suppress_warning
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 26 Apr 2004 21:49:05 -0700
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=8604 >

logdebug_suppress_warning is a hack.  This patch removes the need for it 
by making the function in log.h inline.  Under gcc (and presumably other 
good compilers) you won't get a warning for not using this function in a 
file.

This isn't guaranteed to work for all compilers, I imagine.  But where 
it doesn't work we'll also have a problem with every other inline function.

jason

Index: ai/aidata.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aidata.c,v
retrieving revision 1.22
diff -u -r1.22 aidata.c
--- ai/aidata.c 28 Jan 2004 23:08:38 -0000      1.22
+++ ai/aidata.c 27 Apr 2004 04:47:23 -0000
@@ -379,7 +379,6 @@
   if (!ferry && punit->ai.ferryboat != FERRY_WANTED) {
     struct ai_data *ai = ai_data_get(unit_owner(punit));
 
-    logdebug_suppress_warning;
     UNIT_LOG(LOG_DEBUG, punit, "want a boat.");
     ai->stats.passengers++;
     punit->ai.ferryboat = FERRY_WANTED;
Index: common/log.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/log.h,v
retrieving revision 1.21
diff -u -r1.21 log.h
--- common/log.h        1 Oct 2003 20:48:44 -0000       1.21
+++ common/log.h        27 Apr 2004 04:47:24 -0000
@@ -62,13 +62,13 @@
 void vreal_freelog(int level, const char *message, va_list ap);
 
 
+#ifdef DEBUG
 /* A static (per-file) function to use/update the above per-file vars.
  * This should only be called for LOG_DEBUG messages.
  * It returns whether such a LOG_DEBUG message should be sent on
  * to real_freelog.
  */
-#ifdef DEBUG
-static int logdebug_check(const char *file, int line)
+static inline int logdebug_check(const char *file, int line)
 {
   if (logdebug_this_init < logd_init_counter) {  
     logdebug_thisfile = logdebug_update(file);
@@ -78,13 +78,6 @@
                                      || (line >= logdebug_thisfile.min 
                                          && line <= logdebug_thisfile.max))); 
 }
-/* Including log.h without calling freelog() can generate a
-   warning that logdebug_check is never used; can use this to
-   suppress that warning:
-*/
-#define logdebug_suppress_warning logdebug_check(__FILE__, __LINE__)
-#else
-#define logdebug_suppress_warning
 #endif
 
 #ifdef DEBUG
Index: server/civserver.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/civserver.c,v
retrieving revision 1.218
diff -u -r1.218 civserver.c
--- server/civserver.c  25 Apr 2004 19:03:40 -0000      1.218
+++ server/civserver.c  27 Apr 2004 04:47:24 -0000
@@ -162,9 +162,6 @@
 
   /* Technically, we won't ever get here. We exit via server_quit. */
 
-  /* suppress warnings */
-  logdebug_suppress_warning;
-
   /* done */
   exit(EXIT_SUCCESS);
 }
Index: server/console.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/console.c,v
retrieving revision 1.22
diff -u -r1.22 console.c
--- server/console.c    5 Mar 2004 18:56:09 -0000       1.22
+++ server/console.c    27 Apr 2004 04:47:24 -0000
@@ -83,7 +83,6 @@
   bool has_file = (log_filename && strlen(log_filename) > 0);
 
   log_init(log_filename, log_level, has_file ? NULL : con_handle_log);
-  logdebug_suppress_warning;
 }
 
 #ifndef HAVE_LIBREADLINE

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#8604) remove logdebug_suppress_warning, Jason Short <=