Skip to content

Commit

Permalink
[usb-moded] Do not disable warnings that affect code quality
Browse files Browse the repository at this point in the history
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 <simo.piiroinen@jollamobile.com>
  • Loading branch information
spiiroin committed Mar 28, 2018
1 parent cd8d5d2 commit d5cc31f
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion configure.ac
Expand Up @@ -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@:>@]),
Expand Down
2 changes: 2 additions & 0 deletions src/usb_moded-network.c
Expand Up @@ -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);

Expand Down
2 changes: 2 additions & 0 deletions src/usb_moded-trigger.c
Expand Up @@ -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();
Expand Down
4 changes: 4 additions & 0 deletions src/usb_moded-udev.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down
14 changes: 12 additions & 2 deletions src/usb_moded.c
Expand Up @@ -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 */
Expand All @@ -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");
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit d5cc31f

Please sign in to comment.