363 lines
9.2 KiB
Diff
363 lines
9.2 KiB
Diff
From 58c68cae4db04a25f567c61be7d1d70543aa56a2 Mon Sep 17 00:00:00 2001
|
|
From: Robbie Harwood <rharwood@redhat.com>
|
|
Date: Wed, 2 Aug 2017 18:42:57 -0400
|
|
Subject: [PATCH] Enable (and fix) all warnings
|
|
|
|
(cherry picked from commit 11366334b528f99c38c1323b428de9578691ff7d)
|
|
---
|
|
.travis.sh | 8 ++++----
|
|
.travis.yml | 10 +++++-----
|
|
configure.ac | 5 +++++
|
|
src/module.c | 6 ++++--
|
|
src/verto-glib.c | 10 +++++++++-
|
|
src/verto-libev.c | 5 +++++
|
|
src/verto-libevent.c | 5 +++++
|
|
src/verto.c | 4 ++--
|
|
src/verto.h | 1 +
|
|
tests/child.c | 9 +++++++++
|
|
tests/idle.c | 4 ++++
|
|
tests/read.c | 2 ++
|
|
tests/signal.c | 3 +++
|
|
tests/test.h | 1 +
|
|
tests/timeout.c | 1 +
|
|
tests/write.c | 2 ++
|
|
16 files changed, 62 insertions(+), 14 deletions(-)
|
|
|
|
diff --git a/.travis.sh b/.travis.sh
|
|
index 3be21ac..d8fe415 100755
|
|
--- a/.travis.sh
|
|
+++ b/.travis.sh
|
|
@@ -2,15 +2,15 @@
|
|
|
|
if [ -f /etc/debian_version ]; then
|
|
apt-get update
|
|
- apt-get -y install autoconf build-essential libtool $CC \
|
|
+ apt-get -y install autoconf build-essential libtool $COMPILER \
|
|
lib{ev,event,glib2.0}-dev
|
|
elif [ -f /etc/fedora-release ]; then
|
|
# dnf has no update-only verb
|
|
- dnf -y install autoconf automake libtool make $CC \
|
|
+ dnf -y install autoconf automake libtool make which $COMPILER \
|
|
{glib2,libevent,libev}-devel
|
|
elif [ -f /etc/redhat-release ]; then
|
|
# rhel/centos
|
|
- yum -y install autoconf automake libtool make $CC \
|
|
+ yum -y install autoconf automake libtool make which $COMPILER \
|
|
{glib2,libevent}-devel
|
|
else
|
|
echo "Distro not found!"
|
|
@@ -18,6 +18,6 @@ else
|
|
fi
|
|
|
|
autoreconf -fiv
|
|
-./configure
|
|
+./configure CFLAGS=-Werror CC=$(which $COMPILER)
|
|
make
|
|
make check
|
|
diff --git a/.travis.yml b/.travis.yml
|
|
index 0def685..bda4236 100644
|
|
--- a/.travis.yml
|
|
+++ b/.travis.yml
|
|
@@ -7,15 +7,15 @@ services:
|
|
- docker
|
|
|
|
env:
|
|
- - DISTRO=debian:sid CC=gcc
|
|
- - DISTRO=fedora:rawhide CC=gcc
|
|
- - DISTRO=fedora:rawhide CC=clang
|
|
- - DISTRO=centos:7 CC=gcc
|
|
+ - DISTRO=debian:sid COMPILER=gcc
|
|
+ - DISTRO=fedora:rawhide COMPILER=gcc
|
|
+ - DISTRO=fedora:rawhide COMPILER=clang
|
|
+ - DISTRO=centos:7 COMPILER=gcc
|
|
|
|
script:
|
|
- >
|
|
docker run
|
|
-v `pwd`:/tmp/build
|
|
-w /tmp/build
|
|
- -e CC=$CC
|
|
+ -e COMPILER=$COMPILER
|
|
$DISTRO /bin/bash -ex .travis.sh
|
|
diff --git a/configure.ac b/configure.ac
|
|
index d109617..db3a9c3 100644
|
|
--- a/configure.ac
|
|
+++ b/configure.ac
|
|
@@ -3,6 +3,11 @@ dnl Process this file with autoconf to produce a configure script.
|
|
AC_PREREQ(2.59)
|
|
AC_INIT(libverto, 0.2.6)
|
|
|
|
+m4_ifdef([AC_USE_SYSTEM_EXTENSIONS],
|
|
+ [AC_USE_SYSTEM_EXTENSIONS],
|
|
+ [AC_GNU_SOURCE])
|
|
+CFLAGS="$CFLAGS -Wall -Wextra"
|
|
+
|
|
AC_CANONICAL_SYSTEM
|
|
AM_INIT_AUTOMAKE([1.11])
|
|
|
|
diff --git a/src/module.c b/src/module.c
|
|
index d5977cb..1f1b7c9 100644
|
|
--- a/src/module.c
|
|
+++ b/src/module.c
|
|
@@ -86,7 +86,6 @@ dladdr(void* s, Dl_info* i)
|
|
return 0;
|
|
}
|
|
#else
|
|
-#define _GNU_SOURCE
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <dlfcn.h>
|
|
@@ -101,7 +100,10 @@ module_symbol_is_present(const char *modname, const char *symbname)
|
|
return (GetProcAddress(GetModuleHandle(modname), symbname) != NULL ||
|
|
GetProcAddress(GetModuleHandle(NULL), symbname) != NULL);
|
|
#else /* WIN32 */
|
|
- void* mod = dlopen(NULL, RTLD_LAZY | RTLD_LOCAL);
|
|
+ void *mod;
|
|
+ (void) modname;
|
|
+
|
|
+ mod = dlopen(NULL, RTLD_LAZY | RTLD_LOCAL);
|
|
if (mod) {
|
|
void* sym = dlsym(mod, symbname);
|
|
dlclose(mod);
|
|
diff --git a/src/verto-glib.c b/src/verto-glib.c
|
|
index 3136ccb..2e0c0f5 100644
|
|
--- a/src/verto-glib.c
|
|
+++ b/src/verto-glib.c
|
|
@@ -66,6 +66,8 @@ typedef struct GIOSource {
|
|
static gboolean
|
|
prepare(GSource *source, gint *timeout)
|
|
{
|
|
+ (void) source;
|
|
+
|
|
*timeout = -1;
|
|
return FALSE;
|
|
}
|
|
@@ -92,7 +94,7 @@ finalize(GSource *source)
|
|
close(src->fd.fd);
|
|
}
|
|
|
|
-static GSourceFuncs funcs = { prepare, check, dispatch, finalize };
|
|
+static GSourceFuncs funcs = { prepare, check, dispatch, finalize, NULL, NULL };
|
|
|
|
static void *
|
|
glib_convert_(GMainContext *mc, GMainLoop *ml)
|
|
@@ -195,6 +197,8 @@ glib_callback_io(gpointer data, GIOCondition condition)
|
|
static void
|
|
glib_callback_child(GPid pid, gint status, gpointer data)
|
|
{
|
|
+ (void) pid;
|
|
+
|
|
verto_set_proc_status(data, status);
|
|
verto_fire(data);
|
|
}
|
|
@@ -202,6 +206,8 @@ glib_callback_child(GPid pid, gint status, gpointer data)
|
|
static void
|
|
glib_ctx_set_flags(verto_mod_ctx *ctx, const verto_ev *ev, verto_mod_ev *evpriv)
|
|
{
|
|
+ (void) ctx;
|
|
+
|
|
if (verto_get_flags(ev) & VERTO_EV_FLAG_PRIORITY_HIGH)
|
|
g_source_set_priority(evpriv, G_PRIORITY_HIGH);
|
|
else if (verto_get_flags(ev) & VERTO_EV_FLAG_PRIORITY_MEDIUM)
|
|
@@ -296,6 +302,8 @@ glib_ctx_add(verto_mod_ctx *ctx, const verto_ev *ev, verto_ev_flag *flags)
|
|
static void
|
|
glib_ctx_del(verto_mod_ctx *ctx, const verto_ev *ev, verto_mod_ev *evpriv)
|
|
{
|
|
+ (void) ctx;
|
|
+
|
|
if (!ev)
|
|
return;
|
|
|
|
diff --git a/src/verto-libev.c b/src/verto-libev.c
|
|
index 9c7c324..99256a2 100644
|
|
--- a/src/verto-libev.c
|
|
+++ b/src/verto-libev.c
|
|
@@ -80,6 +80,11 @@ libev_callback(EV_P_ ev_watcher *w, int revents)
|
|
{
|
|
verto_ev_flag state = VERTO_EV_FLAG_NONE;
|
|
|
|
+#if EV_MULTIPLICITY
|
|
+ /* Match the check in ev.h, which doesn't mark this unused */
|
|
+ (void) EV_A;
|
|
+#endif
|
|
+
|
|
if (verto_get_type(w->data)== VERTO_EV_TYPE_CHILD)
|
|
verto_set_proc_status(w->data, ((ev_child*) w)->rstatus);
|
|
|
|
diff --git a/src/verto-libevent.c b/src/verto-libevent.c
|
|
index c8f73cd..f1f94e2 100644
|
|
--- a/src/verto-libevent.c
|
|
+++ b/src/verto-libevent.c
|
|
@@ -94,6 +94,8 @@ libevent_callback(evutil_socket_t socket, short type, void *data)
|
|
{
|
|
verto_ev_flag state = VERTO_EV_FLAG_NONE;
|
|
|
|
+ (void) socket;
|
|
+
|
|
if (type & EV_READ)
|
|
state |= VERTO_EV_FLAG_IO_READ;
|
|
if (type & EV_WRITE)
|
|
@@ -163,6 +165,9 @@ libevent_ctx_add(verto_mod_ctx *ctx, const verto_ev *ev, verto_ev_flag *flags)
|
|
static void
|
|
libevent_ctx_del(verto_mod_ctx *ctx, const verto_ev *ev, verto_mod_ev *evpriv)
|
|
{
|
|
+ (void) ctx;
|
|
+ (void) ev;
|
|
+
|
|
event_del(evpriv);
|
|
event_free(evpriv);
|
|
}
|
|
diff --git a/src/verto.c b/src/verto.c
|
|
index b14bc76..b98142d 100644
|
|
--- a/src/verto.c
|
|
+++ b/src/verto.c
|
|
@@ -22,8 +22,6 @@
|
|
* SOFTWARE.
|
|
*/
|
|
|
|
-#define _GNU_SOURCE /* For asprintf() */
|
|
-
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
@@ -496,6 +494,8 @@ remove_ev(verto_ev **origin, verto_ev *item)
|
|
static void
|
|
signal_ignore(verto_ctx *ctx, verto_ev *ev)
|
|
{
|
|
+ (void) ctx;
|
|
+ (void) ev;
|
|
}
|
|
|
|
verto_ctx *
|
|
diff --git a/src/verto.h b/src/verto.h
|
|
index 84f21a7..15fd81e 100644
|
|
--- a/src/verto.h
|
|
+++ b/src/verto.h
|
|
@@ -33,6 +33,7 @@
|
|
typedef HANDLE verto_proc;
|
|
typedef DWORD verto_proc_status;
|
|
#else
|
|
+#include <sys/types.h>
|
|
typedef pid_t verto_proc;
|
|
typedef int verto_proc_status;
|
|
#endif
|
|
diff --git a/tests/child.c b/tests/child.c
|
|
index d442cbd..286cda6 100644
|
|
--- a/tests/child.c
|
|
+++ b/tests/child.c
|
|
@@ -36,6 +36,9 @@ static int freed;
|
|
void
|
|
exit_cb(verto_ctx *ctx, verto_ev *ev)
|
|
{
|
|
+ (void) ctx;
|
|
+ (void) ev;
|
|
+
|
|
if (WEXITSTATUS(exitstatus) != EXITCODE) {
|
|
printf("ERROR: Child event never fired!\n");
|
|
retval = 1;
|
|
@@ -51,12 +54,18 @@ exit_cb(verto_ctx *ctx, verto_ev *ev)
|
|
void
|
|
onfree(verto_ctx *ctx, verto_ev *ev)
|
|
{
|
|
+ (void) ctx;
|
|
+ (void) ev;
|
|
+
|
|
freed = 1;
|
|
}
|
|
|
|
void
|
|
cb(verto_ctx *ctx, verto_ev *ev)
|
|
{
|
|
+ (void) ctx;
|
|
+ (void) ev;
|
|
+
|
|
exitstatus = verto_get_proc_status(ev);
|
|
}
|
|
|
|
diff --git a/tests/idle.c b/tests/idle.c
|
|
index f6b43b8..a0c6e48 100644
|
|
--- a/tests/idle.c
|
|
+++ b/tests/idle.c
|
|
@@ -29,6 +29,8 @@ static int callcount;
|
|
void
|
|
exit_cb(verto_ctx *ctx, verto_ev *ev)
|
|
{
|
|
+ (void) ctx;
|
|
+ (void) ev;
|
|
retval = 1;
|
|
switch (callcount) {
|
|
case 0:
|
|
@@ -55,6 +57,8 @@ exit_cb(verto_ctx *ctx, verto_ev *ev)
|
|
|
|
void
|
|
onfree(verto_ctx *ctx, verto_ev *ev) {
|
|
+ (void) ctx;
|
|
+ (void) ev;
|
|
++callcount;
|
|
}
|
|
|
|
diff --git a/tests/read.c b/tests/read.c
|
|
index 9d0bca5..51010d3 100644
|
|
--- a/tests/read.c
|
|
+++ b/tests/read.c
|
|
@@ -41,6 +41,8 @@ static int callcount = 0;
|
|
static void
|
|
timeout_cb(verto_ctx *ctx, verto_ev *ev)
|
|
{
|
|
+ (void) ev;
|
|
+
|
|
printf("ERROR: Timeout!\n");
|
|
if (fds[0] >= 0)
|
|
close(fds[0]);
|
|
diff --git a/tests/signal.c b/tests/signal.c
|
|
index 5a62ad1..47a723a 100644
|
|
--- a/tests/signal.c
|
|
+++ b/tests/signal.c
|
|
@@ -55,6 +55,9 @@ exit_cb(verto_ctx *ctx, verto_ev *ev)
|
|
void
|
|
cb(verto_ctx *ctx, verto_ev *ev)
|
|
{
|
|
+ (void) ctx;
|
|
+ (void) ev;
|
|
+
|
|
count++;
|
|
}
|
|
|
|
diff --git a/tests/test.h b/tests/test.h
|
|
index 56e3ffc..16111cf 100644
|
|
--- a/tests/test.h
|
|
+++ b/tests/test.h
|
|
@@ -27,6 +27,7 @@
|
|
#include <assert.h>
|
|
#include <signal.h>
|
|
#include <string.h>
|
|
+#include <unistd.h>
|
|
|
|
#include <verto.h>
|
|
|
|
diff --git a/tests/timeout.c b/tests/timeout.c
|
|
index 82ebd0a..4ecc45d 100644
|
|
--- a/tests/timeout.c
|
|
+++ b/tests/timeout.c
|
|
@@ -57,6 +57,7 @@ elapsed(time_t min, time_t max)
|
|
static void
|
|
exit_cb(verto_ctx *ctx, verto_ev *ev)
|
|
{
|
|
+ (void) ev;
|
|
assert(callcount == 3);
|
|
verto_break(ctx);
|
|
}
|
|
diff --git a/tests/write.c b/tests/write.c
|
|
index 0a2422c..deb59fc 100644
|
|
--- a/tests/write.c
|
|
+++ b/tests/write.c
|
|
@@ -41,6 +41,8 @@ static int callcount = 0;
|
|
static void
|
|
timeout_cb(verto_ctx *ctx, verto_ev *ev)
|
|
{
|
|
+ (void) ev;
|
|
+
|
|
printf("ERROR: Timeout!\n");
|
|
if (fds[0] >= 0)
|
|
close(fds[0]);
|