more whitespace normalization

This commit is contained in:
Nick Mathewson 2010-03-05 13:00:15 -05:00
parent c7cf6f0049
commit 2c2618d858
19 changed files with 66 additions and 67 deletions

View File

@ -346,14 +346,14 @@ int _bufferevent_generic_adj_timeouts(struct bufferevent *bev);
struct bufferevent_private *locking = BEV_UPCAST(b); \ struct bufferevent_private *locking = BEV_UPCAST(b); \
if (locking->lock) \ if (locking->lock) \
EVLOCK_LOCK(locking->lock, 0); \ EVLOCK_LOCK(locking->lock, 0); \
} while(0) } while (0)
/** Internal: Release the lock (if any) on a bufferevent */ /** Internal: Release the lock (if any) on a bufferevent */
#define BEV_UNLOCK(b) do { \ #define BEV_UNLOCK(b) do { \
struct bufferevent_private *locking = BEV_UPCAST(b); \ struct bufferevent_private *locking = BEV_UPCAST(b); \
if (locking->lock) \ if (locking->lock) \
EVLOCK_UNLOCK(locking->lock, 0); \ EVLOCK_UNLOCK(locking->lock, 0); \
} while(0) } while (0)
/* ==== For rate-limiting. */ /* ==== For rate-limiting. */

View File

@ -58,11 +58,11 @@ struct devpollop {
int nchanges; int nchanges;
}; };
static void *devpoll_init (struct event_base *); static void *devpoll_init(struct event_base *);
static int devpoll_add(struct event_base *, int fd, short old, short events, void *); static int devpoll_add(struct event_base *, int fd, short old, short events, void *);
static int devpoll_del(struct event_base *, int fd, short old, short events, void *); static int devpoll_del(struct event_base *, int fd, short old, short events, void *);
static int devpoll_dispatch (struct event_base *, struct timeval *); static int devpoll_dispatch(struct event_base *, struct timeval *);
static void devpoll_dealloc (struct event_base *); static void devpoll_dealloc(struct event_base *);
const struct eventop devpollops = { const struct eventop devpollops = {
"devpoll", "devpoll",
@ -103,7 +103,7 @@ devpoll_queue(struct devpollop *devpollop, int fd, int events) {
* adding more * adding more
*/ */
if (devpoll_commit(devpollop) != 0) if (devpoll_commit(devpollop) != 0)
return(-1); return (-1);
} }
pfd = &devpollop->changes[devpollop->nchanges++]; pfd = &devpollop->changes[devpollop->nchanges++];
@ -245,7 +245,7 @@ devpoll_add(struct event_base *base, int fd, short old, short events, void *p)
res |= POLLOUT; res |= POLLOUT;
if (devpoll_queue(devpollop, fd, res) != 0) if (devpoll_queue(devpollop, fd, res) != 0)
return(-1); return (-1);
return (0); return (0);
} }
@ -271,7 +271,7 @@ devpoll_del(struct event_base *base, int fd, short old, short events, void *p)
*/ */
if (devpoll_queue(devpollop, fd, POLLREMOVE) != 0) if (devpoll_queue(devpollop, fd, POLLREMOVE) != 0)
return(-1); return (-1);
if ((res & (POLLIN|POLLOUT)) != (POLLIN|POLLOUT)) { if ((res & (POLLIN|POLLOUT)) != (POLLIN|POLLOUT)) {
/* /*

View File

@ -58,9 +58,9 @@ struct epollop {
int epfd; int epfd;
}; };
static void *epoll_init (struct event_base *); static void *epoll_init(struct event_base *);
static int epoll_dispatch (struct event_base *, struct timeval *); static int epoll_dispatch(struct event_base *, struct timeval *);
static void epoll_dealloc (struct event_base *); static void epoll_dealloc(struct event_base *);
const struct eventop epollops = { const struct eventop epollops = {
"epoll", "epoll",

View File

@ -206,19 +206,19 @@ struct evbuffer_chain_reference {
#define EVBUFFER_LOCK(buffer) \ #define EVBUFFER_LOCK(buffer) \
do { \ do { \
EVLOCK_LOCK((buffer)->lock, 0); \ EVLOCK_LOCK((buffer)->lock, 0); \
} while(0) } while (0)
#define EVBUFFER_UNLOCK(buffer) \ #define EVBUFFER_UNLOCK(buffer) \
do { \ do { \
EVLOCK_UNLOCK((buffer)->lock, 0); \ EVLOCK_UNLOCK((buffer)->lock, 0); \
} while(0) } while (0)
#define EVBUFFER_LOCK2(buffer1, buffer2) \ #define EVBUFFER_LOCK2(buffer1, buffer2) \
do { \ do { \
EVLOCK_LOCK2((buffer1)->lock, (buffer2)->lock, 0, 0); \ EVLOCK_LOCK2((buffer1)->lock, (buffer2)->lock, 0, 0); \
} while(0) } while (0)
#define EVBUFFER_UNLOCK2(buffer1, buffer2) \ #define EVBUFFER_UNLOCK2(buffer1, buffer2) \
do { \ do { \
EVLOCK_UNLOCK2((buffer1)->lock, (buffer2)->lock, 0, 0); \ EVLOCK_UNLOCK2((buffer1)->lock, (buffer2)->lock, 0, 0); \
} while(0) } while (0)
/** Increase the reference count of buf by one. */ /** Increase the reference count of buf by one. */
void _evbuffer_incref(struct evbuffer *buf); void _evbuffer_incref(struct evbuffer *buf);
@ -250,7 +250,7 @@ int _evbuffer_read_setup_vecs(struct evbuffer *buf, ev_ssize_t howmuch,
#define WSABUF_FROM_EVBUFFER_IOV(i,ei) do { \ #define WSABUF_FROM_EVBUFFER_IOV(i,ei) do { \
(i)->buf = (ei)->iov_base; \ (i)->buf = (ei)->iov_base; \
(i)->len = (ei)->iov_len; \ (i)->len = (ei)->iov_len; \
} while(0) } while (0)
/** Set the parent bufferevent object for buf to bev */ /** Set the parent bufferevent object for buf to bev */
void evbuffer_set_parent(struct evbuffer *buf, struct bufferevent *bev); void evbuffer_set_parent(struct evbuffer *buf, struct bufferevent *bev);

14
evdns.c
View File

@ -808,7 +808,7 @@ reply_handle(struct evdns_request *const req, u16 flags, u32 ttl, struct reply *
} }
} }
switch(error) { switch (error) {
case DNS_ERR_NOTIMPL: case DNS_ERR_NOTIMPL:
case DNS_ERR_REFUSED: case DNS_ERR_REFUSED:
/* we regard these errors as marking a bad nameserver */ /* we regard these errors as marking a bad nameserver */
@ -867,9 +867,9 @@ name_parse(u8 *packet, int length, int *idx, char *name_out, int name_out_len) {
int name_end = -1; int name_end = -1;
int j = *idx; int j = *idx;
int ptr_count = 0; int ptr_count = 0;
#define GET32(x) do { if (j + 4 > length) goto err; memcpy(&_t32, packet + j, 4); j += 4; x = ntohl(_t32); } while(0) #define GET32(x) do { if (j + 4 > length) goto err; memcpy(&_t32, packet + j, 4); j += 4; x = ntohl(_t32); } while (0)
#define GET16(x) do { if (j + 2 > length) goto err; memcpy(&_t, packet + j, 2); j += 2; x = ntohs(_t); } while(0) #define GET16(x) do { if (j + 2 > length) goto err; memcpy(&_t, packet + j, 2); j += 2; x = ntohs(_t); } while (0)
#define GET8(x) do { if (j >= length) goto err; x = packet[j++]; } while(0) #define GET8(x) do { if (j >= length) goto err; x = packet[j++]; } while (0)
char *cp = name_out; char *cp = name_out;
const char *const end = name_out + name_out_len; const char *const end = name_out + name_out_len;
@ -965,7 +965,7 @@ reply_parse(struct evdns_base *base, u8 *packet, int length) {
if (name_parse(packet, length, &j, tmp_name, \ if (name_parse(packet, length, &j, tmp_name, \
sizeof(tmp_name))<0) \ sizeof(tmp_name))<0) \
goto err; \ goto err; \
} while(0) } while (0)
#define TEST_NAME \ #define TEST_NAME \
do { tmp_name[0] = '\0'; \ do { tmp_name[0] = '\0'; \
cmp_name[0] = '\0'; \ cmp_name[0] = '\0'; \
@ -983,7 +983,7 @@ reply_parse(struct evdns_base *base, u8 *packet, int length) {
if (evutil_ascii_strcasecmp(tmp_name, cmp_name) == 0) \ if (evutil_ascii_strcasecmp(tmp_name, cmp_name) == 0) \
name_matches = 1; \ name_matches = 1; \
} \ } \
} while(0) } while (0)
reply.type = req->request_type; reply.type = req->request_type;
@ -1441,7 +1441,7 @@ dnslabel_table_add(struct dnslabel_table *table, const char *label, off_t pos)
return (-1); return (-1);
v = mm_strdup(label); v = mm_strdup(label);
if (v == NULL) if (v == NULL)
return(-1); return (-1);
p = table->n_labels++; p = table->n_labels++;
table->labels[p].v = v; table->labels[p].v = v;
table->labels[p].pos = pos; table->labels[p].pos = pos;

View File

@ -215,7 +215,7 @@ HT_GENERATE(event_debug_map, event_debug_entry, node, hash_debug_entry,
mm_free(dent); \ mm_free(dent); \
EVLOCK_UNLOCK(_event_debug_map_lock, 0); \ EVLOCK_UNLOCK(_event_debug_map_lock, 0); \
} \ } \
} while(0) } while (0)
#define _event_debug_note_add(ev) do { \ #define _event_debug_note_add(ev) do { \
if (_event_debug_mode_on) { \ if (_event_debug_mode_on) { \
struct event_debug_entry *dent,find; \ struct event_debug_entry *dent,find; \
@ -231,7 +231,7 @@ HT_GENERATE(event_debug_map, event_debug_entry, node, hash_debug_entry,
} \ } \
EVLOCK_UNLOCK(_event_debug_map_lock, 0); \ EVLOCK_UNLOCK(_event_debug_map_lock, 0); \
} \ } \
} while(0) } while (0)
#define _event_debug_note_del(ev) do { \ #define _event_debug_note_del(ev) do { \
if (_event_debug_mode_on) { \ if (_event_debug_mode_on) { \
struct event_debug_entry *dent,find; \ struct event_debug_entry *dent,find; \
@ -247,7 +247,7 @@ HT_GENERATE(event_debug_map, event_debug_entry, node, hash_debug_entry,
} \ } \
EVLOCK_UNLOCK(_event_debug_map_lock, 0); \ EVLOCK_UNLOCK(_event_debug_map_lock, 0); \
} \ } \
} while(0) } while (0)
#define _event_debug_assert_is_setup(ev) do { \ #define _event_debug_assert_is_setup(ev) do { \
if (_event_debug_mode_on) { \ if (_event_debug_mode_on) { \
struct event_debug_entry *dent,find; \ struct event_debug_entry *dent,find; \

View File

@ -107,11 +107,11 @@ struct evport_data {
int ed_pending[EVENTS_PER_GETN]; /* fd's with pending events */ int ed_pending[EVENTS_PER_GETN]; /* fd's with pending events */
}; };
static void* evport_init (struct event_base *); static void* evport_init(struct event_base *);
static int evport_add(struct event_base *, int fd, short old, short events, void *); static int evport_add(struct event_base *, int fd, short old, short events, void *);
static int evport_del(struct event_base *, int fd, short old, short events, void *); static int evport_del(struct event_base *, int fd, short old, short events, void *);
static int evport_dispatch (struct event_base *, struct timeval *); static int evport_dispatch(struct event_base *, struct timeval *);
static void evport_dealloc (struct event_base *); static void evport_dealloc(struct event_base *);
const struct eventop evportops = { const struct eventop evportops = {
"evport", "evport",

View File

@ -99,9 +99,9 @@ ht_string_hash(const char *s)
#ifdef HT_CACHE_HASH_VALUES #ifdef HT_CACHE_HASH_VALUES
#define _HT_SET_HASH(elm, field, hashfn) \ #define _HT_SET_HASH(elm, field, hashfn) \
do { (elm)->field.hte_hash = hashfn(elm); } while(0) do { (elm)->field.hte_hash = hashfn(elm); } while (0)
#define _HT_SET_HASHVAL(elm, field, val) \ #define _HT_SET_HASHVAL(elm, field, val) \
do { (elm)->field.hte_hash = (val); } while(0) do { (elm)->field.hte_hash = (val); } while (0)
#define _HT_ELT_HASH(elm, field, hashfn) \ #define _HT_ELT_HASH(elm, field, hashfn) \
((elm)->field.hte_hash) ((elm)->field.hte_hash)
#else #else

View File

@ -76,11 +76,11 @@ struct kqop {
static void kqop_free(struct kqop *kqop); static void kqop_free(struct kqop *kqop);
static void *kq_init (struct event_base *); static void *kq_init(struct event_base *);
static int kq_sig_add (struct event_base *, int, short, short, void *); static int kq_sig_add(struct event_base *, int, short, short, void *);
static int kq_sig_del (struct event_base *, int, short, short, void *); static int kq_sig_del(struct event_base *, int, short, short, void *);
static int kq_dispatch (struct event_base *, struct timeval *); static int kq_dispatch(struct event_base *, struct timeval *);
static void kq_dealloc (struct event_base *); static void kq_dealloc(struct event_base *);
const struct eventop kqops = { const struct eventop kqops = {
"kqueue", "kqueue",

View File

@ -119,9 +119,9 @@ int min_heap_reserve(min_heap_t* s, unsigned n)
{ {
struct event** p; struct event** p;
unsigned a = s->a ? s->a * 2 : 8; unsigned a = s->a ? s->a * 2 : 8;
if(a < n) if (a < n)
a = n; a = n;
if(!(p = (struct event**)realloc(s->p, a * sizeof *p))) if (!(p = (struct event**)realloc(s->p, a * sizeof *p)))
return -1; return -1;
s->p = p; s->p = p;
s->a = a; s->a = a;
@ -132,7 +132,7 @@ int min_heap_reserve(min_heap_t* s, unsigned n)
void min_heap_shift_up_(min_heap_t* s, unsigned hole_index, struct event* e) void min_heap_shift_up_(min_heap_t* s, unsigned hole_index, struct event* e)
{ {
unsigned parent = (hole_index - 1) / 2; unsigned parent = (hole_index - 1) / 2;
while(hole_index && min_heap_elem_greater(s->p[parent], e)) while (hole_index && min_heap_elem_greater(s->p[parent], e))
{ {
(s->p[hole_index] = s->p[parent])->ev_timeout_pos.min_heap_idx = hole_index; (s->p[hole_index] = s->p[parent])->ev_timeout_pos.min_heap_idx = hole_index;
hole_index = parent; hole_index = parent;
@ -144,7 +144,7 @@ void min_heap_shift_up_(min_heap_t* s, unsigned hole_index, struct event* e)
void min_heap_shift_down_(min_heap_t* s, unsigned hole_index, struct event* e) void min_heap_shift_down_(min_heap_t* s, unsigned hole_index, struct event* e)
{ {
unsigned min_child = 2 * (hole_index + 1); unsigned min_child = 2 * (hole_index + 1);
while(min_child <= s->n) while (min_child <= s->n)
{ {
min_child -= min_child == s->n || min_heap_elem_greater(s->p[min_child], s->p[min_child - 1]); min_child -= min_child == s->n || min_heap_elem_greater(s->p[min_child], s->p[min_child - 1]);
if (!(min_heap_elem_greater(e, s->p[min_child]))) if (!(min_heap_elem_greater(e, s->p[min_child])))

6
poll.c
View File

@ -61,11 +61,11 @@ struct pollop {
struct pollfd *event_set_copy; struct pollfd *event_set_copy;
}; };
static void *poll_init (struct event_base *); static void *poll_init(struct event_base *);
static int poll_add(struct event_base *, int, short old, short events, void *_idx); static int poll_add(struct event_base *, int, short old, short events, void *_idx);
static int poll_del(struct event_base *, int, short old, short events, void *_idx); static int poll_del(struct event_base *, int, short old, short events, void *_idx);
static int poll_dispatch (struct event_base *, struct timeval *); static int poll_dispatch(struct event_base *, struct timeval *);
static void poll_dealloc (struct event_base *); static void poll_dealloc(struct event_base *);
const struct eventop pollops = { const struct eventop pollops = {
"poll", "poll",

View File

@ -93,30 +93,30 @@ main(int argc, char **argv)
const char *fifo = "event.fifo"; const char *fifo = "event.fifo";
int socket; int socket;
if (lstat (fifo, &st) == 0) { if (lstat(fifo, &st) == 0) {
if ((st.st_mode & S_IFMT) == S_IFREG) { if ((st.st_mode & S_IFMT) == S_IFREG) {
errno = EEXIST; errno = EEXIST;
perror("lstat"); perror("lstat");
exit (1); exit(1);
} }
} }
unlink (fifo); unlink(fifo);
if (mkfifo (fifo, 0600) == -1) { if (mkfifo(fifo, 0600) == -1) {
perror("mkfifo"); perror("mkfifo");
exit (1); exit(1);
} }
/* Linux pipes are broken, we need O_RDWR instead of O_RDONLY */ /* Linux pipes are broken, we need O_RDWR instead of O_RDONLY */
#ifdef __linux #ifdef __linux
socket = open (fifo, O_RDWR | O_NONBLOCK, 0); socket = open(fifo, O_RDWR | O_NONBLOCK, 0);
#else #else
socket = open (fifo, O_RDONLY | O_NONBLOCK, 0); socket = open(fifo, O_RDONLY | O_NONBLOCK, 0);
#endif #endif
if (socket == -1) { if (socket == -1) {
perror("open"); perror("open");
exit (1); exit(1);
} }
fprintf(stderr, "Write data to %s\n", fifo); fprintf(stderr, "Write data to %s\n", fifo);

View File

@ -71,11 +71,11 @@ struct selectop {
fd_set *event_writeset_out; fd_set *event_writeset_out;
}; };
static void *select_init (struct event_base *); static void *select_init(struct event_base *);
static int select_add(struct event_base *, int, short old, short events, void*); static int select_add(struct event_base *, int, short old, short events, void*);
static int select_del(struct event_base *, int, short old, short events, void*); static int select_del(struct event_base *, int, short old, short events, void*);
static int select_dispatch (struct event_base *, struct timeval *); static int select_dispatch(struct event_base *, struct timeval *);
static void select_dealloc (struct event_base *); static void select_dealloc(struct event_base *);
const struct eventop selectops = { const struct eventop selectops = {
"select", "select",

View File

@ -94,8 +94,8 @@ main(int argc, char **argv)
unsigned short port = 8080; unsigned short port = 8080;
#ifdef WIN32 #ifdef WIN32
WSADATA WSAData; WSADATA WSAData;
WSAStartup(0x101, &WSAData); WSAStartup(0x101, &WSAData);
#else #else
if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) if (signal(SIGPIPE, SIG_IGN) == SIG_ERR)
return (1); return (1);
@ -114,7 +114,6 @@ main(int argc, char **argv)
exit(1); exit(1);
} }
switch (c) { switch (c) {
case 'p': case 'p':
port = atoi(argv[i+1]); port = atoi(argv[i+1]);

View File

@ -107,7 +107,7 @@ int _test_ai_eq(const struct evutil_addrinfo *ai, const char *sockaddr_port,
#define test_ai_eq(ai, str, s, p) do { \ #define test_ai_eq(ai, str, s, p) do { \
if (_test_ai_eq((ai), (str), (s), (p), __LINE__)<0) \ if (_test_ai_eq((ai), (str), (s), (p), __LINE__)<0) \
goto end; \ goto end; \
} while(0) } while (0)
#define test_timeval_diff_eq(tv1, tv2, diff) \ #define test_timeval_diff_eq(tv1, tv2, diff) \
tt_int_op(abs(timeval_msec_diff((tv1), (tv2)) - diff), <=, 30) tt_int_op(abs(timeval_msec_diff((tv1), (tv2)) - diff), <=, 30)

View File

@ -139,10 +139,10 @@ http_connect(const char *address, u_short port)
slen = sizeof(struct sockaddr_in); slen = sizeof(struct sockaddr_in);
sa = (struct sockaddr*)&sin; sa = (struct sockaddr*)&sin;
#else #else
memset(&ai, 0, sizeof (ai)); memset(&ai, 0, sizeof(ai));
ai.ai_family = AF_INET; ai.ai_family = AF_INET;
ai.ai_socktype = SOCK_STREAM; ai.ai_socktype = SOCK_STREAM;
evutil_snprintf(strport, sizeof (strport), "%d", port); evutil_snprintf(strport, sizeof(strport), "%d", port);
if (getaddrinfo(address, strport, &ai, &aitop) != 0) { if (getaddrinfo(address, strport, &ai, &aitop) != 0) {
event_warn("getaddrinfo"); event_warn("getaddrinfo");
return (-1); return (-1);

View File

@ -28,7 +28,7 @@
/* Helpers for defining statement-like macros */ /* Helpers for defining statement-like macros */
#define TT_STMT_BEGIN do { #define TT_STMT_BEGIN do {
#define TT_STMT_END } while(0) #define TT_STMT_END } while (0)
/* Redefine this if your test functions want to abort with something besides /* Redefine this if your test functions want to abort with something besides
* "goto end;" */ * "goto end;" */

View File

@ -179,7 +179,7 @@ long _evutil_weakrand(void);
__FILE__,__LINE__,#cond,__func__); \ __FILE__,__LINE__,#cond,__func__); \
abort(); \ abort(); \
} \ } \
} while(0) } while (0)
/* Internal addrinfo error code. This one is returned from only from /* Internal addrinfo error code. This one is returned from only from
* evutil_getaddrinfo_common, when we are sure that we'll have to hit a DNS * evutil_getaddrinfo_common, when we are sure that we'll have to hit a DNS

View File

@ -46,7 +46,7 @@
#include "event2/thread.h" #include "event2/thread.h"
#include "evthread-internal.h" #include "evthread-internal.h"
#define XFREE(ptr) do { if (ptr) mm_free(ptr); } while(0) #define XFREE(ptr) do { if (ptr) mm_free(ptr); } while (0)
extern struct event_list timequeue; extern struct event_list timequeue;
extern struct event_list addqueue; extern struct event_list addqueue;
@ -75,11 +75,11 @@ struct win32op {
unsigned signals_are_broken : 1; unsigned signals_are_broken : 1;
}; };
static void *win32_init (struct event_base *); static void *win32_init(struct event_base *);
static int win32_add(struct event_base *, evutil_socket_t, short old, short events, void *_idx); static int win32_add(struct event_base *, evutil_socket_t, short old, short events, void *_idx);
static int win32_del(struct event_base *, evutil_socket_t, short old, short events, void *_idx); static int win32_del(struct event_base *, evutil_socket_t, short old, short events, void *_idx);
static int win32_dispatch (struct event_base *base, struct timeval *); static int win32_dispatch(struct event_base *base, struct timeval *);
static void win32_dealloc (struct event_base *); static void win32_dealloc(struct event_base *);
struct eventop win32ops = { struct eventop win32ops = {
"win32", "win32",