mirror of
https://github.com/libevent/libevent.git
synced 2025-01-31 09:12:55 +08:00
more whitespace normalization
This commit is contained in:
parent
c7cf6f0049
commit
2c2618d858
@ -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. */
|
||||
|
||||
|
12
devpoll.c
12
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)) {
|
||||
/*
|
||||
|
6
epoll.c
6
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",
|
||||
|
@ -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);
|
||||
|
14
evdns.c
14
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;
|
||||
|
6
event.c
6
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; \
|
||||
|
6
evport.c
6
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",
|
||||
|
@ -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
|
||||
|
10
kqueue.c
10
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",
|
||||
|
@ -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])))
|
||||
|
6
poll.c
6
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",
|
||||
|
@ -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);
|
||||
|
6
select.c
6
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",
|
||||
|
@ -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]);
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
|
@ -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;" */
|
||||
|
@ -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
|
||||
|
@ -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",
|
||||
|
Loading…
x
Reference in New Issue
Block a user