Skip to content

Commit 664dc6d

Browse files
committed
Constify some internal poll_priv.h function parameters.
1 parent 5d5be51 commit 664dc6d

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

Lib/poll_plugins/epoll_priv.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ int poll_set_data(void **_ev) {
1111
return MOD_OK;
1212
}
1313

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

27-
int poll_init_pevents(void **pevents, int max_events) {
27+
int poll_init_pevents(void **pevents, const int max_events) {
2828
*pevents = memhook._calloc(max_events, sizeof(struct epoll_event));
2929
MOD_ALLOC_ASSERT(*pevents);
3030
return MOD_OK;
3131
}
3232

33-
int poll_wait(int fd, int max_events, void *pevents, int timeout) {
33+
int poll_wait(const int fd, const int max_events, void *pevents, const int timeout) {
3434
return epoll_wait(fd, (struct epoll_event *) pevents, max_events, timeout);
3535
}
3636

37-
module_poll_t *poll_recv(int idx, void *pevents) {
37+
module_poll_t *poll_recv(const int idx, void *pevents) {
3838
struct epoll_event *pev = (struct epoll_event *) pevents;
3939
return (module_poll_t *)pev[idx].data.ptr;
4040
}
@@ -46,7 +46,7 @@ int poll_destroy_pevents(void **pevents, int *max_events) {
4646
return MOD_OK;
4747
}
4848

49-
int poll_close(int fd, void **pevents, int *max_events) {
49+
int poll_close(const int fd, void **pevents, int *max_events) {
5050
poll_destroy_pevents(pevents, max_events);
5151
return close(fd);
5252
}

Lib/poll_plugins/kqueue_priv.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ int poll_set_data(void **_ev) {
1515
return MOD_OK;
1616
}
1717

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

30-
int poll_init_pevents(void **pevents, int max_events) {
30+
int poll_init_pevents(void **pevents, const int max_events) {
3131
*pevents = memhook._calloc(max_events, sizeof(struct kevent));
3232
MOD_ALLOC_ASSERT(*pevents);
3333
return MOD_OK;
3434
}
3535

36-
int poll_wait(int fd, int max_events, void *pevents, int timeout) {
36+
int poll_wait(const int fd, const int max_events, void *pevents, const int timeout) {
3737
struct timespec t = {0};
3838
t.tv_sec = timeout;
3939
return kevent(fd, NULL, 0, (struct kevent *)pevents, max_events, timeout >= 0 ? &t : NULL);
4040
}
4141

42-
module_poll_t *poll_recv(int idx, void *pevents) {
42+
module_poll_t *poll_recv(const int idx, void *pevents) {
4343
struct kevent *pev = (struct kevent *)pevents;
4444
if (pev[idx].flags & EV_ERROR) {
4545
return NULL;
@@ -54,7 +54,7 @@ int poll_destroy_pevents(void **pevents, int *max_events) {
5454
return MOD_OK;
5555
}
5656

57-
int poll_close(int fd, void **pevents, int *max_events) {
57+
int poll_close(const int fd, void **pevents, int *max_events) {
5858
poll_destroy_pevents(pevents, max_events);
5959
return close(fd);
6060
}

Lib/poll_priv.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ enum op_type { ADD, RM };
1010

1111
int poll_create(void);
1212
int poll_set_data(void **_ev);
13-
int poll_set_new_evt(module_poll_t *tmp, m_context *c, enum op_type flag);
14-
int poll_init_pevents(void **pevents, int max_events);
15-
int poll_wait(int fd, int max_events, void *pevents, int timeout);
16-
module_poll_t *poll_recv(int idx, void *pevents);
13+
int poll_set_new_evt(module_poll_t *tmp, m_context *c, const enum op_type flag);
14+
int poll_init_pevents(void **pevents, const int max_events);
15+
int poll_wait(const int fd, const int max_events, void *pevents, const int timeout);
16+
module_poll_t *poll_recv(const int idx, void *pevents);
1717
int poll_destroy_pevents(void **pevents, int *max_events);
18-
int poll_close(int fd, void **pevents, int *max_events);
18+
int poll_close(const int fd, void **pevents, int *max_events);

0 commit comments

Comments
 (0)