[Olsr-dev] [PATCH v1 08/12] Makefile: WARNINGS: add -Wundef

Ferry Huberts (spam-protected)
Tue May 29 15:59:37 CEST 2012


From: Ferry Huberts <(spam-protected)>

-Wundef
  Warn if an undefined identifier is evaluated in an #if directive.

Signed-off-by: Ferry Huberts <(spam-protected)>
---
 Makefile.inc                      |    1 +
 gui/win32/Main/Frontend.h         |    2 +-
 gui/win32/Main/FrontendDlg.h      |    2 +-
 gui/win32/Main/MyDialog1.h        |    2 +-
 gui/win32/Main/MyDialog2.h        |    2 +-
 gui/win32/Main/MyDialog3.h        |    2 +-
 gui/win32/Main/MyDialog4.h        |    2 +-
 gui/win32/Main/MyEdit.h           |    2 +-
 gui/win32/Main/MyTabCtrl.h        |    2 +-
 gui/win32/Main/StdAfx.h           |    2 +-
 lib/dot_draw/src/olsrd_dot_draw.c |    2 +-
 lib/pgraph/src/olsrd_pgraph.c     |    2 +-
 src/bsd/net.c                     |    2 +-
 src/cfgparser/olsrd_conf.c        |    6 +++++-
 src/cfgparser/oparse.y            |    4 ++--
 src/linux/kernel_tunnel.c         |    6 ++++++
 src/log.h                         |    2 +-
 src/main.c                        |    4 ++--
 src/plugin_loader.c               |   14 +++++++-------
 src/plugin_loader.h               |    4 ++--
 src/process_routes.c              |    2 +-
 src/tc_set.c                      |    2 +-
 src/unix/log.c                    |    2 +-
 23 files changed, 41 insertions(+), 30 deletions(-)

diff --git a/Makefile.inc b/Makefile.inc
index d72fdf4..8b8f31a 100644
--- a/Makefile.inc
+++ b/Makefile.inc
@@ -95,6 +95,7 @@ WARNINGS +=	-Wformat-y2k
 WARNINGS +=	-Winit-self
 WARNINGS +=	-Wswitch-default
 WARNINGS +=	-Wsync-nand
+WARNINGS +=	-Wundef
 # the following 2 do not work yet and need more work on it
 #WARNINGS +=	-Wconversion
 #WARNINGS +=	-Wredundant-decls
diff --git a/gui/win32/Main/Frontend.h b/gui/win32/Main/Frontend.h
index 2a9e28d..6bda3c1 100644
--- a/gui/win32/Main/Frontend.h
+++ b/gui/win32/Main/Frontend.h
@@ -42,7 +42,7 @@
 #if !defined(AFX_FRONTEND_H__8033A41F_6FDC_4054_A582_AB7B6AC5EEAE__INCLUDED_)
 #define AFX_FRONTEND_H__8033A41F_6FDC_4054_A582_AB7B6AC5EEAE__INCLUDED_
 
-#if _MSC_VER > 1000
+#if defined _MSC_VER && _MSC_VER > 1000
 #pragma once
 #endif
 
diff --git a/gui/win32/Main/FrontendDlg.h b/gui/win32/Main/FrontendDlg.h
index 088f5e9..f76c8f5 100644
--- a/gui/win32/Main/FrontendDlg.h
+++ b/gui/win32/Main/FrontendDlg.h
@@ -42,7 +42,7 @@
 #if !defined(AFX_FRONTENDDLG_H__7D68FBC0_7448_479B_81F0_3FBBDE291395__INCLUDED_)
 #define AFX_FRONTENDDLG_H__7D68FBC0_7448_479B_81F0_3FBBDE291395__INCLUDED_
 
-#if _MSC_VER > 1000
+#if defined _MSC_VER && _MSC_VER > 1000
 #pragma once
 #endif
 
diff --git a/gui/win32/Main/MyDialog1.h b/gui/win32/Main/MyDialog1.h
index b5f0365..c69dd0d 100644
--- a/gui/win32/Main/MyDialog1.h
+++ b/gui/win32/Main/MyDialog1.h
@@ -42,7 +42,7 @@
 #if !defined(AFX_MYDIALOG1_H__1A381668_A36B_4C51_9B79_643BC2A59D88__INCLUDED_)
 #define AFX_MYDIALOG1_H__1A381668_A36B_4C51_9B79_643BC2A59D88__INCLUDED_
 
