diff --git a/src/usb_moded-appsync.c b/src/usb_moded-appsync.c index eac7a77..4c82b2b 100644 --- a/src/usb_moded-appsync.c +++ b/src/usb_moded-appsync.c @@ -52,7 +52,7 @@ static void cancel_enumerate_usb_timer(void); static GList *sync_list = NULL; static guint enumerate_usb_id = 0; -static struct timeval sync_tv; +static struct timeval sync_tv = {0, 0}; #ifdef APP_SYNC_DBUS static int no_dbus = 0; #else diff --git a/src/usb_moded-dbus.c b/src/usb_moded-dbus.c index 06adcdd..0c8caec 100644 --- a/src/usb_moded-dbus.c +++ b/src/usb_moded-dbus.c @@ -47,8 +47,6 @@ static DBusConnection *dbus_connection_sys = NULL; static gboolean have_service_name = FALSE; -extern gboolean rescue_mode; - /** * Issues "sig_usb_config_ind" signal. */ diff --git a/src/usb_moded-modules-android.c b/src/usb_moded-modules-android.c index 630af54..dc29bd2 100644 --- a/src/usb_moded-modules-android.c +++ b/src/usb_moded-modules-android.c @@ -38,9 +38,6 @@ #include "usb_moded-config.h" #include "usb_moded-modesetting.h" -/* kmod context - initialized at start in usb_moded_init */ -struct kmod_ctx *ctx; - /** load module * * @param module Name of the module to load diff --git a/src/usb_moded-network.c b/src/usb_moded-network.c index 0b6f50d..ccb635e 100644 --- a/src/usb_moded-network.c +++ b/src/usb_moded-network.c @@ -52,7 +52,7 @@ #define UDHCP_CONFIG_DIR "/run/usb-moded" #define UDHCP_CONFIG_LINK "/etc/udhcpd.conf" -const char default_interface[] = "usb0"; +static const char default_interface[] = "usb0"; /** IP forwarding configuration block */ typedef struct ipforward_data diff --git a/src/usb_moded-trigger.c b/src/usb_moded-trigger.c index e09f346..a8e4ce3 100644 --- a/src/usb_moded-trigger.c +++ b/src/usb_moded-trigger.c @@ -47,7 +47,7 @@ static struct udev *udev = 0; static struct udev_monitor *mon = 0; static GIOChannel *iochannel = 0; static guint watch_id = 0; -static const char *dev_name; +static const char *dev_name = 0; /* static function definitions */ static gboolean monitor_udev(GIOChannel *iochannel G_GNUC_UNUSED, GIOCondition cond, diff --git a/src/usb_moded-udev.c b/src/usb_moded-udev.c index 7d86cd3..68ee843 100644 --- a/src/usb_moded-udev.c +++ b/src/usb_moded-udev.c @@ -40,10 +40,10 @@ #include "usb_moded-modes.h" /* global variables */ -static struct udev *udev; -static struct udev_monitor *mon; -static GIOChannel *iochannel; -static guint watch_id; +static struct udev *udev = 0; +static struct udev_monitor *mon = 0; +static GIOChannel *iochannel = 0; +static guint watch_id = 0; static char *dev_name = 0; static int cleanup = 0; /* track cable and charger connects disconnects */ diff --git a/src/usb_moded-util.c b/src/usb_moded-util.c index f716fdf..2007f78 100644 --- a/src/usb_moded-util.c +++ b/src/usb_moded-util.c @@ -29,8 +29,7 @@ #include "usb_moded-dbus.h" -DBusError error; -DBusConnection *conn = 0; +static DBusConnection *conn = 0; static int query_mode (void) { @@ -408,7 +407,7 @@ int main (int argc, char *argv[]) } /* init dbus */ - dbus_error_init(&error); + DBusError error = DBUS_ERROR_INIT; conn = dbus_bus_get_private(DBUS_BUS_SYSTEM, &error); if (!conn) diff --git a/src/usb_moded.c b/src/usb_moded.c index 00ee2da..f8f5cfb 100644 --- a/src/usb_moded.c +++ b/src/usb_moded.c @@ -83,11 +83,11 @@ static int usb_moded_exitcode = EXIT_FAILURE; static GMainLoop *usb_moded_mainloop = NULL; gboolean rescue_mode = FALSE; -gboolean diag_mode = FALSE; -gboolean hw_fallback = FALSE; -gboolean android_broken_usb = FALSE; -gboolean android_ignore_udev_events = FALSE; -gboolean android_ignore_next_udev_disconnect_event = FALSE; +static gboolean diag_mode = FALSE; +static gboolean hw_fallback = FALSE; +static gboolean android_broken_usb = FALSE; +static gboolean android_ignore_udev_events = FALSE; +static gboolean android_ignore_next_udev_disconnect_event = FALSE; #ifdef SYSTEMD static gboolean systemd_notify = FALSE; #endif @@ -132,9 +132,17 @@ static void set_cable_connection_delay(int delay_ms) } } -struct usb_mode current_mode; -guint charging_timeout = 0; -static GList *modelist; +static struct usb_mode current_mode = { + .connected = FALSE, + .mounted = FALSE, + .android_usb_broken = FALSE, + .mode = NULL, + .module = NULL, + .data = NULL, +}; + +static guint charging_timeout = 0; +static GList *modelist = 0; /* static helper functions */ static gboolean set_disconnected(gpointer data); diff --git a/src/usb_moded.h b/src/usb_moded.h index 07975f7..f16df5f 100644 --- a/src/usb_moded.h +++ b/src/usb_moded.h @@ -88,6 +88,7 @@ void allow_suspend(void); void delay_suspend(void); extern int cable_connection_delay; +extern gboolean rescue_mode; void usb_moded_stop(int exitcode);