From: Simon Ruderich Date: Sun, 1 Dec 2013 23:09:15 +0000 (+0100) Subject: Rename DEBUG() macro to DBG() to fix name clash. X-Git-Url: https://ruderich.org/simon/gitweb/?a=commitdiff_plain;h=39b505e0c28b8ee39bef37174cd12b0981b07d20;p=socket2unix%2Fsocket2unix.git Rename DEBUG() macro to DBG() to fix name clash. --- diff --git a/src/socket2unix.c b/src/socket2unix.c index 87c91e7..848a40b 100644 --- a/src/socket2unix.c +++ b/src/socket2unix.c @@ -128,7 +128,7 @@ static void log_(int level, const char *file, int line, const char *format, ...) log_(LOG_LEVEL_ERROR, __FILE__, __LINE__, __VA_ARGS__) #define WARN(...) \ log_(LOG_LEVEL_WARNING, __FILE__, __LINE__, __VA_ARGS__) -#define DEBUG(...) \ +#define DBG(...) \ log_(LOG_LEVEL_DEBUG, __FILE__, __LINE__, __VA_ARGS__) #define DIE(...) \ @@ -322,8 +322,8 @@ int socket(int domain, int type, int protocol) { return real_socket(domain, type, protocol); } - DEBUG("socket(%s, %s, %d)\n", - af_to_name(domain), sock_to_name(type), protocol); + DBG("socket(%s, %s, %d)\n", + af_to_name(domain), sock_to_name(type), protocol); /* We must return the replacement socket in case the program uses select() * or similar on it. */ @@ -353,11 +353,11 @@ int close(int fd) { static int (*real_close)(int); LOAD_FUNCTION(real_close, "close"); - DEBUG("close(%d)\n", fd); + DBG("close(%d)\n", fd); struct list *entry = remove_sockfd(fd); if (entry == NULL) { - DEBUG("close(%d): sockfd not found\n", fd); + DBG("close(%d): sockfd not found\n", fd); return real_close(fd); } assert(fd == entry->unix_sockfd); @@ -370,7 +370,7 @@ int bind(int sockfd, const struct sockaddr *addr, socklen_t addrlen) { static int (*real_bind)(int, const struct sockaddr *, socklen_t); LOAD_FUNCTION(real_bind, "bind"); - DEBUG("bind(%d, ..)\n", sockfd); + DBG("bind(%d, ..)\n", sockfd); if (addr == NULL || addrlen < sizeof(addr->sa_family) || addr->sa_family == AF_UNIX @@ -380,21 +380,20 @@ int bind(int sockfd, const struct sockaddr *addr, socklen_t addrlen) { struct list *entry = find_sockfd(sockfd); if (!entry) { - DEBUG("bind(%d, ..): sockfd not found\n", sockfd); + DBG("bind(%d, ..): sockfd not found\n", sockfd); return real_bind(sockfd, addr, addrlen); } assert(sockfd == entry->unix_sockfd); - DEBUG("bind(%d, ..): %s %s\n", - sockfd, - af_to_name(entry->orig_domain), - sock_to_name(entry->orig_type)); + DBG("bind(%d, ..): %s %s\n", + sockfd, + af_to_name(entry->orig_domain), sock_to_name(entry->orig_type)); struct sockaddr_un sockaddr; if (set_sockaddr_un(&sockaddr, addr, addrlen) != 0) { ERROR("connect(%d, ..) failed\n", sockfd); } - DEBUG("bind(%d, ..): using path '%s'\n", sockfd, sockaddr.sun_path); + DBG("bind(%d, ..): using path '%s'\n", sockfd, sockaddr.sun_path); int attempts = 0; while (attempts < 10) { @@ -441,18 +440,17 @@ int listen(int sockfd, int backlog) { static int (*real_listen)(int, int); LOAD_FUNCTION(real_listen, "listen"); - DEBUG("listen(%d, %d)\n", sockfd, backlog); + DBG("listen(%d, %d)\n", sockfd, backlog); struct list *entry = find_sockfd(sockfd); if (!entry) { - DEBUG("listen(%d, %d): sockfd not found\n", sockfd, backlog); + DBG("listen(%d, %d): sockfd not found\n", sockfd, backlog); return real_listen(sockfd, backlog); } assert(sockfd == entry->unix_sockfd); - DEBUG("listen(%d, %d): %s %s\n", - sockfd, backlog, - af_to_name(entry->orig_domain), - sock_to_name(entry->orig_type)); + DBG("listen(%d, %d): %s %s\n", + sockfd, backlog, + af_to_name(entry->orig_domain), sock_to_name(entry->orig_type)); if (real_listen(entry->unix_sockfd, backlog) != 0) { DIE("listen(): failed to listen"); @@ -465,18 +463,17 @@ int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen) { static int (*real_accept)(int, struct sockaddr *, socklen_t *); LOAD_FUNCTION(real_accept, "accept"); - DEBUG("accept(%d, ..)\n", sockfd); + DBG("accept(%d, ..)\n", sockfd); struct list *entry = find_sockfd(sockfd); if (!entry) { - DEBUG("accept(%d, ..): sockfd not found\n", sockfd); + DBG("accept(%d, ..): sockfd not found\n", sockfd); return real_accept(sockfd, addr, addrlen); } assert(sockfd == entry->unix_sockfd); - DEBUG("accept(%d, ..): %s %s\n", - sockfd, - af_to_name(entry->orig_domain), - sock_to_name(entry->orig_type)); + DBG("accept(%d, ..): %s %s\n", + sockfd, + af_to_name(entry->orig_domain), sock_to_name(entry->orig_type)); struct sockaddr_un sockaddr; socklen_t size = sizeof(sockaddr); @@ -489,7 +486,7 @@ int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen) { if (addr == NULL || addrlen == NULL) { return sock; } - DEBUG("accept(%d, ..): caller requested sockaddr\n", sockfd); + DBG("accept(%d, ..): caller requested sockaddr\n", sockfd); if (*addrlen < size) { WARN("accept(%d, ..): invalid addrlen from program", sockfd); @@ -511,7 +508,7 @@ int connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen) { static int (*real_connect)(int, const struct sockaddr *, socklen_t); LOAD_FUNCTION(real_connect, "connect"); - DEBUG("connect(%d, ..)\n", sockfd); + DBG("connect(%d, ..)\n", sockfd); if (addr == NULL || addrlen < sizeof(addr->sa_family) || addr->sa_family == AF_UNIX @@ -521,21 +518,20 @@ int connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen) { struct list *entry = find_sockfd(sockfd); if (!entry) { - DEBUG("connect(%d, ..): sockfd not found\n", sockfd); + DBG("connect(%d, ..): sockfd not found\n", sockfd); return real_connect(sockfd, addr, addrlen); } assert(sockfd == entry->unix_sockfd); - DEBUG("connect(%d, ..): %s %s\n", - sockfd, - af_to_name(entry->orig_domain), - sock_to_name(entry->orig_type)); + DBG("connect(%d, ..): %s %s\n", + sockfd, + af_to_name(entry->orig_domain), sock_to_name(entry->orig_type)); struct sockaddr_un sockaddr; if (set_sockaddr_un(&sockaddr, addr, addrlen) != 0) { ERROR("connect(%d, ..) failed\n", sockfd); } - DEBUG("connect(%d, ..): using path '%s'\n", sockfd, sockaddr.sun_path); + DBG("connect(%d, ..): using path '%s'\n", sockfd, sockaddr.sun_path); if (real_connect(entry->unix_sockfd, (struct sockaddr *)&sockaddr, sizeof(sockaddr)) != 0) { @@ -550,7 +546,7 @@ int getsockname(int sockfd, struct sockaddr *addr, socklen_t *addrlen) { static int (*real_getsockname)(int, struct sockaddr *, socklen_t *); LOAD_FUNCTION(real_getsockname, "getsockname"); - DEBUG("getsockname(%d, ..)\n", sockfd); + DBG("getsockname(%d, ..)\n", sockfd); return real_getsockname(sockfd, addr, addrlen); } @@ -559,7 +555,7 @@ int getpeername(int sockfd, struct sockaddr *addr, socklen_t *addrlen) { static int (*real_getpeername)(int, struct sockaddr *, socklen_t *); LOAD_FUNCTION(real_getpeername, "getpeername"); - DEBUG("getpeername(%d, ..)\n", sockfd); + DBG("getpeername(%d, ..)\n", sockfd); return real_getpeername(sockfd, addr, addrlen); } @@ -568,10 +564,8 @@ int getsockopt(int sockfd, int level, int optname, void *optval, socklen_t *optl static int (*real_getsockopt)(int, int, int, void *, socklen_t *); LOAD_FUNCTION(real_getsockopt, "getsockopt"); - DEBUG("getsockopt(%d, %d %s, %d, ..)\n", - sockfd, - level, level_to_name(level), - optname); + DBG("getsockopt(%d, %d %s, %d, ..)\n", + sockfd, level, level_to_name(level), optname); return real_getsockopt(sockfd, level, optname, optval, optlen); } @@ -579,10 +573,8 @@ int setsockopt(int sockfd, int level, int optname, const void *optval, socklen_t static int (*real_setsockopt)(int, int, int, const void *, socklen_t); LOAD_FUNCTION(real_setsockopt, "setsockopt"); - DEBUG("setsockopt(%d, %d %s, %d, ..)\n", - sockfd, - level, level_to_name(level), - optname); + DBG("setsockopt(%d, %d %s, %d, ..)\n", + sockfd, level, level_to_name(level), optname); return real_setsockopt(sockfd, level, optname, optval, optlen); }