Parenthesize macro arguments more aggressively

This commit is contained in:
Nick Mathewson 2009-11-20 16:50:55 -05:00
parent f32b57505e
commit 07e9e9b4b1
4 changed files with 28 additions and 27 deletions

View File

@ -104,7 +104,7 @@ unsigned char *evbuffer_find(struct evbuffer *buffer, const unsigned char *what,
/** deprecated in favor of calling the functions directly */ /** deprecated in favor of calling the functions directly */
#define EVBUFFER_LENGTH(x) evbuffer_get_length(x) #define EVBUFFER_LENGTH(x) evbuffer_get_length(x)
/** deprecated in favor of calling the functions directly */ /** deprecated in favor of calling the functions directly */
#define EVBUFFER_DATA(x) evbuffer_pullup(x, -1) #define EVBUFFER_DATA(x) evbuffer_pullup((x), -1)
#endif #endif

View File

@ -367,8 +367,9 @@ int event_base_got_break(struct event_base *);
@param cb callback function @param cb callback function
@param arg argument that will be passed to the callback function @param arg argument that will be passed to the callback function
*/ */
#define evtimer_assign(ev, b, cb, arg) event_assign(ev, b, -1, 0, cb, arg) #define evtimer_assign(ev, b, cb, arg) \
#define evtimer_new(b, cb, arg) event_new(b, -1, 0, cb, arg) event_assign((ev), (b), -1, 0, (cb), (arg))
#define evtimer_new(b, cb, arg) event_new((b), -1, 0, (cb), (arg))
/** /**
Add a timer event. Add a timer event.
@ -376,7 +377,7 @@ int event_base_got_break(struct event_base *);
@param ev the event struct @param ev the event struct
@param tv timeval struct @param tv timeval struct
*/ */
#define evtimer_add(ev, tv) event_add(ev, tv) #define evtimer_add(ev, tv) event_add((ev), (tv))
/** /**
* Delete a timer event. * Delete a timer event.
@ -384,16 +385,16 @@ int event_base_got_break(struct event_base *);
* @param ev the event struct to be disabled * @param ev the event struct to be disabled
*/ */
#define evtimer_del(ev) event_del(ev) #define evtimer_del(ev) event_del(ev)
#define evtimer_pending(ev, tv) event_pending(ev, EV_TIMEOUT, tv) #define evtimer_pending(ev, tv) event_pending((ev), EV_TIMEOUT, (tv))
#define evtimer_initialized(ev) _event_initialized((ev), 0) #define evtimer_initialized(ev) _event_initialized((ev), 0)
#define evsignal_add(ev, tv) event_add(ev, tv) #define evsignal_add(ev, tv) event_add((ev), (tv))
#define evsignal_assign(ev, b, x, cb, arg) \ #define evsignal_assign(ev, b, x, cb, arg) \
event_assign(ev, b, x, EV_SIGNAL|EV_PERSIST, cb, arg) event_assign((ev), (b), (x), EV_SIGNAL|EV_PERSIST, cb, (arg))
#define evsignal_new(b, x, cb, arg) \ #define evsignal_new(b, x, cb, arg) \
event_new(b, x, EV_SIGNAL|EV_PERSIST, cb, arg) event_new((b), (x), EV_SIGNAL|EV_PERSIST, (cb), (arg))
#define evsignal_del(ev) event_del(ev) #define evsignal_del(ev) event_del(ev)
#define evsignal_pending(ev, tv) event_pending(ev, EV_SIGNAL, tv) #define evsignal_pending(ev, tv) event_pending((ev), EV_SIGNAL, (tv))
#define evsignal_initialized(ev) _event_initialized((ev), 0) #define evsignal_initialized(ev) _event_initialized((ev), 0)
/** /**

View File

@ -240,9 +240,9 @@ int event_priority_init(int);
*/ */
void event_set(struct event *, evutil_socket_t, short, void (*)(evutil_socket_t, short, void *), void *); void event_set(struct event *, evutil_socket_t, short, void (*)(evutil_socket_t, short, void *), void *);
#define evtimer_set(ev, cb, arg) event_set(ev, -1, 0, cb, arg) #define evtimer_set(ev, cb, arg) event_set((ev), -1, 0, (cb), (arg))
#define evsignal_set(ev, x, cb, arg) \ #define evsignal_set(ev, x, cb, arg) \
event_set(ev, x, EV_SIGNAL|EV_PERSIST, cb, arg) event_set((ev), (x), EV_SIGNAL|EV_PERSIST, (cb), (arg))
/** /**
@ -254,7 +254,7 @@ void event_set(struct event *, evutil_socket_t, short, void (*)(evutil_socket_t,
* @deprecated This macro is deprecated because its naming is inconsistent. * @deprecated This macro is deprecated because its naming is inconsistent.
* The recommend macro is evtimer_add(). * The recommend macro is evtimer_add().
*/ */
#define timeout_add(ev, tv) event_add(ev, tv) #define timeout_add(ev, tv) event_add((ev), (tv))
/** /**
@ -267,7 +267,7 @@ void event_set(struct event *, evutil_socket_t, short, void (*)(evutil_socket_t,
* @deprecated This macro is deprecated because its naming is inconsistent. * @deprecated This macro is deprecated because its naming is inconsistent.
* The recommend macro is evtimer_set(). * The recommend macro is evtimer_set().
*/ */
#define timeout_set(ev, cb, arg) event_set(ev, -1, 0, cb, arg) #define timeout_set(ev, cb, arg) event_set((ev), -1, 0, (cb), (arg))
/** /**
* Disable a timeout event. * Disable a timeout event.
@ -283,7 +283,7 @@ void event_set(struct event *, evutil_socket_t, short, void (*)(evutil_socket_t,
@deprecated This macro is deprecated because its naming is inconsistent. @deprecated This macro is deprecated because its naming is inconsistent.
The recommend macro is evtimer_pending(). The recommend macro is evtimer_pending().
*/ */
#define timeout_pending(ev, tv) event_pending(ev, EV_TIMEOUT, tv) #define timeout_pending(ev, tv) event_pending((ev), EV_TIMEOUT, (tv))
/** /**
@deprecated This macro is deprecated because its naming is inconsistent. @deprecated This macro is deprecated because its naming is inconsistent.
The recommend macro is evtimer_initialized(). The recommend macro is evtimer_initialized().
@ -294,25 +294,25 @@ void event_set(struct event *, evutil_socket_t, short, void (*)(evutil_socket_t,
@deprecated This macro is deprecated because its naming is inconsistent. @deprecated This macro is deprecated because its naming is inconsistent.
The recommend macro is evsignal_add(). The recommend macro is evsignal_add().
*/ */
#define signal_add(ev, tv) event_add(ev, tv) #define signal_add(ev, tv) event_add((ev), (tv))
/** /**
@deprecated This macro is deprecated because its naming is inconsistent. @deprecated This macro is deprecated because its naming is inconsistent.
The recommend macro is evsignal_set(). The recommend macro is evsignal_set().
*/ */
#define signal_set(ev, x, cb, arg) \ #define signal_set(ev, x, cb, arg) \
event_set(ev, x, EV_SIGNAL|EV_PERSIST, cb, arg) event_set((ev), (x), EV_SIGNAL|EV_PERSIST, (cb), (arg))
/** /**
@deprecated This macro is deprecated because its naming is inconsistent. @deprecated This macro is deprecated because its naming is inconsistent.
The recommend macro is evsignal_assign(). The recommend macro is evsignal_assign().
*/ */
#define signal_assign(ev, b, x, cb, arg) \ #define signal_assign(ev, b, x, cb, arg) \
event_assign(ev, b, x, EV_SIGNAL|EV_PERSIST, cb, arg) event_assign((ev), (b), (x), EV_SIGNAL|EV_PERSIST, (cb), (arg))
/** /**
@deprecated This macro is deprecated because its naming is inconsistent. @deprecated This macro is deprecated because its naming is inconsistent.
The recommend macro is evsignal_new(). The recommend macro is evsignal_new().
*/ */
#define signal_new(b, x, cb, arg) \ #define signal_new(b, x, cb, arg) \
event_new(b, x, EV_SIGNAL|EV_PERSIST, cb, arg) event_new((b), (x), EV_SIGNAL|EV_PERSIST, (cb), (arg))
/** /**
@deprecated This macro is deprecated because its naming is inconsistent. @deprecated This macro is deprecated because its naming is inconsistent.
The recommend macro is evsignal_del(). The recommend macro is evsignal_del().
@ -322,7 +322,7 @@ void event_set(struct event *, evutil_socket_t, short, void (*)(evutil_socket_t,
@deprecated This macro is deprecated because its naming is inconsistent. @deprecated This macro is deprecated because its naming is inconsistent.
The recommend macro is evsignal_pending(). The recommend macro is evsignal_pending().
*/ */
#define signal_pending(ev, tv) event_pending(ev, EV_SIGNAL, tv) #define signal_pending(ev, tv) event_pending((ev), EV_SIGNAL, (tv))
/** /**
@deprecated This macro is deprecated because its naming is inconsistent. @deprecated This macro is deprecated because its naming is inconsistent.
The recommend macro is evsignal_initialized(). The recommend macro is evsignal_initialized().

View File

@ -86,7 +86,7 @@ extern "C" {
@param value the value to assign @param value the value to assign
*/ */
#define EVTAG_ASSIGN(msg, member, value) \ #define EVTAG_ASSIGN(msg, member, value) \
(*(msg)->base->member##_assign)(msg, value) (*(msg)->base->member##_assign)((msg), (value))
/** /**
Assigns a value to the member in the message. Assigns a value to the member in the message.
@ -96,7 +96,7 @@ extern "C" {
@param len the length of the value @param len the length of the value
*/ */
#define EVTAG_ASSIGN_WITH_LEN(msg, member, value, len) \ #define EVTAG_ASSIGN_WITH_LEN(msg, member, value, len) \
(*(msg)->base->member##_assign)(msg, value, len) (*(msg)->base->member##_assign)((msg), (value), (len))
/** /**
Returns the value for a member. Returns the value for a member.
@ -106,7 +106,7 @@ extern "C" {
@return 0 on success, -1 otherwise. @return 0 on success, -1 otherwise.
*/ */
#define EVTAG_GET(msg, member, pvalue) \ #define EVTAG_GET(msg, member, pvalue) \
(*(msg)->base->member##_get)(msg, pvalue) (*(msg)->base->member##_get)((msg), (pvalue))
/** /**
Returns the value for a member. Returns the value for a member.
@ -117,7 +117,7 @@ extern "C" {
@return 0 on success, -1 otherwise. @return 0 on success, -1 otherwise.
*/ */
#define EVTAG_GET_WITH_LEN(msg, member, pvalue, plen) \ #define EVTAG_GET_WITH_LEN(msg, member, pvalue, plen) \
(*(msg)->base->member##_get)(msg, pvalue, plen) (*(msg)->base->member##_get)((msg), (pvalue), (plen))
#endif /* _EVENT2_RPC_COMPAT_H_ */ #endif /* _EVENT2_RPC_COMPAT_H_ */
@ -125,7 +125,7 @@ extern "C" {
Adds a value to an array. Adds a value to an array.
*/ */
#define EVTAG_ARRAY_ADD_VALUE(msg, member, value) \ #define EVTAG_ARRAY_ADD_VALUE(msg, member, value) \
(*(msg)->base->member##_add)(msg, value) (*(msg)->base->member##_add)((msg), (value))
/** /**
Allocates a new entry in the array and returns it. Allocates a new entry in the array and returns it.
*/ */
@ -135,7 +135,7 @@ extern "C" {
Gets a variable at the specified offset from the array. Gets a variable at the specified offset from the array.
*/ */
#define EVTAG_ARRAY_GET(msg, member, offset, pvalue) \ #define EVTAG_ARRAY_GET(msg, member, offset, pvalue) \
(*(msg)->base->member##_get)(msg, offset, pvalue) (*(msg)->base->member##_get)((msg), (offset), (pvalue))
/** /**
Returns the number of entries in the array. Returns the number of entries in the array.
*/ */
@ -342,7 +342,7 @@ int evrpc_register_rpc(struct evrpc_base *, struct evrpc *,
* @return -1 on error or 0 when successful. * @return -1 on error or 0 when successful.
* @see EVRPC_REGISTER() * @see EVRPC_REGISTER()
*/ */
#define EVRPC_UNREGISTER(base, name) evrpc_unregister_rpc(base, #name) #define EVRPC_UNREGISTER(base, name) evrpc_unregister_rpc((base), #name)
int evrpc_unregister_rpc(struct evrpc_base *base, const char *name); int evrpc_unregister_rpc(struct evrpc_base *base, const char *name);
@ -369,7 +369,7 @@ struct evrpc_status;
* @return 0 on success, -1 on failure * @return 0 on success, -1 on failure
*/ */
#define EVRPC_MAKE_REQUEST(name, pool, request, reply, cb, cbarg) \ #define EVRPC_MAKE_REQUEST(name, pool, request, reply, cb, cbarg) \
evrpc_send_request_##name(pool, request, reply, cb, cbarg) evrpc_send_request_##name((pool), (request), (reply), (cb), (cbarg))
/** /**
Makes an RPC request based on the provided context. Makes an RPC request based on the provided context.