mirror of
https://github.com/darlinghq/darling-libkqueue.git
synced 2024-11-23 03:39:51 +00:00
Add -Wextra to CFLAGS and fix all related warnings on Linux.
This will also need to be done on Solaris. git-svn-id: svn://svn.code.sf.net/p/libkqueue/code/trunk@513 fb4e3144-bc1c-4b72-a658-5bcd248dd7f7
This commit is contained in:
parent
8f90bd7127
commit
54cafd9c68
6
TODO
6
TODO
@ -1,4 +1,10 @@
|
||||
|
||||
* Create a FILTER_DECL() macro that initializes the 'struct filter' object,
|
||||
with all members properly initialized. Then -Wno-missing-field-initializers
|
||||
can be removed from CFLAGS.
|
||||
|
||||
* Implement the knote_modify() hook for all filters.
|
||||
|
||||
* Add a dbg_printf() statement within kevent_wait() to report the value
|
||||
of the timeout.
|
||||
|
||||
|
@ -3,7 +3,7 @@ version="2.0a"
|
||||
abi_major="0"
|
||||
abi_minor="0"
|
||||
abi_version="$abi_major.$abi_minor"
|
||||
cflags="-Wall -Werror -g -O2 -std=c99 -D_XOPEN_SOURCE=600"
|
||||
cflags="-Wall -Wextra -Wno-missing-field-initializers -Werror -g -O2 -std=c99 -D_XOPEN_SOURCE=600"
|
||||
ldflags=""
|
||||
sources="src/common/filter.c src/common/knote.c src/common/map.c
|
||||
src/common/kevent.c src/common/kqueue.c"
|
||||
|
@ -31,7 +31,7 @@
|
||||
static const char *
|
||||
kevent_filter_dump(const struct kevent *kev)
|
||||
{
|
||||
static char __thread buf[64];
|
||||
static __thread char buf[64];
|
||||
|
||||
snprintf(&buf[0], sizeof(buf), "%d (%s)",
|
||||
kev->filter, filter_name(kev->filter));
|
||||
@ -41,7 +41,7 @@ kevent_filter_dump(const struct kevent *kev)
|
||||
static const char *
|
||||
kevent_fflags_dump(const struct kevent *kev)
|
||||
{
|
||||
static char __thread buf[1024];
|
||||
static __thread char buf[1024];
|
||||
|
||||
#define KEVFFL_DUMP(attrib) \
|
||||
if (kev->fflags & attrib) \
|
||||
@ -74,7 +74,7 @@ kevent_fflags_dump(const struct kevent *kev)
|
||||
static const char *
|
||||
kevent_flags_dump(const struct kevent *kev)
|
||||
{
|
||||
static char __thread buf[1024];
|
||||
static __thread char buf[1024];
|
||||
|
||||
#define KEVFL_DUMP(attrib) \
|
||||
if (kev->flags & attrib) \
|
||||
@ -101,7 +101,7 @@ kevent_flags_dump(const struct kevent *kev)
|
||||
const char *
|
||||
kevent_dump(const struct kevent *kev)
|
||||
{
|
||||
static char __thread buf[1024];
|
||||
static __thread char buf[1024];
|
||||
|
||||
snprintf((char *) &buf[0], sizeof(buf),
|
||||
"{ ident=%d, filter=%s, %s, %s, data=%d, udata=%p }",
|
||||
@ -147,7 +147,7 @@ kevent_copyin_one(struct kqueue *kq, const struct kevent *src)
|
||||
kn->kn_kq = kq;
|
||||
assert(filt->kn_create);
|
||||
if (filt->kn_create(filt, kn) < 0) {
|
||||
knote_release(filt, kn);
|
||||
knote_release(kn);
|
||||
errno = EFAULT;
|
||||
return (-1);
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ knote_new(void)
|
||||
}
|
||||
|
||||
void
|
||||
knote_release(struct filter *filt, struct knote *kn)
|
||||
knote_release(struct knote *kn)
|
||||
{
|
||||
assert (kn->kn_ref > 0);
|
||||
|
||||
@ -114,7 +114,7 @@ knote_delete(struct filter *filt, struct knote *kn)
|
||||
|
||||
kn->kn_flags |= KNFL_KNOTE_DELETED;
|
||||
|
||||
knote_release(filt, kn);
|
||||
knote_release(kn);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
@ -189,7 +189,7 @@ struct knote * knote_lookup(struct filter *, short);
|
||||
//DEADWOOD: struct knote * knote_get_by_data(struct filter *filt, intptr_t);
|
||||
struct knote * knote_new(void);
|
||||
#define knote_retain(kn) atomic_inc(&kn->kn_ref)
|
||||
void knote_release(struct filter *, struct knote *);
|
||||
void knote_release(struct knote *);
|
||||
void knote_insert(struct filter *, struct knote *);
|
||||
int knote_delete(struct filter *, struct knote *);
|
||||
int knote_init(void);
|
||||
|
@ -23,7 +23,7 @@ const struct filter evfilt_proc = EVFILT_NOTIMPL;
|
||||
* Per-thread epoll event buffer used to ferry data between
|
||||
* kevent_wait() and kevent_copyout().
|
||||
*/
|
||||
static struct epoll_event __thread epevt[MAX_KEVENT];
|
||||
static __thread struct epoll_event epevt[MAX_KEVENT];
|
||||
|
||||
const struct kqueue_vtable kqops = {
|
||||
linux_kqueue_init,
|
||||
@ -80,7 +80,7 @@ linux_kqueue_init(struct kqueue *kq)
|
||||
}
|
||||
|
||||
void
|
||||
linux_kqueue_free(struct kqueue *kq)
|
||||
linux_kqueue_free(struct kqueue *kq UNUSED)
|
||||
{
|
||||
abort();//FIXME
|
||||
}
|
||||
@ -146,7 +146,7 @@ linux_kevent_wait(
|
||||
|
||||
int
|
||||
linux_kevent_copyout(struct kqueue *kq, int nready,
|
||||
struct kevent *eventlist, int nevents)
|
||||
struct kevent *eventlist, int nevents UNUSED)
|
||||
{
|
||||
struct epoll_event *ev;
|
||||
struct filter *filt;
|
||||
@ -247,11 +247,13 @@ int
|
||||
linux_eventfd_lower(struct eventfd *e)
|
||||
{
|
||||
uint64_t cur;
|
||||
ssize_t n;
|
||||
int rv = 0;
|
||||
|
||||
/* Reset the counter */
|
||||
dbg_puts("lowering event level");
|
||||
if (read(e->ef_id, &cur, sizeof(cur)) < sizeof(cur)) {
|
||||
n = read(e->ef_id, &cur, sizeof(cur));
|
||||
if (n < 0) {
|
||||
switch (errno) {
|
||||
case EAGAIN:
|
||||
/* Not considered an error */
|
||||
@ -265,7 +267,10 @@ linux_eventfd_lower(struct eventfd *e)
|
||||
dbg_printf("read(2): %s", strerror(errno));
|
||||
rv = -1;
|
||||
}
|
||||
}
|
||||
} else if (n != sizeof(cur)) {
|
||||
dbg_puts("short read");
|
||||
rv = -1;
|
||||
}
|
||||
|
||||
return (rv);
|
||||
}
|
||||
@ -322,7 +327,7 @@ linux_get_descriptor_type(struct knote *kn)
|
||||
char *
|
||||
epoll_event_dump(struct epoll_event *evt)
|
||||
{
|
||||
static char __thread buf[128];
|
||||
static __thread char buf[128];
|
||||
|
||||
if (evt == NULL)
|
||||
return "(null)";
|
||||
|
@ -191,6 +191,9 @@ int
|
||||
evfilt_read_knote_modify(struct filter *filt, struct knote *kn,
|
||||
const struct kevent *kev)
|
||||
{
|
||||
(void) filt;
|
||||
(void) kn;
|
||||
(void) kev;
|
||||
return (-1); /* STUB */
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ signalfd_reset(int sigfd)
|
||||
|
||||
/* Discard any pending signal */
|
||||
n = read(sigfd, &sig, sizeof(sig));
|
||||
if (n < sizeof(sig)) {
|
||||
if (n < 0 || n != sizeof(sig)) {
|
||||
if (errno == EWOULDBLOCK)
|
||||
return;
|
||||
//FIXME: eintr?
|
||||
@ -94,7 +94,7 @@ errout:
|
||||
}
|
||||
|
||||
int
|
||||
evfilt_signal_copyout(struct kevent *dst, struct knote *src, void *unused)
|
||||
evfilt_signal_copyout(struct kevent *dst, struct knote *src, void *x UNUSED)
|
||||
{
|
||||
int sigfd;
|
||||
|
||||
@ -128,8 +128,9 @@ evfilt_signal_knote_create(struct filter *filt, struct knote *kn)
|
||||
}
|
||||
|
||||
int
|
||||
evfilt_signal_knote_modify(struct filter *filt, struct knote *kn,
|
||||
const struct kevent *kev)
|
||||
evfilt_signal_knote_modify(struct filter *filt UNUSED,
|
||||
struct knote *kn UNUSED,
|
||||
const struct kevent *kev UNUSED)
|
||||
{
|
||||
/* Nothing to do since the signal number does not change. */
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
||||
static char *
|
||||
itimerspec_dump(struct itimerspec *ts)
|
||||
{
|
||||
static char __thread buf[1024];
|
||||
static __thread char buf[1024];
|
||||
|
||||
snprintf(buf, sizeof(buf),
|
||||
"itimer: [ interval=%lu s %lu ns, next expire=%lu s %lu ns ]",
|
||||
@ -73,7 +73,7 @@ evfilt_timer_copyout(struct kevent *dst, struct knote *src, void *ptr)
|
||||
timer has been trigered.
|
||||
*/
|
||||
n = read(src->data.pfd, &expired, sizeof(expired));
|
||||
if (n < 0 || n < sizeof(expired)) {
|
||||
if (n != sizeof(expired)) {
|
||||
dbg_puts("invalid read from timerfd");
|
||||
expired = 1; /* Fail gracefully */
|
||||
}
|
||||
@ -122,6 +122,9 @@ int
|
||||
evfilt_timer_knote_modify(struct filter *filt, struct knote *kn,
|
||||
const struct kevent *kev)
|
||||
{
|
||||
(void)filt;
|
||||
(void)kn;
|
||||
(void)kev;
|
||||
return (0); /* STUB */
|
||||
}
|
||||
|
||||
|
@ -61,11 +61,13 @@ static int
|
||||
eventfd_lower(int evfd)
|
||||
{
|
||||
uint64_t cur;
|
||||
ssize_t n;
|
||||
int rv = 0;
|
||||
|
||||
/* Reset the counter */
|
||||
dbg_puts("lowering event level");
|
||||
if (read(evfd, &cur, sizeof(cur)) < sizeof(cur)) {
|
||||
n = read(evfd, &cur, sizeof(cur));
|
||||
if (n < 0) {
|
||||
switch (errno) {
|
||||
case EAGAIN:
|
||||
/* Not considered an error */
|
||||
@ -79,13 +81,16 @@ eventfd_lower(int evfd)
|
||||
dbg_printf("read(2): %s", strerror(errno));
|
||||
rv = -1;
|
||||
}
|
||||
}
|
||||
} else if (n != sizeof(cur)) {
|
||||
dbg_puts("short read");
|
||||
rv = -1;
|
||||
}
|
||||
|
||||
return (rv);
|
||||
}
|
||||
|
||||
int
|
||||
evfilt_user_copyout(struct kevent *dst, struct knote *src, void *ptr)
|
||||
evfilt_user_copyout(struct kevent *dst, struct knote *src, void *ptr UNUSED)
|
||||
{
|
||||
memcpy(dst, &src->kev, sizeof(*dst));
|
||||
dst->fflags &= ~NOTE_FFCTRLMASK; //FIXME: Not sure if needed
|
||||
@ -140,7 +145,7 @@ errout:
|
||||
}
|
||||
|
||||
int
|
||||
evfilt_user_knote_modify(struct filter *filt, struct knote *kn,
|
||||
evfilt_user_knote_modify(struct filter *filt UNUSED, struct knote *kn,
|
||||
const struct kevent *kev)
|
||||
{
|
||||
unsigned int ffctrl;
|
||||
|
@ -19,7 +19,7 @@
|
||||
static char *
|
||||
inotify_mask_dump(uint32_t mask)
|
||||
{
|
||||
static char __thread buf[1024];
|
||||
static __thread char buf[1024];
|
||||
|
||||
#define INEVT_MASK_DUMP(attrib) \
|
||||
if (mask & attrib) \
|
||||
@ -46,7 +46,7 @@ inotify_mask_dump(uint32_t mask)
|
||||
static char *
|
||||
inotify_event_dump(struct inotify_event *evt)
|
||||
{
|
||||
static char __thread buf[1024];
|
||||
static __thread char buf[1024];
|
||||
|
||||
snprintf(buf, sizeof(buf), "wd=%d mask=%s",
|
||||
evt->wd,
|
||||
@ -165,7 +165,7 @@ delete_watch(struct filter *filt, struct knote *kn)
|
||||
}
|
||||
|
||||
int
|
||||
evfilt_vnode_copyout(struct kevent *dst, struct knote *src, void *ptr)
|
||||
evfilt_vnode_copyout(struct kevent *dst, struct knote *src, void *ptr UNUSED)
|
||||
{
|
||||
struct inotify_event evt;
|
||||
struct stat sb;
|
||||
@ -241,6 +241,9 @@ int
|
||||
evfilt_vnode_knote_modify(struct filter *filt, struct knote *kn,
|
||||
const struct kevent *kev)
|
||||
{
|
||||
(void)filt;
|
||||
(void)kn;
|
||||
(void)kev;
|
||||
return (-1); /* FIXME - STUB */
|
||||
}
|
||||
|
||||
|
@ -87,6 +87,9 @@ int
|
||||
evfilt_socket_knote_modify(struct filter *filt, struct knote *kn,
|
||||
const struct kevent *kev)
|
||||
{
|
||||
(void) filt;
|
||||
(void) kn;
|
||||
(void) kev;
|
||||
return (-1); /* STUB */
|
||||
}
|
||||
|
||||
|
@ -17,13 +17,13 @@
|
||||
#include "../common/private.h"
|
||||
|
||||
int
|
||||
posix_kqueue_init(struct kqueue *kq)
|
||||
posix_kqueue_init(struct kqueue *kq UNUSED)
|
||||
{
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
posix_kqueue_free(struct kqueue *kq)
|
||||
posix_kqueue_free(struct kqueue *kq UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -36,6 +36,9 @@
|
||||
#define fastpath(x) __builtin_expect((x), 1)
|
||||
#define slowpath(x) __builtin_expect((x), 0)
|
||||
|
||||
/*
|
||||
* GCC-compatible attributes
|
||||
*/
|
||||
#ifdef MAKE_STATIC
|
||||
# define CONSTRUCTOR
|
||||
#else
|
||||
@ -43,6 +46,7 @@
|
||||
#endif
|
||||
#define VISIBLE __attribute__((visibility("default")))
|
||||
#define HIDDEN __attribute__((visibility("hidden")))
|
||||
#define UNUSED __attribute__((unused))
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <limits.h>
|
||||
|
Loading…
Reference in New Issue
Block a user