From d5cc31f38652b64a14ec70e054dbd5c06c2be28a Mon Sep 17 00:00:00 2001 From: Simo Piiroinen Date: Wed, 28 Mar 2018 14:11:09 +0300 Subject: [PATCH] [usb-moded] Do not disable warnings that affect code quality Compilation options such as: -Wno-unused-parameter and -Wno-unused-result easily hide genuine issues. Remove such relaxations and deal with issues that surface. Signed-off-by: Simo Piiroinen --- configure.ac | 2 +- src/usb_moded-network.c | 2 ++ src/usb_moded-trigger.c | 2 ++ src/usb_moded-udev.c | 4 ++++ src/usb_moded.c | 14 ++++++++++++-- 5 files changed, 21 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 67dbfbf..e5127da 100644 --- a/configure.ac +++ b/configure.ac @@ -22,7 +22,7 @@ test_gcc_flag() { # We use gnu99 instead of c99 because many have interpreted the standard # in a way that int64_t isn't defined on non-64 bit platforms. -CFLAGS="-Os -std=gnu99 -Wall -Wextra -pipe -Wold-style-definition -Wfloat-equal -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wendif-labels -Wpointer-arith -Wcast-align -Wwrite-strings -Winline -Wno-unused-parameter -finline-small-functions -Wno-unused-result -fstack-protector -D_FORTIFY_SOURCE=2 -Wl,-z,relro,-z,now -fPIE -fpie -pie" +CFLAGS="-Os -std=gnu99 -Wall -Wextra -pipe -Wold-style-definition -Wfloat-equal -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wendif-labels -Wpointer-arith -Wcast-align -Wwrite-strings -Winline -finline-small-functions -fstack-protector -D_FORTIFY_SOURCE=2 -Wl,-z,relro,-z,now -fPIE -fpie -pie" LDFLAGS="-z relro -z now" AC_ARG_ENABLE([debug], AS_HELP_STRING([--enable-debug],[Enable debug @<:@default=false@:>@]), diff --git a/src/usb_moded-network.c b/src/usb_moded-network.c index ccb635e..72e2d82 100644 --- a/src/usb_moded-network.c +++ b/src/usb_moded-network.c @@ -100,6 +100,8 @@ static int check_interface(char *interface) static char* get_interface(struct mode_list_elem *data) { + (void)data; // FIXME: why is this passed in the 1st place? + char *interface = 0; char *setting = get_network_setting(NETWORK_INTERFACE_KEY); diff --git a/src/usb_moded-trigger.c b/src/usb_moded-trigger.c index a8e4ce3..8ad73fe 100644 --- a/src/usb_moded-trigger.c +++ b/src/usb_moded-trigger.c @@ -56,6 +56,8 @@ static void udev_parse(struct udev_device *dev); static void notify_issue (gpointer data) { + (void)data; + log_debug("trigger watch destroyed\n!"); /* clean up & restart trigger */ trigger_stop(); diff --git a/src/usb_moded-udev.c b/src/usb_moded-udev.c index 68ee843..1e39b7f 100644 --- a/src/usb_moded-udev.c +++ b/src/usb_moded-udev.c @@ -70,6 +70,8 @@ static gboolean cable_connection_timeout_cb(gpointer data); static void notify_issue (gpointer data) { + (void)data; + /* we do not want to restart when we try to clean up */ if(cleanup) return; @@ -335,6 +337,8 @@ static void setup_charger_connection(void) static gboolean cable_connection_timeout_cb(gpointer data) { + (void)data; + log_debug("connect delay: timeout"); cable_connection_timeout_id = 0; diff --git a/src/usb_moded.c b/src/usb_moded.c index f8f5cfb..387ad5a 100644 --- a/src/usb_moded.c +++ b/src/usb_moded.c @@ -206,6 +206,8 @@ void set_usb_connected(gboolean connected) static gboolean set_disconnected(gpointer data) { + (void)data; + /* let usb settle */ usb_moded_sleep(1); /* only disconnect for real if we are actually still disconnected */ @@ -229,6 +231,8 @@ static gboolean set_disconnected(gpointer data) /* set disconnected without sending signals. */ static gboolean set_disconnected_silent(gpointer data) { + (void)data; + if(!get_usb_connection_state()) { log_debug("Resetting connection data after HUP\n"); @@ -787,6 +791,8 @@ static void usb_moded_cleanup(void) /* charging fallback handler */ static gboolean charging_fallback(gpointer data) { + (void)data; + /* if a mode has been set we don't want it changed to charging * after 5 seconds. We set it to ask, so anything different * means a mode has been set */ @@ -1372,8 +1378,12 @@ int main(int argc, char* argv[]) /* silence usb_moded_system() calls */ if( log_get_type() != LOG_TO_STDERR && log_get_level() != LOG_DEBUG ) { - freopen("/dev/null", "a", stdout); - freopen("/dev/null", "a", stderr); + if( !freopen("/dev/null", "a", stdout) ) { + log_err("can't redirect stdout: %m"); + } + if( !freopen("/dev/null", "a", stderr) ) { + log_err("can't redirect stderr: %m"); + } } #if !GLIB_CHECK_VERSION(2, 36, 0)