svn commit: r360073 - head/tests/sys/kqueue/libkqueue

Alexander Richardson arichardson at freebsd.org
Sat Apr 18 20:43:29 UTC 2020


On Sat, 18 Apr 2020 at 20:13, Conrad Meyer <cem at freebsd.org> wrote:
>
> Hi Alex,
>
> We usually do not use "extern" for function declarations in headers.
>
> Best,
> Conrad

Hi Conrad,

I decided to follow the style that was used in the header already, but
I agree those externs should probably be dropped.
I can commit a follow-up change to remove them on Monday.

Alex

>
> On Sat, Apr 18, 2020 at 5:55 AM Alex Richardson <arichardson at freebsd.org> wrote:
> >
> > Author: arichardson
> > Date: Sat Apr 18 12:54:47 2020
> > New Revision: 360073
> > URL: https://svnweb.freebsd.org/changeset/base/360073
> >
> > Log:
> >   Fix various warnings in tests/sys/kqueue and bump WARNS
> >
> >   Reviewed By:  kevans
> >   Differential Revision: https://reviews.freebsd.org/D24296
> >
> > Modified:
> >   head/tests/sys/kqueue/libkqueue/Makefile
> >   head/tests/sys/kqueue/libkqueue/common.h
> >   head/tests/sys/kqueue/libkqueue/main.c
> >   head/tests/sys/kqueue/libkqueue/proc.c
> >   head/tests/sys/kqueue/libkqueue/read.c
> >   head/tests/sys/kqueue/libkqueue/signal.c
> >   head/tests/sys/kqueue/libkqueue/timer.c
> >   head/tests/sys/kqueue/libkqueue/user.c
> >   head/tests/sys/kqueue/libkqueue/vnode.c
> >
> > Modified: head/tests/sys/kqueue/libkqueue/Makefile
> > ==============================================================================
> > --- head/tests/sys/kqueue/libkqueue/Makefile    Sat Apr 18 12:54:40 2020        (r360072)
> > +++ head/tests/sys/kqueue/libkqueue/Makefile    Sat Apr 18 12:54:47 2020        (r360073)
> > @@ -16,6 +16,5 @@ SRCS.kqtest=          \
> >         proc.c          \
> >         signal.c        \
> >         user.c
> > -WARNS?=        2
> >
> >  .include <bsd.test.mk>
> >
> > Modified: head/tests/sys/kqueue/libkqueue/common.h
> > ==============================================================================
> > --- head/tests/sys/kqueue/libkqueue/common.h    Sat Apr 18 12:54:40 2020        (r360072)
> > +++ head/tests/sys/kqueue/libkqueue/common.h    Sat Apr 18 12:54:47 2020        (r360073)
> > @@ -40,7 +40,6 @@
> >
> >  #include <sys/event.h>
> >
> > -extern char *cur_test_id;
> >  extern int vnode_fd;
> >  extern int kqfd;
> >
> > @@ -76,5 +75,14 @@ extern void test_no_kevents_quietly(void);
> >
> >  extern void test_begin(const char *);
> >  extern void success(void);
> > +
> > +extern void test_evfilt_read(void);
> > +extern void test_evfilt_signal(void);
> > +extern void test_evfilt_vnode(void);
> > +extern void test_evfilt_timer(void);
> > +extern void test_evfilt_proc(void);
> > +#if HAVE_EVFILT_USER
> > +extern void test_evfilt_user(void);
> > +#endif
> >
> >  #endif  /* _COMMON_H */
> >
> > Modified: head/tests/sys/kqueue/libkqueue/main.c
> > ==============================================================================
> > --- head/tests/sys/kqueue/libkqueue/main.c      Sat Apr 18 12:54:40 2020        (r360072)
> > +++ head/tests/sys/kqueue/libkqueue/main.c      Sat Apr 18 12:54:47 2020        (r360073)
> > @@ -21,21 +21,12 @@
> >  #include "config.h"
> >  #include "common.h"
> >
> > -int testnum = 1;
> > -char *cur_test_id = NULL;
> >  int kqfd;
> > +static char *cur_test_id = NULL;
> > +static int testnum = 1;
> >
> > -extern void test_evfilt_read();
> > -extern void test_evfilt_signal();
> > -extern void test_evfilt_vnode();
> > -extern void test_evfilt_timer();
> > -extern void test_evfilt_proc();
> > -#if HAVE_EVFILT_USER
> > -extern void test_evfilt_user();
> > -#endif
> > -
> >  /* Checks if any events are pending, which is an error. */
> > -void
> > +void
> >  test_no_kevents(void)
> >  {
> >      int nfds;
> > @@ -58,7 +49,7 @@ test_no_kevents(void)
> >  /* Checks if any events are pending, which is an error. Do not print
> >   * out anything unless events are found.
> >  */
> > -void
> > +void
> >  test_no_kevents_quietly(void)
> >  {
> >      int nfds;
> > @@ -79,7 +70,7 @@ test_no_kevents_quietly(void)
> >
> >  /* Retrieve a single kevent */
> >  struct kevent *
> > -kevent_get(int kqfd)
> > +kevent_get(int fd)
> >  {
> >      int nfds;
> >      struct kevent *kev;
> > @@ -87,7 +78,7 @@ kevent_get(int kqfd)
> >      if ((kev = calloc(1, sizeof(*kev))) == NULL)
> >          err(1, "out of memory");
> >
> > -    nfds = kevent(kqfd, NULL, 0, kev, 1, NULL);
> > +    nfds = kevent(fd, NULL, 0, kev, 1, NULL);
> >      if (nfds < 1)
> >          err(1, "kevent(2)");
> >
> > @@ -96,7 +87,7 @@ kevent_get(int kqfd)
> >
> >  /* Retrieve a single kevent, specifying a maximum time to wait for it. */
> >  struct kevent *
> > -kevent_get_timeout(int kqfd, int seconds)
> > +kevent_get_timeout(int fd, int seconds)
> >  {
> >      int nfds;
> >      struct kevent *kev;
> > @@ -105,7 +96,7 @@ kevent_get_timeout(int kqfd, int seconds)
> >      if ((kev = calloc(1, sizeof(*kev))) == NULL)
> >          err(1, "out of memory");
> >
> > -    nfds = kevent(kqfd, NULL, 0, kev, 1, &timeout);
> > +    nfds = kevent(fd, NULL, 0, kev, 1, &timeout);
> >      if (nfds < 0) {
> >          err(1, "kevent(2)");
> >      } else if (nfds == 0) {
> > @@ -116,7 +107,7 @@ kevent_get_timeout(int kqfd, int seconds)
> >      return (kev);
> >  }
> >
> > -char *
> > +static char *
> >  kevent_fflags_dump(struct kevent *kev)
> >  {
> >      char *buf;
> > @@ -166,7 +157,7 @@ kevent_fflags_dump(struct kevent *kev)
> >      return (buf);
> >  }
> >
> > -char *
> > +static char *
> >  kevent_flags_dump(struct kevent *kev)
> >  {
> >      char *buf;
> > @@ -227,7 +218,7 @@ kevent_to_str(struct kevent *kev)
> >  }
> >
> >  void
> > -kevent_add(int kqfd, struct kevent *kev,
> > +kevent_add(int fd, struct kevent *kev,
> >          uintptr_t ident,
> >          short     filter,
> >          u_short   flags,
> > @@ -237,8 +228,8 @@ kevent_add(int kqfd, struct kevent *kev,
> >  {
> >      char *kev_str;
> >
> > -    EV_SET(kev, ident, filter, flags, fflags, data, NULL);
> > -    if (kevent(kqfd, kev, 1, NULL, 0, NULL) < 0) {
> > +    EV_SET(kev, ident, filter, flags, fflags, data, udata);
> > +    if (kevent(fd, kev, 1, NULL, 0, NULL) < 0) {
> >          kev_str = kevent_to_str(kev);
> >          printf("Unable to add the following kevent:\n%s\n",
> >                  kev_str);
> > @@ -295,7 +286,7 @@ success(void)
> >      cur_test_id = NULL;
> >  }
> >
> > -void
> > +static void
> >  test_kqueue(void)
> >  {
> >      test_begin("kqueue()");
> > @@ -305,7 +296,7 @@ test_kqueue(void)
> >      success();
> >  }
> >
> > -void
> > +static void
> >  test_kqueue_close(void)
> >  {
> >      test_begin("close(kq)");
> >
> > Modified: head/tests/sys/kqueue/libkqueue/proc.c
> > ==============================================================================
> > --- head/tests/sys/kqueue/libkqueue/proc.c      Sat Apr 18 12:54:40 2020        (r360072)
> > +++ head/tests/sys/kqueue/libkqueue/proc.c      Sat Apr 18 12:54:47 2020        (r360073)
> > @@ -27,7 +27,7 @@ static int sigusr1_caught = 0;
> >
> >
> >  static void
> > -sig_handler(int signum)
> > +sig_handler(__unused int signum)
> >  {
> >      sigusr1_caught = 1;
> >  }
> > @@ -203,10 +203,10 @@ proc_track(int sleep_time)
> >                  }
> >
> >                  if (kevp->fflags & NOTE_EXIT) {
> > -                    if ((kevp->ident == pid) && (!child_exit)) {
> > +                    if ((kevp->ident == (uintptr_t)pid) && (!child_exit)) {
> >                          ++child_exit;
> >                          ++handled;
> > -                    } else if ((kevp->ident == gchild_pid) && (!gchild_exit)) {
> > +                    } else if ((kevp->ident == (uintptr_t)gchild_pid) && (!gchild_exit)) {
> >                          ++gchild_exit;
> >                          ++handled;
> >                      } else {
> > @@ -215,7 +215,7 @@ proc_track(int sleep_time)
> >                  }
> >
> >                  if (kevp->fflags & NOTE_FORK) {
> > -                    if ((kevp->ident == pid) && (!child_fork)) {
> > +                    if ((kevp->ident == (uintptr_t)pid) && (!child_fork)) {
> >                          ++child_fork;
> >                          ++handled;
> >                      } else {
> > @@ -273,7 +273,7 @@ event_trigger(void)
> >      success();
> >  }
> >
> > -void
> > +static void
> >  test_kevent_signal_disable(void)
> >  {
> >      const char *test_id = "kevent(EVFILT_SIGNAL, EV_DISABLE)";
> > @@ -397,7 +397,7 @@ test_kevent_signal_oneshot(void)
> >  #endif
> >
> >  void
> > -test_evfilt_proc()
> > +test_evfilt_proc(void)
> >  {
> >      kqfd = kqueue();
> >
> >
> > Modified: head/tests/sys/kqueue/libkqueue/read.c
> > ==============================================================================
> > --- head/tests/sys/kqueue/libkqueue/read.c      Sat Apr 18 12:54:40 2020        (r360072)
> > +++ head/tests/sys/kqueue/libkqueue/read.c      Sat Apr 18 12:54:47 2020        (r360073)
> > @@ -18,7 +18,7 @@
> >
> >  #include "common.h"
> >
> > -int sockfd[2];
> > +static int sockfd[2];
> >
> >  static void
> >  kevent_socket_drain(void)
> > @@ -40,7 +40,7 @@ kevent_socket_fill(void)
> >  }
> >
> >
> > -void
> > +static void
> >  test_kevent_socket_add(void)
> >  {
> >      const char *test_id = "kevent(EVFILT_READ, EV_ADD)";
> > @@ -54,7 +54,7 @@ test_kevent_socket_add(void)
> >      success();
> >  }
> >
> > -void
> > +static void
> >  test_kevent_socket_get(void)
> >  {
> >      const char *test_id = "kevent(EVFILT_READ) wait";
> > @@ -81,7 +81,7 @@ test_kevent_socket_get(void)
> >      success();
> >  }
> >
> > -void
> > +static void
> >  test_kevent_socket_clear(void)
> >  {
> >      const char *test_id = "kevent(EVFILT_READ, EV_CLEAR)";
> > @@ -115,7 +115,7 @@ test_kevent_socket_clear(void)
> >      success();
> >  }
> >
> > -void
> > +static void
> >  test_kevent_socket_disable_and_enable(void)
> >  {
> >      const char *test_id = "kevent(EVFILT_READ, EV_DISABLE)";
> > @@ -153,7 +153,7 @@ test_kevent_socket_disable_and_enable(void)
> >      success();
> >  }
> >
> > -void
> > +static void
> >  test_kevent_socket_del(void)
> >  {
> >      const char *test_id = "kevent(EVFILT_READ, EV_DELETE)";
> > @@ -172,7 +172,7 @@ test_kevent_socket_del(void)
> >      success();
> >  }
> >
> > -void
> > +static void
> >  test_kevent_socket_oneshot(void)
> >  {
> >      const char *test_id = "kevent(EVFILT_READ, EV_ONESHOT)";
> > @@ -207,7 +207,7 @@ test_kevent_socket_oneshot(void)
> >
> >
> >  #if HAVE_EV_DISPATCH
> > -void
> > +static void
> >  test_kevent_socket_dispatch(void)
> >  {
> >      const char *test_id = "kevent(EVFILT_READ, EV_DISPATCH)";
> > @@ -242,7 +242,7 @@ test_kevent_socket_dispatch(void)
> >  #endif  /* HAVE_EV_DISPATCH */
> >
> >  #if BROKEN
> > -void
> > +static void
> >  test_kevent_socket_lowat(void)
> >  {
> >      const char *test_id = "kevent(EVFILT_READ, NOTE_LOWAT)";
> > @@ -275,7 +275,7 @@ test_kevent_socket_lowat(void)
> >  }
> >  #endif
> >
> > -void
> > +static void
> >  test_kevent_socket_eof(void)
> >  {
> >      const char *test_id = "kevent(EVFILT_READ, EV_EOF)";
> > @@ -304,7 +304,7 @@ test_kevent_socket_eof(void)
> >  }
> >
> >  void
> > -test_evfilt_read()
> > +test_evfilt_read(void)
> >  {
> >      /* Create a connected pair of full-duplex sockets for testing socket events */
> >      if (socketpair(AF_UNIX, SOCK_STREAM, 0, sockfd) < 0)
> >
> > Modified: head/tests/sys/kqueue/libkqueue/signal.c
> > ==============================================================================
> > --- head/tests/sys/kqueue/libkqueue/signal.c    Sat Apr 18 12:54:40 2020        (r360072)
> > +++ head/tests/sys/kqueue/libkqueue/signal.c    Sat Apr 18 12:54:47 2020        (r360073)
> > @@ -19,7 +19,7 @@
> >  #include "common.h"
> >
> >
> > -void
> > +static void
> >  test_kevent_signal_add(void)
> >  {
> >      const char *test_id = "kevent(EVFILT_SIGNAL, EV_ADD)";
> > @@ -34,7 +34,7 @@ test_kevent_signal_add(void)
> >      success();
> >  }
> >
> > -void
> > +static void
> >  test_kevent_signal_get(void)
> >  {
> >      const char *test_id = "kevent(EVFILT_SIGNAL, wait)";
> > @@ -62,7 +62,7 @@ test_kevent_signal_get(void)
> >      success();
> >  }
> >
> > -void
> > +static void
> >  test_kevent_signal_disable(void)
> >  {
> >      const char *test_id = "kevent(EVFILT_SIGNAL, EV_DISABLE)";
> > @@ -88,7 +88,7 @@ test_kevent_signal_disable(void)
> >      success();
> >  }
> >
> > -void
> > +static void
> >  test_kevent_signal_enable(void)
> >  {
> >      const char *test_id = "kevent(EVFILT_SIGNAL, EV_ENABLE)";
> > @@ -125,7 +125,7 @@ test_kevent_signal_enable(void)
> >      success();
> >  }
> >
> > -void
> > +static void
> >  test_kevent_signal_del(void)
> >  {
> >      const char *test_id = "kevent(EVFILT_SIGNAL, EV_DELETE)";
> > @@ -151,7 +151,7 @@ test_kevent_signal_del(void)
> >      success();
> >  }
> >
> > -void
> > +static void
> >  test_kevent_signal_oneshot(void)
> >  {
> >      const char *test_id = "kevent(EVFILT_SIGNAL, EV_ONESHOT)";
> > @@ -185,7 +185,7 @@ test_kevent_signal_oneshot(void)
> >  }
> >
> >  void
> > -test_evfilt_signal()
> > +test_evfilt_signal(void)
> >  {
> >      kqfd = kqueue();
> >      test_kevent_signal_add();
> >
> > Modified: head/tests/sys/kqueue/libkqueue/timer.c
> > ==============================================================================
> > --- head/tests/sys/kqueue/libkqueue/timer.c     Sat Apr 18 12:54:40 2020        (r360072)
> > +++ head/tests/sys/kqueue/libkqueue/timer.c     Sat Apr 18 12:54:47 2020        (r360073)
> > @@ -42,7 +42,7 @@ now(void)
> >  /* Sleep for a given number of milliseconds. The timeout is assumed to
> >   * be less than 1 second.
> >   */
> > -void
> > +static void
> >  mssleep(int t)
> >  {
> >      struct timespec stime = {
> > @@ -56,7 +56,7 @@ mssleep(int t)
> >  /* Sleep for a given number of microseconds. The timeout is assumed to
> >   * be less than 1 second.
> >   */
> > -void
> > +static void
> >  ussleep(int t)
> >  {
> >      struct timespec stime = {
> > @@ -67,7 +67,7 @@ ussleep(int t)
> >      nanosleep(&stime, NULL);
> >  }
> >
> > -void
> > +static void
> >  test_kevent_timer_add(void)
> >  {
> >      const char *test_id = "kevent(EVFILT_TIMER, EV_ADD)";
> > @@ -82,7 +82,7 @@ test_kevent_timer_add(void)
> >      success();
> >  }
> >
> > -void
> > +static void
> >  test_kevent_timer_del(void)
> >  {
> >      const char *test_id = "kevent(EVFILT_TIMER, EV_DELETE)";
> > @@ -99,7 +99,7 @@ test_kevent_timer_del(void)
> >      success();
> >  }
> >
> > -void
> > +static void
> >  test_kevent_timer_get(void)
> >  {
> >      const char *test_id = "kevent(EVFILT_TIMER, wait)";
> > @@ -509,7 +509,7 @@ test_update_timing(void)
> >  }
> >
> >  void
> > -test_evfilt_timer()
> > +test_evfilt_timer(void)
> >  {
> >      kqfd = kqueue();
> >      test_kevent_timer_add();
> >
> > Modified: head/tests/sys/kqueue/libkqueue/user.c
> > ==============================================================================
> > --- head/tests/sys/kqueue/libkqueue/user.c      Sat Apr 18 12:54:40 2020        (r360072)
> > +++ head/tests/sys/kqueue/libkqueue/user.c      Sat Apr 18 12:54:47 2020        (r360073)
> > @@ -114,7 +114,7 @@ oneshot(void)
> >  }
> >
> >  void
> > -test_evfilt_user()
> > +test_evfilt_user(void)
> >  {
> >      kqfd = kqueue();
> >
> >
> > Modified: head/tests/sys/kqueue/libkqueue/vnode.c
> > ==============================================================================
> > --- head/tests/sys/kqueue/libkqueue/vnode.c     Sat Apr 18 12:54:40 2020        (r360072)
> > +++ head/tests/sys/kqueue/libkqueue/vnode.c     Sat Apr 18 12:54:47 2020        (r360073)
> > @@ -20,7 +20,7 @@
> >
> >  int vnode_fd;
> >
> > -void
> > +static void
> >  test_kevent_vnode_add(void)
> >  {
> >      const char *test_id = "kevent(EVFILT_VNODE, EV_ADD)";
> > @@ -44,7 +44,7 @@ test_kevent_vnode_add(void)
> >      success();
> >  }
> >
> > -void
> > +static void
> >  test_kevent_vnode_note_delete(void)
> >  {
> >      const char *test_id = "kevent(EVFILT_VNODE, NOTE_DELETE)";
> > @@ -64,7 +64,7 @@ test_kevent_vnode_note_delete(void)
> >      success();
> >  }
> >
> > -void
> > +static void
> >  test_kevent_vnode_note_write(void)
> >  {
> >      const char *test_id = "kevent(EVFILT_VNODE, NOTE_WRITE)";
> > @@ -88,7 +88,7 @@ test_kevent_vnode_note_write(void)
> >      success();
> >  }
> >
> > -void
> > +static void
> >  test_kevent_vnode_note_attrib(void)
> >  {
> >      const char *test_id = "kevent(EVFILT_VNODE, NOTE_ATTRIB)";
> > @@ -107,7 +107,7 @@ test_kevent_vnode_note_attrib(void)
> >      nfds = kevent(kqfd, NULL, 0, &kev, 1, NULL);
> >      if (nfds < 1)
> >          err(1, "%s", test_id);
> > -    if (kev.ident != vnode_fd ||
> > +    if (kev.ident != (uintptr_t)vnode_fd ||
> >              kev.filter != EVFILT_VNODE ||
> >              kev.fflags != NOTE_ATTRIB)
> >          err(1, "%s - incorrect event (sig=%u; filt=%d; flags=%d)",
> > @@ -116,7 +116,7 @@ test_kevent_vnode_note_attrib(void)
> >      success();
> >  }
> >
> > -void
> > +static void
> >  test_kevent_vnode_note_rename(void)
> >  {
> >      const char *test_id = "kevent(EVFILT_VNODE, NOTE_RENAME)";
> > @@ -135,7 +135,7 @@ test_kevent_vnode_note_rename(void)
> >      nfds = kevent(kqfd, NULL, 0, &kev, 1, NULL);
> >      if (nfds < 1)
> >          err(1, "%s", test_id);
> > -    if (kev.ident != vnode_fd ||
> > +    if (kev.ident != (uintptr_t)vnode_fd ||
> >              kev.filter != EVFILT_VNODE ||
> >              kev.fflags != NOTE_RENAME)
> >          err(1, "%s - incorrect event (sig=%u; filt=%d; flags=%d)",
> > @@ -147,7 +147,7 @@ test_kevent_vnode_note_rename(void)
> >      success();
> >  }
> >
> > -void
> > +static void
> >  test_kevent_vnode_del(void)
> >  {
> >      const char *test_id = "kevent(EVFILT_VNODE, EV_DELETE)";
> > @@ -162,7 +162,7 @@ test_kevent_vnode_del(void)
> >      success();
> >  }
> >
> > -void
> > +static void
> >  test_kevent_vnode_disable_and_enable(void)
> >  {
> >      const char *test_id = "kevent(EVFILT_VNODE, EV_DISABLE and EV_ENABLE)";
> > @@ -195,7 +195,7 @@ test_kevent_vnode_disable_and_enable(void)
> >      nfds = kevent(kqfd, NULL, 0, &kev, 1, NULL);
> >      if (nfds < 1)
> >          err(1, "%s", test_id);
> > -    if (kev.ident != vnode_fd ||
> > +    if (kev.ident != (uintptr_t)vnode_fd ||
> >              kev.filter != EVFILT_VNODE ||
> >              kev.fflags != NOTE_ATTRIB)
> >          err(1, "%s - incorrect event (sig=%u; filt=%d; flags=%d)",
> > @@ -205,7 +205,7 @@ test_kevent_vnode_disable_and_enable(void)
> >  }
> >
> >  #if HAVE_EV_DISPATCH
> > -void
> > +static void
> >  test_kevent_vnode_dispatch(void)
> >  {
> >      const char *test_id = "kevent(EVFILT_VNODE, EV_DISPATCH)";
> > @@ -226,7 +226,7 @@ test_kevent_vnode_dispatch(void)
> >      nfds = kevent(kqfd, NULL, 0, &kev, 1, NULL);
> >      if (nfds < 1)
> >          err(1, "%s", test_id);
> > -    if (kev.ident != vnode_fd ||
> > +    if (kev.ident != (uintptr_t)vnode_fd ||
> >              kev.filter != EVFILT_VNODE ||
> >              kev.fflags != NOTE_ATTRIB)
> >          err(1, "%s - incorrect event (sig=%u; filt=%d; flags=%d)",
> > @@ -248,7 +248,7 @@ test_kevent_vnode_dispatch(void)
> >  #endif         /* HAVE_EV_DISPATCH */
> >
> >  void
> > -test_evfilt_vnode()
> > +test_evfilt_vnode(void)
> >  {
> >      kqfd = kqueue();
> >      test_kevent_vnode_add();


More information about the svn-src-head mailing list