Skip to content

Commit

Permalink
Constify some internal poll_priv.h function parameters.
Browse files Browse the repository at this point in the history
  • Loading branch information
FedeDP committed Mar 16, 2019
1 parent 5d5be51 commit 664dc6d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
10 changes: 5 additions & 5 deletions Lib/poll_plugins/epoll_priv.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ int poll_set_data(void **_ev) {
return MOD_OK;
}

int poll_set_new_evt(module_poll_t *tmp, m_context *c, enum op_type flag) {
int poll_set_new_evt(module_poll_t *tmp, m_context *c, const enum op_type flag) {
int f = flag == ADD ? EPOLL_CTL_ADD : EPOLL_CTL_DEL;
struct epoll_event *ev = (struct epoll_event *)tmp->ev;
ev->data.ptr = tmp;
Expand All @@ -24,17 +24,17 @@ int poll_set_new_evt(module_poll_t *tmp, m_context *c, enum op_type flag) {
return ret;
}

int poll_init_pevents(void **pevents, int max_events) {
int poll_init_pevents(void **pevents, const int max_events) {
*pevents = memhook._calloc(max_events, sizeof(struct epoll_event));
MOD_ALLOC_ASSERT(*pevents);
return MOD_OK;
}

int poll_wait(int fd, int max_events, void *pevents, int timeout) {
int poll_wait(const int fd, const int max_events, void *pevents, const int timeout) {
return epoll_wait(fd, (struct epoll_event *) pevents, max_events, timeout);
}

module_poll_t *poll_recv(int idx, void *pevents) {
module_poll_t *poll_recv(const int idx, void *pevents) {
struct epoll_event *pev = (struct epoll_event *) pevents;
return (module_poll_t *)pev[idx].data.ptr;
}
Expand All @@ -46,7 +46,7 @@ int poll_destroy_pevents(void **pevents, int *max_events) {
return MOD_OK;
}

int poll_close(int fd, void **pevents, int *max_events) {
int poll_close(const int fd, void **pevents, int *max_events) {
poll_destroy_pevents(pevents, max_events);
return close(fd);
}
10 changes: 5 additions & 5 deletions Lib/poll_plugins/kqueue_priv.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ int poll_set_data(void **_ev) {
return MOD_OK;
}

int poll_set_new_evt(module_poll_t *tmp, m_context *c, enum op_type flag) {
int poll_set_new_evt(module_poll_t *tmp, m_context *c, const enum op_type flag) {
int f = flag == ADD ? EV_ADD : EV_DELETE;
struct kevent *_ev = (struct kevent *)tmp->ev;
EV_SET(_ev, tmp->fd, EVFILT_READ, f, 0, 0, (void *)tmp);
Expand All @@ -27,19 +27,19 @@ int poll_set_new_evt(module_poll_t *tmp, m_context *c, enum op_type flag) {
return ret;
}

int poll_init_pevents(void **pevents, int max_events) {
int poll_init_pevents(void **pevents, const int max_events) {
*pevents = memhook._calloc(max_events, sizeof(struct kevent));
MOD_ALLOC_ASSERT(*pevents);
return MOD_OK;
}

int poll_wait(int fd, int max_events, void *pevents, int timeout) {
int poll_wait(const int fd, const int max_events, void *pevents, const int timeout) {
struct timespec t = {0};
t.tv_sec = timeout;
return kevent(fd, NULL, 0, (struct kevent *)pevents, max_events, timeout >= 0 ? &t : NULL);
}

module_poll_t *poll_recv(int idx, void *pevents) {
module_poll_t *poll_recv(const int idx, void *pevents) {
struct kevent *pev = (struct kevent *)pevents;
if (pev[idx].flags & EV_ERROR) {
return NULL;
Expand All @@ -54,7 +54,7 @@ int poll_destroy_pevents(void **pevents, int *max_events) {
return MOD_OK;
}

int poll_close(int fd, void **pevents, int *max_events) {
int poll_close(const int fd, void **pevents, int *max_events) {
poll_destroy_pevents(pevents, max_events);
return close(fd);
}
10 changes: 5 additions & 5 deletions Lib/poll_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ enum op_type { ADD, RM };

int poll_create(void);
int poll_set_data(void **_ev);
int poll_set_new_evt(module_poll_t *tmp, m_context *c, enum op_type flag);
int poll_init_pevents(void **pevents, int max_events);
int poll_wait(int fd, int max_events, void *pevents, int timeout);
module_poll_t *poll_recv(int idx, void *pevents);
int poll_set_new_evt(module_poll_t *tmp, m_context *c, const enum op_type flag);
int poll_init_pevents(void **pevents, const int max_events);
int poll_wait(const int fd, const int max_events, void *pevents, const int timeout);
module_poll_t *poll_recv(const int idx, void *pevents);
int poll_destroy_pevents(void **pevents, int *max_events);
int poll_close(int fd, void **pevents, int *max_events);
int poll_close(const int fd, void **pevents, int *max_events);

0 comments on commit 664dc6d

Please sign in to comment.