-#if _MSC_VER > 1000
+#if defined _MSC_VER && _MSC_VER > 1000
 #pragma once
 #endif
 
diff --git a/gui/win32/Main/MyDialog2.h b/gui/win32/Main/MyDialog2.h
index f50020e..38d8ab4 100644
--- a/gui/win32/Main/MyDialog2.h
+++ b/gui/win32/Main/MyDialog2.h
@@ -42,7 +42,7 @@
 #if !defined(AFX_MYDIALOG2_H__1A381668_A36B_4C51_9B79_643BC2A59D88__INCLUDED_)
 #define AFX_MYDIALOG2_H__1A381668_A36B_4C51_9B79_643BC2A59D88__INCLUDED_
 
-#if _MSC_VER > 1000
+#if defined _MSC_VER && _MSC_VER > 1000
 #pragma once
 #endif
 
diff --git a/gui/win32/Main/MyDialog3.h b/gui/win32/Main/MyDialog3.h
index 54ea7d7..0713502 100644
--- a/gui/win32/Main/MyDialog3.h
+++ b/gui/win32/Main/MyDialog3.h
@@ -42,7 +42,7 @@
 #if !defined(AFX_MYDIALOG3_H__1A381668_A36B_4C51_9B79_643BC2A59D88__INCLUDED_)
 #define AFX_MYDIALOG3_H__1A381668_A36B_4C51_9B79_643BC2A59D88__INCLUDED_
 
-#if _MSC_VER > 1000
+#if defined _MSC_VER && _MSC_VER > 1000
 #pragma once
 #endif
 
diff --git a/gui/win32/Main/MyDialog4.h b/gui/win32/Main/MyDialog4.h
index 6112538..869acfa 100644
--- a/gui/win32/Main/MyDialog4.h
+++ b/gui/win32/Main/MyDialog4.h
@@ -42,7 +42,7 @@
 #if !defined(AFX_MYDIALOG4_H__1A381668_A36B_4C51_9B79_643BC2A59D88__INCLUDED_)
 #define AFX_MYDIALOG4_H__1A381668_A36B_4C51_9B79_643BC2A59D88__INCLUDED_
 
-#if _MSC_VER > 1000
+#if defined _MSC_VER && _MSC_VER > 1000
 #pragma once
 #endif
 
diff --git a/gui/win32/Main/MyEdit.h b/gui/win32/Main/MyEdit.h
index 3d73aed..0f77a3b 100644
--- a/gui/win32/Main/MyEdit.h
+++ b/gui/win32/Main/MyEdit.h
@@ -42,7 +42,7 @@
 #if !defined(AFX_MYEDIT_H__951EC391_AFE3_428F_865D_24CA55C68C7C__INCLUDED_)
 #define AFX_MYEDIT_H__951EC391_AFE3_428F_865D_24CA55C68C7C__INCLUDED_
 
-#if _MSC_VER > 1000
+#if defined _MSC_VER && _MSC_VER > 1000
 #pragma once
 #endif
 
diff --git a/gui/win32/Main/MyTabCtrl.h b/gui/win32/Main/MyTabCtrl.h
index d809740..1f0bb4b 100644
--- a/gui/win32/Main/MyTabCtrl.h
+++ b/gui/win32/Main/MyTabCtrl.h
@@ -42,7 +42,7 @@
 #if !defined(AFX_MYTABCTRL_H__D443FF52_C52D_4C89_AB4B_19B09687EBAE__INCLUDED_)
 #define AFX_MYTABCTRL_H__D443FF52_C52D_4C89_AB4B_19B09687EBAE__INCLUDED_
 
-#if _MSC_VER > 1000
+#if defined _MSC_VER && _MSC_VER > 1000
 #pragma once
 #endif
 
diff --git a/gui/win32/Main/StdAfx.h b/gui/win32/Main/StdAfx.h
index 9c13b05..3411bcc 100644
--- a/gui/win32/Main/StdAfx.h
+++ b/gui/win32/Main/StdAfx.h
@@ -6,7 +6,7 @@
 #if !defined(AFX_STDAFX_H__D43BD17B_AEC0_43A5_9F3B_1DAA99152E38__INCLUDED_)
 #define AFX_STDAFX_H__D43BD17B_AEC0_43A5_9F3B_1DAA99152E38__INCLUDED_
 
-#if _MSC_VER > 1000
+#if defined _MSC_VER && _MSC_VER > 1000
 #pragma once
 #endif // _MSC_VER > 1000
 
