Commit cd8d5d24 authored by spiiroin's avatar spiiroin

[usb-moded] Tune global variables

If variables are used only from one source file, make them static.

If variables are truly global, put extern declaration to relevant header.

Drop completely unused variables.

Explicitly initialize variables to sane defaults.
Signed-off-by: spiiroin's avatarSimo Piiroinen <simo.piiroinen@jollamobile.com>
parent b38ec22f
......@@ -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
......
......@@ -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.
*/
......
......@@ -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
......
......@@ -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
......
......@@ -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,
......
......@@ -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 */
......
......@@ -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)
......
......@@ -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);
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment