From 3bd1c92fad10a504eb8283d3f8d540b4fef9831d Mon Sep 17 00:00:00 2001 Message-Id: <3bd1c92fad10a504eb8283d3f8d540b4fef9831d.1713307284.git.mdw@distorted.org.uk> From: Mark Wooding Date: Sun, 1 Jun 2014 14:04:08 +0100 Subject: [PATCH] Warning tidy-up for FreeBSD. Organization: Straylight/Edgeware From: Richard Kettlewell - if dlfunc is available use that. Allows -Werror to be re-enabled. - use modern struct member initializers - cope with FD_SETSIZE being explicitly unsigned - remove stray brackets - remove unused objects - use %ju to print sig_atomic_t, it might be bigger than int --- configure.ac | 44 +++++++++------- disobedience/control.c | 112 ++++++++++++++++++++--------------------- lib/event.c | 3 +- lib/trackdb.c | 2 +- lib/uaudio-rtp.c | 3 -- server/plugin.c | 2 +- server/rescan.c | 2 +- 7 files changed, 87 insertions(+), 81 deletions(-) diff --git a/configure.ac b/configure.ac index 2887733..1491c67 100644 --- a/configure.ac +++ b/configure.ac @@ -572,24 +572,6 @@ fi old_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS} $gcc_werror" AC_CHECK_TYPES([long long,uint32_t,uint16_t,uint8_t,intmax_t,uintmax_t]) - -# Some GCC invocations warn for converting function pointers to void *. -# This is fair enough, as it's technically forbidden, but we use dlsym() -# which can pretty much only exist if object and function pointers are -# interconvertable. So we disable -Werror if need be. -if test ! -z "$gcc_werror"; then - AC_CACHE_CHECK([whether function pointers can be converted to void * without a warning], - [rjk_cv_function_pointer_cast],[ - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT - void somefunction(void);], - [(void *)somefunction])], - [rjk_cv_function_pointer_cast=yes], - [rjk_cv_function_pointer_cast=no])]) - if test $rjk_cv_function_pointer_cast = no; then - gcc_werror="" - fi -fi - CFLAGS="${old_CFLAGS}" # gcrypt maintainers keep changing everything. Design your interface @@ -657,6 +639,13 @@ AC_CHECK_FUNCS([fdatasync],[:],[ if test ! -z "$missing_functions"; then AC_MSG_ERROR([missing functions:$missing_functions]) fi +# dlsym will do if dlfunc not available +AC_CHECK_FUNCS([dlfunc],[:],[ + AC_DEFINE([dlfunc],[dlsym],[define dlfunc to dlsym if not available]) +]) +if test ! -z "$missing_functions"; then + AC_MSG_ERROR([missing functions:$missing_functions]) +fi # Functions we can take or leave AC_CHECK_FUNCS([fls getfsstat closesocket]) @@ -707,6 +696,25 @@ if test $want_gtk = yes; then fi AM_CONDITIONAL([GTK], [test x$want_gtk = xyes]) +# Some GCC invocations warn for converting function pointers to void *. +# This is fair enough, as it's technically forbidden, but we use dlsym() +# which can pretty much only exist if object and function pointers are +# interconvertable. So we disable -Werror if need be. +if test ! -z "$gcc_werror" && test "$ac_cv_func_dlfunc" != yes; then + CFLAGS="${CFLAGS} $gcc_werror" + AC_CACHE_CHECK([whether function pointers can be converted to void * without a warning], + [rjk_cv_function_pointer_cast],[ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT + void somefunction(void);], + [(void *)somefunction])], + [rjk_cv_function_pointer_cast=yes], + [rjk_cv_function_pointer_cast=no])]) + if test $rjk_cv_function_pointer_cast = no; then + gcc_werror="" + fi + CFLAGS="${old_CFLAGS}" +fi + if test "x$GCC" = xyes; then # We need LLONG_MAX and annoyingly GCC doesn't always give it to us # by default. diff --git a/disobedience/control.c b/disobedience/control.c index 1cdc190..663c815 100644 --- a/disobedience/control.c +++ b/disobedience/control.c @@ -183,70 +183,70 @@ static int rtp_sensitive(void) { /** @brief Table of all icons */ static struct icon icons[] = { { - toggle: TRUE, - stock: TRUE, - icon: GTK_STOCK_MEDIA_PAUSE, - label: "Pause", - tip_on: "Resume playing track", - tip_off: "Pause playing track", - menuitem: "/Control/Playing", - on: pause_resume_on, - sensitive: pause_resume_sensitive, - action_go_on: disorder_eclient_pause, - action_go_off: disorder_eclient_resume, - events: "pause-changed playing-changed rights-changed playing-track-changed", - menu_invert: TRUE, + .toggle = TRUE, + .stock = TRUE, + .icon = GTK_STOCK_MEDIA_PAUSE, + .label = "Pause", + .tip_on = "Resume playing track", + .tip_off = "Pause playing track", + .menuitem = "/Control/Playing", + .on = pause_resume_on, + .sensitive = pause_resume_sensitive, + .action_go_on = disorder_eclient_pause, + .action_go_off = disorder_eclient_resume, + .events = "pause-changed playing-changed rights-changed playing-track-changed", + .menu_invert = TRUE, }, { - stock: TRUE, - icon: GTK_STOCK_STOP, - label: "Scratch", - tip_on: "Cancel playing track", - menuitem: "/Control/Scratch", - sensitive: scratch_sensitive, - action_go_off: disorder_eclient_scratch_playing, - events: "playing-track-changed rights-changed", + .stock = TRUE, + .icon = GTK_STOCK_STOP, + .label = "Scratch", + .tip_on = "Cancel playing track", + .menuitem = "/Control/Scratch", + .sensitive = scratch_sensitive, + .action_go_off = disorder_eclient_scratch_playing, + .events = "playing-track-changed rights-changed", }, { - toggle: TRUE, - stock: FALSE, - icon: "cards24.png", - label: "Random", - tip_on: "Disable random play", - tip_off: "Enable random play", - menuitem: "/Control/Random play", - on: random_enabled, - sensitive: random_sensitive, - action_go_on: disorder_eclient_random_enable, - action_go_off: disorder_eclient_random_disable, - events: "random-changed rights-changed", + .toggle = TRUE, + .stock = FALSE, + .icon = "cards24.png", + .label = "Random", + .tip_on = "Disable random play", + .tip_off = "Enable random play", + .menuitem = "/Control/Random play", + .on = random_enabled, + .sensitive = random_sensitive, + .action_go_on = disorder_eclient_random_enable, + .action_go_off = disorder_eclient_random_disable, + .events = "random-changed rights-changed", }, { - toggle: TRUE, - stock: TRUE, - icon: GTK_STOCK_MEDIA_PLAY, - label: "Play", - tip_on: "Disable play", - tip_off: "Enable play", - on: playing_enabled, - sensitive: playing_sensitive, - action_go_on: disorder_eclient_enable, - action_go_off: disorder_eclient_disable, - events: "enabled-changed rights-changed", + .toggle = TRUE, + .stock = TRUE, + .icon = GTK_STOCK_MEDIA_PLAY, + .label = "Play", + .tip_on = "Disable play", + .tip_off = "Enable play", + .on = playing_enabled, + .sensitive = playing_sensitive, + .action_go_on = disorder_eclient_enable, + .action_go_off = disorder_eclient_disable, + .events = "enabled-changed rights-changed", }, { - toggle: TRUE, - stock: TRUE, - icon: GTK_STOCK_CONNECT, - label: "RTP", - tip_on: "Stop playing network stream", - tip_off: "Play network stream", - menuitem: "/Control/Network player", - on: rtp_enabled, - sensitive: rtp_sensitive, - action_go_on: enable_rtp, - action_go_off: disable_rtp, - events: "rtp-changed", + .toggle = TRUE, + .stock = TRUE, + .icon = GTK_STOCK_CONNECT, + .label = "RTP", + .tip_on = "Stop playing network stream", + .tip_off = "Play network stream", + .menuitem = "/Control/Network player", + .on = rtp_enabled, + .sensitive = rtp_sensitive, + .action_go_on = enable_rtp, + .action_go_off = disable_rtp, + .events = "rtp-changed", }, }; diff --git a/lib/event.c b/lib/event.c index 64f1bdb..2fe4746 100644 --- a/lib/event.c +++ b/lib/event.c @@ -311,7 +311,8 @@ int ev_fd(ev_source *ev, D(("registering %s fd %d callback %p %p", modenames[mode], fd, (void *)callback, u)); - if(fd >= FD_SETSIZE) + /* FreeBSD defines FD_SETSIZE as 1024u for some reason */ + if((unsigned)fd >= FD_SETSIZE) return -1; assert(mode < ev_nmodes); if(ev->mode[mode].nfds >= ev->mode[mode].fdslots) { diff --git a/lib/trackdb.c b/lib/trackdb.c index 7d50e2e..3d3bf93 100644 --- a/lib/trackdb.c +++ b/lib/trackdb.c @@ -1254,7 +1254,7 @@ int trackdb_notice(const char *track, for(;;) { tid = trackdb_begin_transaction(); err = trackdb_notice_tid(track, path, tid); - if((err == DB_LOCK_DEADLOCK)) goto fail; + if(err == DB_LOCK_DEADLOCK) goto fail; break; fail: trackdb_abort_transaction(tid); diff --git a/lib/uaudio-rtp.c b/lib/uaudio-rtp.c index b41bdda..8313054 100644 --- a/lib/uaudio-rtp.c +++ b/lib/uaudio-rtp.c @@ -75,9 +75,6 @@ static uint16_t rtp_sequence; */ static int rtp_errors; -/** @brief Set while paused */ -static volatile int rtp_paused; - /** @brief RTP mode */ static int rtp_mode; diff --git a/server/plugin.c b/server/plugin.c index 6a78693..6856e71 100644 --- a/server/plugin.c +++ b/server/plugin.c @@ -80,7 +80,7 @@ function_t *get_plugin_function(const struct plugin *pl, const char *symbol) { function_t *f; - f = (function_t *)dlsym(pl->dlhandle, symbol); + f = (function_t *)dlfunc(pl->dlhandle, symbol); if(!f) disorder_fatal(0, "error looking up function '%s' in '%s': %s", symbol, pl->name, dlerror()); diff --git a/server/rescan.c b/server/rescan.c index 8f2419c..bd163b4 100644 --- a/server/rescan.c +++ b/server/rescan.c @@ -75,7 +75,7 @@ static void checkabort(void) { exit(0); } if(signalled) { - disorder_info("received signal %d", signalled); + disorder_info("received signal %ju", (uintmax_t)signalled); trackdb_abort_transaction(global_tid); exit(0); } -- [mdw]