diff --git a/lib/dot_draw/src/olsrd_dot_draw.c b/lib/dot_draw/src/olsrd_dot_draw.c
index 31fe705..7ec21ac 100644
--- a/lib/dot_draw/src/olsrd_dot_draw.c
+++ b/lib/dot_draw/src/olsrd_dot_draw.c
@@ -208,7 +208,7 @@ plugin_ipc_init(void)
     CLOSE(ipc_socket);
     return 0;
   }
-#if (defined __FreeBSD__ || __FreeBSD_kernel__) && defined SO_NOSIGPIPE
+#if (defined __FreeBSD__ || defined __FreeBSD_kernel__) && defined SO_NOSIGPIPE
   if (setsockopt(ipc_socket, SOL_SOCKET, SO_NOSIGPIPE, (char *)&yes, sizeof(yes)) < 0) {
     perror("SO_REUSEADDR failed");
     CLOSE(ipc_socket);
diff --git a/lib/pgraph/src/olsrd_pgraph.c b/lib/pgraph/src/olsrd_pgraph.c
index 59adcc9..ebbe3d4 100644
--- a/lib/pgraph/src/olsrd_pgraph.c
+++ b/lib/pgraph/src/olsrd_pgraph.c
@@ -384,7 +384,7 @@ ipc_send(const char *data, int size)
   if (ipc_connection == -1)
     return 0;
 
-#if defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __APPLE__ || __OpenBSD__
+#if defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __APPLE__ || defined __OpenBSD__
 #define FLAG 0
 #else
 #define FLAG MSG_NOSIGNAL
diff --git a/src/bsd/net.c b/src/bsd/net.c
index ef74c32..de877c1 100644
--- a/src/bsd/net.c
+++ b/src/bsd/net.c
@@ -97,7 +97,7 @@
 #include <net80211/ieee80211_ioctl.h>
 #endif
 
-#if defined __FreeBSD__ || __FreeBSD_kernel__
+#if defined __FreeBSD__ || defined __FreeBSD_kernel__
 #include <net/if_var.h>
 #include <net/ethernet.h>
 #include <netinet/in_var.h>
diff --git a/src/cfgparser/olsrd_conf.c b/src/cfgparser/olsrd_conf.c
index 663caa3..32db6bf 100644
--- a/src/cfgparser/olsrd_conf.c
+++ b/src/cfgparser/olsrd_conf.c
@@ -522,12 +522,16 @@ olsrd_sanity_check_cnf(struct olsrd_config *cnf)
   }
 
 #if defined linux
+#if !defined LINUX_VERSION_CODE || !defined KERNEL_VERSION
+#error "Both LINUX_VERSION_CODE and KERNEL_VERSION need to be defined"
+#else
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
   if (cnf->ip_version == AF_INET6 && cnf->smart_gw_active) {
-    fprintf(stderr, "Smart gateways are not supported for linux kernel 2.4 and ipv6\n");
+    fprintf(stderr, "Smart gateways are not supported for linux kernel < 2.6.24 and ipv6\n");
     return -1;
   }
 #endif
