chiark / gitweb /
Warning tidy-up for FreeBSD.
authorRichard Kettlewell <rjk@greenend.org.uk>
Sun, 1 Jun 2014 13:04:08 +0000 (14:04 +0100)
committerRichard Kettlewell <rjk@greenend.org.uk>
Sun, 1 Jun 2014 13:04:08 +0000 (14:04 +0100)
- 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
disobedience/control.c
lib/event.c
lib/trackdb.c
lib/uaudio-rtp.c
server/plugin.c
server/rescan.c

index 2887733307378fa8413350a71f8ce7edca1e2ebf..1491c67cd36dbcc765c5de078ac0cb8608e6d199 100644 (file)
@@ -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.
index 1cdc190b4ea504af212a2b374925b9ee561fcdf6..663c8155c916c39541e94ca5ae649d03e92bf47e 100644 (file)
@@ -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: "<GdisorderMain>/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 = "<GdisorderMain>/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: "<GdisorderMain>/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 = "<GdisorderMain>/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: "<GdisorderMain>/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 = "<GdisorderMain>/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: "<GdisorderMain>/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 = "<GdisorderMain>/Control/Network player",
+    .on = rtp_enabled,
+    .sensitive = rtp_sensitive,
+    .action_go_on = enable_rtp,
+    .action_go_off = disable_rtp,
+    .events = "rtp-changed",
   },
 };
 
index 64f1bdb5b481a77007df9494cbda698fbdf309d9..2fe4746b3e14d35ffbeb9a9b19e15fccdbb2e87e 100644 (file)
@@ -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) {
index 7d50e2ef71f0cf71a461bf7774fd2928bf5a112e..3d3bf932f11c86e036db60dd02031459b50f3a1f 100644 (file)
@@ -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);
index b41bdda5366a56f4b9e04b91da489e5c8ae32267..8313054fbc3e43101e9afc858b28a0239fb3d907 100644 (file)
@@ -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;
 
index 6a78693da992d8e8282fd590b2eb3584f95e7766..6856e711cef57b1e2be841ebe53db2f1ce8cea55 100644 (file)
@@ -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());
index 8f2419ce9ab5919b451c58e518ab047bd57df728..bd163b4b148726bf7afbb9e7bfa3f8be946dd3cb 100644 (file)
@@ -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);
   }