[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [obfsproxy/master] In preparation for importing Tor container.c, switch from bare __attribute__ to ATTR_* macros.



commit 94d44dd806b58dde92fdb82dd0c5ae12d649ef80
Author: Zack Weinberg <zackw@xxxxxxxxx>
Date:   Mon Jul 18 14:15:50 2011 -0700

    In preparation for importing Tor container.c, switch from bare __attribute__ to ATTR_* macros.
---
 src/main.c            |   17 +++++++----------
 src/protocols/dummy.c |    7 +++----
 src/util.c            |    2 +-
 src/util.h            |   21 +++++++++++++--------
 4 files changed, 24 insertions(+), 23 deletions(-)

diff --git a/src/main.c b/src/main.c
index 21c4feb..c48f81a 100644
--- a/src/main.c
+++ b/src/main.c
@@ -2,27 +2,24 @@
    See LICENSE for other credits and copying information
 */
 
-#include <stdlib.h>
+#include "util.h"
+#include "network.h"
+#include "protocol.h"
+
 #include <errno.h>
+#include <signal.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
-#include <signal.h>
 
 #include <event2/event.h>
-#include "network.h"
-#include "util.h"
-#include "protocol.h"
-
-#ifndef __GNUC__
-#define __attribute__(x)
-#endif
 
 /* The character that seperates multiple listeners in the cli */
 #define SEPARATOR "+"
 /* Totally arbitrary. */
 #define MAXPROTOCOLS 20
 
-static void usage(void) __attribute__((noreturn));
+static void usage(void) ATTR_NORETURN;
 static int handle_obfsproxy_args(const char **argv);
 
 static struct event_base *the_event_base=NULL;
diff --git a/src/protocols/dummy.c b/src/protocols/dummy.c
index d82818d..61cdf2b 100644
--- a/src/protocols/dummy.c
+++ b/src/protocols/dummy.c
@@ -116,14 +116,13 @@ dummy_destroy(struct protocol_t *proto)
    The dummy protocol just puts the data of 'source' in 'dest'.
 */
 static int
-dummy_handshake(struct protocol_t *proto __attribute__((unused)),
-                struct evbuffer *buf __attribute__((unused)))
+dummy_handshake(struct protocol_t *proto, struct evbuffer *buf)
 {
   return 0;
 }
 
 static int
-dummy_send(struct protocol_t *proto __attribute__((unused)),
+dummy_send(struct protocol_t *proto,
            struct evbuffer *source, struct evbuffer *dest)
 {
   return evbuffer_add_buffer(dest,source);
@@ -135,7 +134,7 @@ dummy_send(struct protocol_t *proto __attribute__((unused)),
   The dummy protocol just puts the data of 'source' into 'dest'.
 */
 static enum recv_ret
-dummy_recv(struct protocol_t *proto __attribute__((unused)),
+dummy_recv(struct protocol_t *proto,
            struct evbuffer *source, struct evbuffer *dest)
 {
   if (evbuffer_add_buffer(dest,source)<0)
diff --git a/src/util.c b/src/util.c
index 6a0e4a0..ce25375 100644
--- a/src/util.c
+++ b/src/util.c
@@ -25,7 +25,7 @@
 
 /**************************** Memory Allocation ******************************/
 
-static void __attribute__((noreturn))
+static void ATTR_NORETURN
 die_oom(void)
 {
   log_warn("Memory allocation failed: %s",strerror(errno));
diff --git a/src/util.h b/src/util.h
index d909b53..0693930 100644
--- a/src/util.h
+++ b/src/util.h
@@ -11,6 +11,11 @@
 #ifndef __GNUC__
 #define __attribute__(x) /* nothing */
 #endif
+#define ATTR_MALLOC   __attribute__((malloc))
+#define ATTR_NORETURN __attribute__((noreturn))
+#define ATTR_PRINTF_1 __attribute__((format(printf, 1, 2)))
+#define ATTR_PRINTF_3 __attribute__((format(printf, 3, 4)))
+#define ATTR_PURE     __attribute__((pure))
 
 struct sockaddr;
 struct event_base;
@@ -23,11 +28,11 @@ struct evdns_base;
    allocate-memory-or-crash functions "xwhatever". Also, at this time
    I do not see a need for a free() wrapper. */
 
-void *xmalloc(size_t size) __attribute__((malloc)); /* does not clear memory */
-void *xzalloc(size_t size) __attribute__((malloc)); /* clears memory */
+void *xmalloc(size_t size) ATTR_MALLOC; /* does not clear memory */
+void *xzalloc(size_t size) ATTR_MALLOC; /* clears memory */
 void *xrealloc(void *ptr, size_t size);
-void *xmemdup(const void *ptr, size_t size) __attribute__((malloc));
-char *xstrdup(const char *s) __attribute__((malloc));
+void *xmemdup(const void *ptr, size_t size) ATTR_MALLOC;
+char *xstrdup(const char *s) ATTR_MALLOC;
 
 /***** Network functions stuff. *****/
 
@@ -46,7 +51,7 @@ int obfs_vsnprintf(char *str, size_t size,
                    const char *format, va_list args);
 int obfs_snprintf(char *str, size_t size,
                   const char *format, ...)
-  __attribute__((format(printf, 3, 4)));
+  ATTR_PRINTF_3;
 
 /***** Doubly Linked List stuff. *****/
 
@@ -96,16 +101,16 @@ void close_obfsproxy_logfile(void);
 /** Warn-level severity: for messages that only appear when something
     has gone wrong. */
 void log_warn(const char *format, ...)
-  __attribute__((format(printf, 1, 2)));
+  ATTR_PRINTF_1;
 
 /** Info-level severity: for messages that should be sent to the user
     during normal operation. */
 void log_info(const char *format, ...)
-  __attribute__((format(printf, 1, 2)));
+  ATTR_PRINTF_1;
 
 /** Debug-level severity: for hyper-verbose messages of no interest to
     anybody but developers. */
 void log_debug(const char *format, ...)
-  __attribute__((format(printf, 1, 2)));
+  ATTR_PRINTF_1;
 
 #endif



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits