From 2c2618d85861c1508f12787f2757459e02f9a002 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Fri, 5 Mar 2010 13:00:15 -0500 Subject: [PATCH] more whitespace normalization --- bufferevent-internal.h | 4 ++-- devpoll.c | 12 ++++++------ epoll.c | 6 +++--- evbuffer-internal.h | 10 +++++----- evdns.c | 14 +++++++------- event.c | 6 +++--- evport.c | 6 +++--- ht-internal.h | 4 ++-- kqueue.c | 10 +++++----- minheap-internal.h | 8 ++++---- poll.c | 6 +++--- sample/event-test.c | 16 ++++++++-------- select.c | 6 +++--- test/bench_http.c | 7 +++---- test/regress.h | 2 +- test/regress_http.c | 4 ++-- test/tinytest_macros.h | 2 +- util-internal.h | 2 +- win32select.c | 8 ++++---- 19 files changed, 66 insertions(+), 67 deletions(-) diff --git a/bufferevent-internal.h b/bufferevent-internal.h index 9736f42e..c83bf014 100644 --- a/bufferevent-internal.h +++ b/bufferevent-internal.h @@ -346,14 +346,14 @@ int _bufferevent_generic_adj_timeouts(struct bufferevent *bev); struct bufferevent_private *locking = BEV_UPCAST(b); \ if (locking->lock) \ EVLOCK_LOCK(locking->lock, 0); \ - } while(0) + } while (0) /** Internal: Release the lock (if any) on a bufferevent */ #define BEV_UNLOCK(b) do { \ struct bufferevent_private *locking = BEV_UPCAST(b); \ if (locking->lock) \ EVLOCK_UNLOCK(locking->lock, 0); \ - } while(0) + } while (0) /* ==== For rate-limiting. */ diff --git a/devpoll.c b/devpoll.c index 131088ad..9d4d8ba1 100644 --- a/devpoll.c +++ b/devpoll.c @@ -58,11 +58,11 @@ struct devpollop { 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_del(struct event_base *, int fd, short old, short events, void *); -static int devpoll_dispatch (struct event_base *, struct timeval *); -static void devpoll_dealloc (struct event_base *); +static int devpoll_dispatch(struct event_base *, struct timeval *); +static void devpoll_dealloc(struct event_base *); const struct eventop devpollops = { "devpoll", @@ -103,7 +103,7 @@ devpoll_queue(struct devpollop *devpollop, int fd, int events) { * adding more */ if (devpoll_commit(devpollop) != 0) - return(-1); + return (-1); } 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; if (devpoll_queue(devpollop, fd, res) != 0) - return(-1); + return (-1); 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) - return(-1); + return (-1); if ((res & (POLLIN|POLLOUT)) != (POLLIN|POLLOUT)) { /* diff --git a/epoll.c b/epoll.c index f8adeb5b..53c1f09a 100644 --- a/epoll.c +++ b/epoll.c @@ -58,9 +58,9 @@ struct epollop { int epfd; }; -static void *epoll_init (struct event_base *); -static int epoll_dispatch (struct event_base *, struct timeval *); -static void epoll_dealloc (struct event_base *); +static void *epoll_init(struct event_base *); +static int epoll_dispatch(struct event_base *, struct timeval *); +static void epoll_dealloc(struct event_base *); const struct eventop epollops = { "epoll", diff --git a/evbuffer-internal.h b/evbuffer-internal.h index 9a08bfad..894dc2f1 100644 --- a/evbuffer-internal.h +++ b/evbuffer-internal.h @@ -206,19 +206,19 @@ struct evbuffer_chain_reference { #define EVBUFFER_LOCK(buffer) \ do { \ EVLOCK_LOCK((buffer)->lock, 0); \ - } while(0) + } while (0) #define EVBUFFER_UNLOCK(buffer) \ do { \ EVLOCK_UNLOCK((buffer)->lock, 0); \ - } while(0) + } while (0) #define EVBUFFER_LOCK2(buffer1, buffer2) \ do { \ EVLOCK_LOCK2((buffer1)->lock, (buffer2)->lock, 0, 0); \ - } while(0) + } while (0) #define EVBUFFER_UNLOCK2(buffer1, buffer2) \ do { \ EVLOCK_UNLOCK2((buffer1)->lock, (buffer2)->lock, 0, 0); \ - } while(0) + } while (0) /** Increase the reference count of buf by one. */ 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 { \ (i)->buf = (ei)->iov_base; \ (i)->len = (ei)->iov_len; \ - } while(0) + } while (0) /** Set the parent bufferevent object for buf to bev */ void evbuffer_set_parent(struct evbuffer *buf, struct bufferevent *bev); diff --git a/evdns.c b/evdns.c index a597929f..3219aa5b 100644 --- a/evdns.c +++ b/evdns.c @@ -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_REFUSED: /* 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 j = *idx; 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 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 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 GET8(x) do { if (j >= length) goto err; x = packet[j++]; } while (0) char *cp = name_out; 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, \ sizeof(tmp_name))<0) \ goto err; \ - } while(0) + } while (0) #define TEST_NAME \ do { tmp_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) \ name_matches = 1; \ } \ - } while(0) + } while (0) reply.type = req->request_type; @@ -1441,7 +1441,7 @@ dnslabel_table_add(struct dnslabel_table *table, const char *label, off_t pos) return (-1); v = mm_strdup(label); if (v == NULL) - return(-1); + return (-1); p = table->n_labels++; table->labels[p].v = v; table->labels[p].pos = pos; diff --git a/event.c b/event.c index 3735a409..fb5d358e 100644 --- a/event.c +++ b/event.c @@ -215,7 +215,7 @@ HT_GENERATE(event_debug_map, event_debug_entry, node, hash_debug_entry, mm_free(dent); \ EVLOCK_UNLOCK(_event_debug_map_lock, 0); \ } \ - } while(0) + } while (0) #define _event_debug_note_add(ev) do { \ if (_event_debug_mode_on) { \ 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); \ } \ - } while(0) + } while (0) #define _event_debug_note_del(ev) do { \ if (_event_debug_mode_on) { \ 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); \ } \ - } while(0) + } while (0) #define _event_debug_assert_is_setup(ev) do { \ if (_event_debug_mode_on) { \ struct event_debug_entry *dent,find; \ diff --git a/evport.c b/evport.c index 2a703774..226c6cc2 100644 --- a/evport.c +++ b/evport.c @@ -107,11 +107,11 @@ struct evport_data { 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_del(struct event_base *, int fd, short old, short events, void *); -static int evport_dispatch (struct event_base *, struct timeval *); -static void evport_dealloc (struct event_base *); +static int evport_dispatch(struct event_base *, struct timeval *); +static void evport_dealloc(struct event_base *); const struct eventop evportops = { "evport", diff --git a/ht-internal.h b/ht-internal.h index 0c5f8a4f..4cc6b024 100644 --- a/ht-internal.h +++ b/ht-internal.h @@ -99,9 +99,9 @@ ht_string_hash(const char *s) #ifdef HT_CACHE_HASH_VALUES #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) \ - do { (elm)->field.hte_hash = (val); } while(0) + do { (elm)->field.hte_hash = (val); } while (0) #define _HT_ELT_HASH(elm, field, hashfn) \ ((elm)->field.hte_hash) #else diff --git a/kqueue.c b/kqueue.c index e09ae5aa..b8ffade5 100644 --- a/kqueue.c +++ b/kqueue.c @@ -76,11 +76,11 @@ struct kqop { static void kqop_free(struct kqop *kqop); -static void *kq_init (struct event_base *); -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_dispatch (struct event_base *, struct timeval *); -static void kq_dealloc (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_del(struct event_base *, int, short, short, void *); +static int kq_dispatch(struct event_base *, struct timeval *); +static void kq_dealloc(struct event_base *); const struct eventop kqops = { "kqueue", diff --git a/minheap-internal.h b/minheap-internal.h index 227ab96c..a240bf3a 100644 --- a/minheap-internal.h +++ b/minheap-internal.h @@ -119,9 +119,9 @@ int min_heap_reserve(min_heap_t* s, unsigned n) { struct event** p; unsigned a = s->a ? s->a * 2 : 8; - if(a < n) + if (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; s->p = p; 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) { 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; 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) { 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]); if (!(min_heap_elem_greater(e, s->p[min_child]))) diff --git a/poll.c b/poll.c index 0a316d99..84e7944e 100644 --- a/poll.c +++ b/poll.c @@ -61,11 +61,11 @@ struct pollop { 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_del(struct event_base *, int, short old, short events, void *_idx); -static int poll_dispatch (struct event_base *, struct timeval *); -static void poll_dealloc (struct event_base *); +static int poll_dispatch(struct event_base *, struct timeval *); +static void poll_dealloc(struct event_base *); const struct eventop pollops = { "poll", diff --git a/sample/event-test.c b/sample/event-test.c index 4dc41f49..0f3f7665 100644 --- a/sample/event-test.c +++ b/sample/event-test.c @@ -93,30 +93,30 @@ main(int argc, char **argv) const char *fifo = "event.fifo"; int socket; - if (lstat (fifo, &st) == 0) { + if (lstat(fifo, &st) == 0) { if ((st.st_mode & S_IFMT) == S_IFREG) { errno = EEXIST; perror("lstat"); - exit (1); + exit(1); } } - unlink (fifo); - if (mkfifo (fifo, 0600) == -1) { + unlink(fifo); + if (mkfifo(fifo, 0600) == -1) { perror("mkfifo"); - exit (1); + exit(1); } /* Linux pipes are broken, we need O_RDWR instead of O_RDONLY */ #ifdef __linux - socket = open (fifo, O_RDWR | O_NONBLOCK, 0); + socket = open(fifo, O_RDWR | O_NONBLOCK, 0); #else - socket = open (fifo, O_RDONLY | O_NONBLOCK, 0); + socket = open(fifo, O_RDONLY | O_NONBLOCK, 0); #endif if (socket == -1) { perror("open"); - exit (1); + exit(1); } fprintf(stderr, "Write data to %s\n", fifo); diff --git a/select.c b/select.c index d9fd62ce..5b8c2e47 100644 --- a/select.c +++ b/select.c @@ -71,11 +71,11 @@ struct selectop { 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_del(struct event_base *, int, short old, short events, void*); -static int select_dispatch (struct event_base *, struct timeval *); -static void select_dealloc (struct event_base *); +static int select_dispatch(struct event_base *, struct timeval *); +static void select_dealloc(struct event_base *); const struct eventop selectops = { "select", diff --git a/test/bench_http.c b/test/bench_http.c index 82598294..7404cb17 100644 --- a/test/bench_http.c +++ b/test/bench_http.c @@ -94,8 +94,8 @@ main(int argc, char **argv) unsigned short port = 8080; #ifdef WIN32 - WSADATA WSAData; - WSAStartup(0x101, &WSAData); + WSADATA WSAData; + WSAStartup(0x101, &WSAData); #else if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) return (1); @@ -112,9 +112,8 @@ main(int argc, char **argv) if ((c == 'p' || c == 'l') && i + 1 >= argc) { fprintf(stderr, "-%c requires argument.\n", c); exit(1); - } + } - switch (c) { case 'p': port = atoi(argv[i+1]); diff --git a/test/regress.h b/test/regress.h index 436be623..5889a008 100644 --- a/test/regress.h +++ b/test/regress.h @@ -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 { \ if (_test_ai_eq((ai), (str), (s), (p), __LINE__)<0) \ goto end; \ - } while(0) + } while (0) #define test_timeval_diff_eq(tv1, tv2, diff) \ tt_int_op(abs(timeval_msec_diff((tv1), (tv2)) - diff), <=, 30) diff --git a/test/regress_http.c b/test/regress_http.c index 0ee5ca76..43e1d083 100644 --- a/test/regress_http.c +++ b/test/regress_http.c @@ -139,10 +139,10 @@ http_connect(const char *address, u_short port) slen = sizeof(struct sockaddr_in); sa = (struct sockaddr*)&sin; #else - memset(&ai, 0, sizeof (ai)); + memset(&ai, 0, sizeof(ai)); ai.ai_family = AF_INET; 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) { event_warn("getaddrinfo"); return (-1); diff --git a/test/tinytest_macros.h b/test/tinytest_macros.h index 66110877..62210f50 100644 --- a/test/tinytest_macros.h +++ b/test/tinytest_macros.h @@ -28,7 +28,7 @@ /* Helpers for defining statement-like macros */ #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 * "goto end;" */ diff --git a/util-internal.h b/util-internal.h index 633de55b..f74f323c 100644 --- a/util-internal.h +++ b/util-internal.h @@ -179,7 +179,7 @@ long _evutil_weakrand(void); __FILE__,__LINE__,#cond,__func__); \ abort(); \ } \ - } while(0) + } while (0) /* 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 diff --git a/win32select.c b/win32select.c index 444e806a..7dc68c91 100644 --- a/win32select.c +++ b/win32select.c @@ -46,7 +46,7 @@ #include "event2/thread.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 addqueue; @@ -75,11 +75,11 @@ struct win32op { 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_del(struct event_base *, evutil_socket_t, short old, short events, void *_idx); -static int win32_dispatch (struct event_base *base, struct timeval *); -static void win32_dealloc (struct event_base *); +static int win32_dispatch(struct event_base *base, struct timeval *); +static void win32_dealloc(struct event_base *); struct eventop win32ops = { "win32", -- 2.40.0