git » nmdb » commit 981770d

libnmdb: Remove redundant _ENABLE_X constants

author Alberto Bertogli
2010-10-07 03:48:05 UTC
committer Alberto Bertogli
2010-10-07 03:48:05 UTC
parent 46515f4949f35220cb9c8edc29205d80b78f6421

libnmdb: Remove redundant _ENABLE_X constants

There is no need to pass -DENABLE_X when building, the constants are readily
available in internal.h, but as _ENABLE_X.

This patch removes the redundancy by turning the internal.h constants into
ENABLE_X form, and not passing the -D when building. The code then gets the
constants from internal.h.

Thanks to Jay Sprenkle <jsprenkle@gmail.com> for the report.

Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>

libnmdb/Makefile +0 -4
libnmdb/internal.h.in +8 -8

diff --git a/libnmdb/Makefile b/libnmdb/Makefile
index b11f84f..7e2beaf 100644
--- a/libnmdb/Makefile
+++ b/libnmdb/Makefile
@@ -8,10 +8,6 @@ ENABLE_SCTP := $(shell if echo "\#include <netinet/sctp.h>" | \
 
 CFLAGS += -std=c99 -pedantic -Wall -O3
 ALL_CFLAGS = -D_XOPEN_SOURCE=500 -fPIC $(CFLAGS)
-ALL_CFLAGS += -DENABLE_TIPC=$(ENABLE_TIPC) \
-		-DENABLE_TCP=$(ENABLE_TCP) \
-		-DENABLE_UDP=$(ENABLE_UDP) \
-		-DENABLE_SCTP=$(ENABLE_SCTP)
 
 ifdef DEBUG
 ALL_CFLAGS += -g
diff --git a/libnmdb/internal.h.in b/libnmdb/internal.h.in
index 4b78469..dc875f9 100644
--- a/libnmdb/internal.h.in
+++ b/libnmdb/internal.h.in
@@ -22,10 +22,10 @@
 
 /* Defined to 0 or 1 at libnmdb build time according the build configuration,
  * not to be used externally. */
-#define _ENABLE_TIPC ++CONFIG_ENABLE_TIPC++
-#define _ENABLE_TCP ++CONFIG_ENABLE_TCP++
-#define _ENABLE_UDP ++CONFIG_ENABLE_UDP++
-#define _ENABLE_SCTP ++CONFIG_ENABLE_SCTP++
+#define ENABLE_TIPC ++CONFIG_ENABLE_TIPC++
+#define ENABLE_TCP ++CONFIG_ENABLE_TCP++
+#define ENABLE_UDP ++CONFIG_ENABLE_UDP++
+#define ENABLE_SCTP ++CONFIG_ENABLE_SCTP++
 
 /* Functions used internally but shared among the different files. */
 int compare_servers(const void *s1, const void *s2);
@@ -40,11 +40,11 @@ ssize_t ssend(int fd, const unsigned char *buf, size_t count, int flags);
 #include <sys/types.h>		/* socket defines */
 #include <sys/socket.h>		/* socklen_t */
 
-#if _ENABLE_TIPC
+#if ENABLE_TIPC
 #include <linux/tipc.h>		/* struct sockaddr_tipc */
 #endif
 
-#if (_ENABLE_TCP || _ENABLE_UDP || _ENABLE_SCTP)
+#if (ENABLE_TCP || ENABLE_UDP || ENABLE_SCTP)
 #include <netinet/in.h>		/* struct sockaddr_in */
 #endif
 
@@ -54,7 +54,7 @@ struct nmdb_srv {
 	int type;
 	union {
 
-#if _ENABLE_TIPC
+#if ENABLE_TIPC
 		struct {
 			unsigned int port;
 			struct sockaddr_tipc srvsa;
@@ -62,7 +62,7 @@ struct nmdb_srv {
 		} tipc;
 #endif
 
-#if (_ENABLE_TCP || _ENABLE_UDP || _ENABLE_SCTP)
+#if (ENABLE_TCP || ENABLE_UDP || ENABLE_SCTP)
 		struct {
 			struct sockaddr_in srvsa;
 			socklen_t srvlen;