From 52322a3367a91678a82eeba11c72fc7b5888d952 Mon Sep 17 00:00:00 2001 From: Robbie Harwood Date: Aug 03 2017 17:59:55 +0000 Subject: Fix all compile warnings --- diff --git a/Add-Travis-support.patch b/Add-Travis-support.patch new file mode 100644 index 0000000..756033d --- /dev/null +++ b/Add-Travis-support.patch @@ -0,0 +1,67 @@ +From 695322c08c4031d873cd04a4bc7d7589b83368ac Mon Sep 17 00:00:00 2001 +From: Robbie Harwood +Date: Wed, 2 Aug 2017 16:58:44 -0400 +Subject: [PATCH] Add Travis support + +(cherry picked from commit caf08f984596eeb77fdcb80009951f201e03b370) +--- + .travis.sh | 23 +++++++++++++++++++++++ + .travis.yml | 19 +++++++++++++++++++ + 2 files changed, 42 insertions(+) + create mode 100755 .travis.sh + create mode 100644 .travis.yml + +diff --git a/.travis.sh b/.travis.sh +new file mode 100755 +index 0000000..e404e9a +--- /dev/null ++++ b/.travis.sh +@@ -0,0 +1,23 @@ ++#!/bin/bash -ex ++ ++if [ -f /etc/debian_version ]; then ++ apt-get update ++ apt-get -y install autoconf build-essential libtool \ ++ 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 \ ++ {glib2,libevent,libev}-devel ++elif [ -f /etc/redhat-release ]; then ++ # rhel/centos ++ yum -y install autoconf automake libtool make \ ++ {glib2,libevent}-devel ++else ++ echo "Distro not found!" ++ false ++fi ++ ++autoreconf -fiv ++./configure ++make ++make check +diff --git a/.travis.yml b/.travis.yml +new file mode 100644 +index 0000000..4c63f28 +--- /dev/null ++++ b/.travis.yml +@@ -0,0 +1,19 @@ ++sudo: required ++ ++# not necessary, but less confusing if defined ++language: C ++ ++services: ++ - docker ++ ++env: ++ - DISTRO=debian:sid ++ - DISTRO=fedora:rawhide ++ - DISTRO=centos:7 ++ ++script: ++ - > ++ docker run ++ -v `pwd`:/tmp/build ++ -w /tmp/build ++ $DISTRO /bin/bash -ex .travis.sh diff --git a/Add-a-CI-target-for-clang.patch b/Add-a-CI-target-for-clang.patch new file mode 100644 index 0000000..98d2198 --- /dev/null +++ b/Add-a-CI-target-for-clang.patch @@ -0,0 +1,57 @@ +From 3d0272265e89adfcc790d697d07cbc42be1b7b2e Mon Sep 17 00:00:00 2001 +From: Robbie Harwood +Date: Wed, 2 Aug 2017 18:48:02 -0400 +Subject: [PATCH] Add a CI target for clang + +(cherry picked from commit b1cb74d3db1f6377508282d0d98e197b5c654295) +--- + .travis.sh | 6 +++--- + .travis.yml | 8 +++++--- + 2 files changed, 8 insertions(+), 6 deletions(-) + +diff --git a/.travis.sh b/.travis.sh +index e404e9a..3be21ac 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 \ ++ apt-get -y install autoconf build-essential libtool $CC \ + 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 \ ++ dnf -y install autoconf automake libtool make $CC \ + {glib2,libevent,libev}-devel + elif [ -f /etc/redhat-release ]; then + # rhel/centos +- yum -y install autoconf automake libtool make \ ++ yum -y install autoconf automake libtool make $CC \ + {glib2,libevent}-devel + else + echo "Distro not found!" +diff --git a/.travis.yml b/.travis.yml +index 4c63f28..0def685 100644 +--- a/.travis.yml ++++ b/.travis.yml +@@ -7,13 +7,15 @@ services: + - docker + + env: +- - DISTRO=debian:sid +- - DISTRO=fedora:rawhide +- - DISTRO=centos:7 ++ - DISTRO=debian:sid CC=gcc ++ - DISTRO=fedora:rawhide CC=gcc ++ - DISTRO=fedora:rawhide CC=clang ++ - DISTRO=centos:7 CC=gcc + + script: + - > + docker run + -v `pwd`:/tmp/build + -w /tmp/build ++ -e CC=$CC + $DISTRO /bin/bash -ex .travis.sh diff --git a/Enable-and-fix-all-warnings.patch b/Enable-and-fix-all-warnings.patch new file mode 100644 index 0000000..2cc98dc --- /dev/null +++ b/Enable-and-fix-all-warnings.patch @@ -0,0 +1,362 @@ +From 58c68cae4db04a25f567c61be7d1d70543aa56a2 Mon Sep 17 00:00:00 2001 +From: Robbie Harwood +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 + #include + #include +@@ -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 + #include + #include +@@ -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 + 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 + #include + #include ++#include + + #include + +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]); diff --git a/libverto.spec b/libverto.spec index bcfa69a..a3127e2 100644 --- a/libverto.spec +++ b/libverto.spec @@ -2,7 +2,7 @@ Name: libverto Version: 0.2.6 -Release: 9%{?dist} +Release: 10%{?dist} Summary: Main loop abstraction library License: MIT @@ -196,6 +196,9 @@ find $RPM_BUILD_ROOT -name '*.la' -exec rm -f {} ';' %endif %changelog +* Thu Aug 03 2017 Robbie Harwood - 0.2.6-10 +- Fix all compile warnings + * Tue Aug 01 2017 Robbie Harwood - 0.2.6-9 - Update upstream URLs (no functional changes) - Move to autosetup