+#endif
 
   /* this rtpolicy settings are also currently only used in Linux */
   if (olsrd_sanity_check_rtpolicy(cnf)) {
diff --git a/src/cfgparser/oparse.y b/src/cfgparser/oparse.y
index 0aed134..a6da2b3 100644
--- a/src/cfgparser/oparse.y
+++ b/src/cfgparser/oparse.y
@@ -59,7 +59,7 @@
 
 #define PARSER_DEBUG 1
 
-#if PARSER_DEBUG
+#if defined PARSER_DEBUG && PARSER_DEBUG
 #define PARSER_DEBUG_PRINTF(x, args...)   printf(x, ##args)
 #else
 #define PARSER_DEBUG_PRINTF(x, args...)   do { } while (0)
@@ -87,7 +87,7 @@ static int lq_mult_helper(YYSTYPE ip_addr_arg, YYSTYPE mult_arg)
   int i;
   struct olsr_if *walker;
 
-#if PARSER_DEBUG > 0
+#if defined PARSER_DEBUG && PARSER_DEBUG > 0
   printf("\tLinkQualityMult %s %0.2f\n",
          (ip_addr_arg != NULL) ? ip_addr_arg->string : "any",
          (double)mult_arg->floating);
diff --git a/src/linux/kernel_tunnel.c b/src/linux/kernel_tunnel.c
index ecad1d0..3289d5b 100644
--- a/src/linux/kernel_tunnel.c
+++ b/src/linux/kernel_tunnel.c
@@ -57,9 +57,15 @@
 #include <linux/ip.h>
 #include <linux/if_tunnel.h>
 #include <linux/version.h>
+#if defined linux
+#if !defined LINUX_VERSION_CODE || !defined KERNEL_VERSION
+#error "Both LINUX_VERSION_CODE and KERNEL_VERSION need to be defined"
+#else
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
 #include <linux/ip6_tunnel.h>
 #endif
+#endif
+#endif
 
 //ifup includes
 #include <sys/socket.h>
diff --git a/src/log.h b/src/log.h
index cfdcfae..5b95ed9 100644
--- a/src/log.h
+++ b/src/log.h
@@ -53,7 +53,7 @@
 
 void olsr_openlog(const char *ident);
 
-#if SYSLOG_NUMBERING
+#if defined SYSLOG_NUMBERING && SYSLOG_NUMBERING
 void olsr_syslog_real(int level, const char *format, ...) __attribute__ ((format(printf, 2, 3)));
 
 extern unsigned int olsr_syslog_ctr;
diff --git a/src/main.c b/src/main.c
index 4a41740..11cb2fb 100644
--- a/src/main.c
+++ b/src/main.c
@@ -82,7 +82,7 @@ static void olsr_shutdown(int) __attribute__ ((noreturn));
 
 #if defined __ANDROID__
 #define DEFAULT_LOCKFILE_PREFIX "/data/local/olsrd"
-#elif defined linux || __FreeBSD__ || defined __NetBSD__ || defined __OpenBSD__
+#elif defined linux || defined __FreeBSD__ || defined __NetBSD__ || defined __OpenBSD__
 #define DEFAULT_LOCKFILE_PREFIX "/var/run/olsrd"
 #elif defined WIN32
 #define DEFAULT_LOCKFILE_PREFIX "C:\\olsrd"
@@ -438,7 +438,7 @@ int main(int argc, char *argv[]) {
   /*
    * create routing socket
    */
-#if defined __FreeBSD__ || __FreeBSD_kernel__ || defined __APPLE__ || defined __NetBSD__ || defined __OpenBSD__
+#if defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __APPLE__ || defined __NetBSD__ || defined __OpenBSD__
   olsr_cnf->rts = socket(PF_ROUTE, SOCK_RAW, 0);
   if (olsr_cnf->rts < 0) {
     olsr_syslog(OLSR_LOG_ERR, "routing socket: %m");
diff --git a/src/plugin_loader.c b/src/plugin_loader.c
index 6f82527..5b4972c 100644
--- a/src/plugin_loader.c
+++ b/src/plugin_loader.c
@@ -87,7 +87,7 @@ olsr_load_plugins(void)
 static int
 olsr_load_dl(char *libname, struct plugin_param *params)
 {
-#if TESTLIB_PATH
+#if defined TESTLIB_PATH && TESTLIB_PATH
   char path[256] = "/usr/testlib/";
 #endif
   struct olsr_plugin *plugin = olsr_malloc(sizeof(struct olsr_plugin), "Plugin entry");
@@ -95,7 +95,7 @@ olsr_load_dl(char *libname, struct plugin_param *params)
 
   OLSR_PRINTF(0, "---------- LOADING LIBRARY %s ----------\n", libname);
 
-#if TESTLIB_PATH
+#if defined TESTLIB_PATH && TESTLIB_PATH
   strcat(path, libname);
   plugin->dlhandle = dlopen(path, RTLD_NOW);
 #else
@@ -131,7 +131,7 @@ olsr_load_dl(char *libname, struct plugin_param *params)
   return rv;
 }
 
-#if SUPPORT_OLD_PLUGIN_VERSIONS
+#if defined SUPPORT_OLD_PLUGIN_VERSIONS && SUPPORT_OLD_PLUGIN_VERSIONS
 static int
 try_old_versions(const struct olsr_plugin *plugin)
 {
@@ -183,14 +183,14 @@ olsr_add_dl(struct olsr_plugin *plugin)
                 "\nWARNING: YOU ARE USING AN OLD DEPRECATED PLUGIN INTERFACE!\n"
                 "DETECTED VERSION %d AND THE CURRENT VERSION IS %d\n" "PLEASE UPGRADE YOUR PLUGIN!\n", plugin_interface_version,
                 MOST_RECENT_PLUGIN_INTERFACE_VERSION);
-#if SUPPORT_OLD_PLUGIN_VERSIONS
+#if defined SUPPORT_OLD_PLUGIN_VERSIONS && SUPPORT_OLD_PLUGIN_VERSIONS
     OLSR_PRINTF(0, "WILL CONTINUE IN 5 SECONDS...\n\n");
     sleep(5);
 #else
     return -1;
 #endif
   }
-#if SUPPORT_OLD_PLUGIN_VERSIONS
+#if defined SUPPORT_OLD_PLUGIN_VERSIONS && SUPPORT_OLD_PLUGIN_VERSIONS
   /* new plugin interface */
   if (plugin_interface_version < LAST_SUPPORTED_PLUGIN_INTERFACE_VERSION) {
     OLSR_PRINTF(0,
@@ -216,7 +216,7 @@ olsr_add_dl(struct olsr_plugin *plugin)
   if (get_plugin_parameters != NULL) {
     (*get_plugin_parameters) (&plugin->plugin_parameters, &plugin->plugin_parameters_size);
   } else {
-#if SUPPORT_OLD_PLUGIN_VERSIONS
+#if defined SUPPORT_OLD_PLUGIN_VERSIONS && SUPPORT_OLD_PLUGIN_VERSIONS
     /* Fetch the parameter function */
     OLSR_PRINTF(1, "Trying to fetch param function: ");
 
@@ -282,7 +282,7 @@ init_olsr_plugin(struct olsr_plugin *entry)
           rv = -1;
         }
       }
-#if SUPPORT_OLD_PLUGIN_VERSIONS
+#if defined SUPPORT_OLD_PLUGIN_VERSIONS && SUPPORT_OLD_PLUGIN_VERSIONS
     } else if (entry->register_param != NULL) {
       int rc;
       OLSR_PRINTF(0, "Registering parameter \"%s\": ", params->key);
diff --git a/src/plugin_loader.h b/src/plugin_loader.h
index 244a8e6..6951c0e 100644
--- a/src/plugin_loader.h
+++ b/src/plugin_loader.h
@@ -52,7 +52,7 @@
 typedef int (*plugin_init_func) (void);
 typedef int (*get_interface_version_func) (void);
 
-#if SUPPORT_OLD_PLUGIN_VERSIONS
+#if defined SUPPORT_OLD_PLUGIN_VERSIONS && SUPPORT_OLD_PLUGIN_VERSIONS
 
 /* version 4 */
 typedef int (*register_param_func) (char *, char *);
@@ -68,7 +68,7 @@ struct olsr_plugin {
   struct plugin_param *params;
   int plugin_interface_version;
 
-#if SUPPORT_OLD_PLUGIN_VERSIONS
+#if defined SUPPORT_OLD_PLUGIN_VERSIONS && SUPPORT_OLD_PLUGIN_VERSIONS
   /* version 4 */
   register_param_func register_param;
 #endif
diff --git a/src/process_routes.c b/src/process_routes.c
index a528b64..697a228 100644
--- a/src/process_routes.c
+++ b/src/process_routes.c
@@ -419,7 +419,7 @@ olsr_update_kernel_routes(void)
   /* route changes */
   olsr_chg_kernel_routes(&chg_kernel_list);
 
-#if DEBUG
+#if defined DEBUG && DEBUG
   olsr_print_routing_table(&routingtree);
 #endif
 }
diff --git a/src/tc_set.c b/src/tc_set.c
index dc5ea01..2971195 100644
--- a/src/tc_set.c
+++ b/src/tc_set.c
@@ -667,7 +667,7 @@ olsr_tc_update_edge(struct tc_entry *tc, uint16_t ansn, const unsigned char **cu
     if (olsr_calc_tc_edge_entry_etx(tc_edge)) {
       edge_change = 1;
     }
-#if DEBUG
+#if defined DEBUG && DEBUG
     if (edge_change) {
       OLSR_PRINTF(1, "TC:   chg edge entry %s\n", olsr_tc_edge_to_string(tc_edge));
     }
diff --git a/src/unix/log.c b/src/unix/log.c
index d60d17a..e58c876 100644
--- a/src/unix/log.c
+++ b/src/unix/log.c
@@ -63,7 +63,7 @@ olsr_openlog(const char *ident)
   return;
 }
 
-#if SYSLOG_NUMBERING
+#if defined SYSLOG_NUMBERING && SYSLOG_NUMBERING
 
 unsigned int olsr_syslog_ctr = 0;
 
-- 
1.7.7.6





More information about the Olsr-dev mailing list