Commit e48f26b4 authored by spiiroin's avatar spiiroin

[usb-moded] Normalize typedefs

Use named structs / enums in typedefs.

Drop "struct" from code in places where it has been made redundant due to
having a typedef for the structure.
Signed-off-by: spiiroin's avatarSimo Piiroinen <simo.piiroinen@jollamobile.com>
parent a2823139
......@@ -42,12 +42,12 @@
/* -- appsync -- */
static void appsync_free_elem (struct list_elem *elem);
static void appsync_free_elem (list_elem_t *elem);
static void appsync_free_elem_cb (gpointer elem, gpointer user_data);
void appsync_free_appsync_list (void);
static gint appsync_list_sort_func (gconstpointer a, gconstpointer b);
void appsync_read_list (int diag);
static struct list_elem *appsync_read_file (const gchar *filename, int diag);
static list_elem_t *appsync_read_file (const gchar *filename, int diag);
int appsync_activate_sync (const char *mode);
int appsync_activate_sync_post (const char *mode);
int appsync_mark_active (const gchar *name, int post);
......@@ -76,7 +76,7 @@ static int appsync_no_dbus = 0;
* Functions
* ========================================================================= */
static void appsync_free_elem(struct list_elem *elem)
static void appsync_free_elem(list_elem_t *elem)
{
g_free(elem->name);
g_free(elem->launch);
......@@ -112,7 +112,7 @@ void appsync_read_list(int diag)
GDir *confdir = 0;
const gchar *dirname;
struct list_elem *list_item;
list_elem_t *list_item;
appsync_free_appsync_list();
......@@ -154,11 +154,11 @@ cleanup:
}
}
static struct list_elem *appsync_read_file(const gchar *filename, int diag)
static list_elem_t *appsync_read_file(const gchar *filename, int diag)
{
gchar *full_filename = NULL;
GKeyFile *settingsfile = NULL;
struct list_elem *list_item = NULL;
list_elem_t *list_item = NULL;
if(diag)
{
......@@ -230,7 +230,7 @@ int appsync_activate_sync(const char *mode)
* mark them as currently inactive */
for( iter = appsync_sync_list; iter; iter = g_list_next(iter) )
{
struct list_elem *data = iter->data;
list_elem_t *data = iter->data;
if(!strcmp(data->mode, mode))
{
......@@ -266,7 +266,7 @@ int appsync_activate_sync(const char *mode)
/* go through list and launch apps */
for( iter = appsync_sync_list; iter; iter = g_list_next(iter) )
{
struct list_elem *data = iter->data;
list_elem_t *data = iter->data;
if(!strcmp(mode, data->mode))
{
/* do not launch items marked as post, will be launched after usb is up */
......@@ -329,7 +329,7 @@ int appsync_activate_sync_post(const char *mode)
/* go through list and launch apps */
for( iter = appsync_sync_list; iter; iter = g_list_next(iter) )
{
struct list_elem *data = iter->data;
list_elem_t *data = iter->data;
if(!strcmp(mode, data->mode))
{
/* launch only items marked as post, others are already running */
......@@ -375,7 +375,7 @@ int appsync_mark_active(const gchar *name, int post)
for( iter = appsync_sync_list; iter; iter = g_list_next(iter) )
{
struct list_elem *data = iter->data;
list_elem_t *data = iter->data;
if(!strcmp(data->name, name))
{
......@@ -455,7 +455,7 @@ void appsync_stop_apps(int post)
for( iter = appsync_sync_list; iter; iter = g_list_next(iter) )
{
struct list_elem *data = iter->data;
list_elem_t *data = iter->data;
if(data->systemd && data->state == APP_STATE_ACTIVE && data->post == post)
{
......@@ -478,7 +478,7 @@ int appsync_stop(gboolean force)
for( iter = appsync_sync_list; iter; iter = g_list_next(iter) )
{
struct list_elem *data = iter->data;
list_elem_t *data = iter->data;
data->state = APP_STATE_ACTIVE;
}
}
......
......@@ -48,7 +48,7 @@
/** Application activation state
*/
typedef enum {
typedef enum app_state_t {
/** Application is not relevant for the current mode */
APP_STATE_DONTCARE = 0,
/** Application should be started */
......@@ -60,7 +60,7 @@ typedef enum {
/**
* keep all the needed info together for launching an app
*/
typedef struct list_elem
typedef struct list_elem_t
{
char *name; /**< name of the app to launch */
char *mode; /**< mode in which to launch the app */
......@@ -68,7 +68,7 @@ typedef struct list_elem
app_state_t state; /**< marker to check if the app has started sucessfully */
int systemd; /**< marker to know if we start it with systemd or not */
int post; /**< marker to indicate when to start the app */
} list_elem;
} list_elem_t;
/* ========================================================================= *
* Prototypes
......
......@@ -417,7 +417,7 @@ int common_valid_mode(const char *mode)
whitelist_array = g_strsplit(whitelist_value, ",", 0);
for( GList *iter = usbmoded_get_modelist(); iter; iter = g_list_next(iter) ) {
struct mode_list_elem *data = iter->data;
mode_list_elem_t *data = iter->data;
if( strcmp(mode, data->mode_name) )
continue;
......@@ -472,7 +472,7 @@ gchar *common_get_mode_list(mode_list_type_t type)
for( GList *iter = usbmoded_get_modelist(); iter; iter = g_list_next(iter) )
{
struct mode_list_elem *data = iter->data;
mode_list_elem_t *data = iter->data;
/* skip items in the hidden list */
if (common_mode_in_list(data->mode_name, hidden_modes_array))
......
......@@ -668,7 +668,7 @@ set_config_result_t config_set_network_setting(const char *config, const char *s
char * config_get_network_setting(const char *config)
{
char * ret = 0;
struct mode_list_elem *data;
mode_list_elem_t *data;
if(!strcmp(config, NETWORK_IP_KEY))
{
......
......@@ -245,7 +245,7 @@ void control_select_usb_mode(void)
log_err("Diagnostic mode is not configured!");
}
else {
struct mode_list_elem *data = iter->data;
mode_list_elem_t *data = iter->data;
log_debug("Entering diagnostic mode!");
control_set_usb_mode(data->mode_name);
}
......
......@@ -38,17 +38,17 @@
/* -- dynconfig -- */
void dynconfig_free_list_item(mode_list_elem *list_item);
void dynconfig_free_list_item(mode_list_elem_t *list_item);
void dynconfig_free_mode_list(GList *modelist);
static gint dynconfig_compare_modes (gconstpointer a, gconstpointer b);
GList *dynconfig_read_mode_list(int diag);
static struct mode_list_elem *dynconfig_read_mode_file(const gchar *filename);
static mode_list_elem_t *dynconfig_read_mode_file(const gchar *filename);
/* ========================================================================= *
* Functions
* ========================================================================= */
void dynconfig_free_list_item(mode_list_elem *list_item)
void dynconfig_free_list_item(mode_list_elem_t *list_item)
{
if( list_item ) {
free(list_item->mode_name);
......@@ -86,8 +86,8 @@ void dynconfig_free_mode_list(GList *modelist)
static gint dynconfig_compare_modes(gconstpointer a, gconstpointer b)
{
struct mode_list_elem *aa = (struct mode_list_elem *)a;
struct mode_list_elem *bb = (struct mode_list_elem *)b;
mode_list_elem_t *aa = (mode_list_elem_t *)a;
mode_list_elem_t *bb = (mode_list_elem_t *)b;
return g_strcmp0(aa->mode_name, bb->mode_name);
}
......@@ -97,7 +97,7 @@ GList *dynconfig_read_mode_list(int diag)
GDir *confdir;
GList *modelist = NULL;
const gchar *dirname;
struct mode_list_elem *list_item;
mode_list_elem_t *list_item;
gchar *full_filename = NULL;
if(diag)
......@@ -128,11 +128,11 @@ GList *dynconfig_read_mode_list(int diag)
return(modelist);
}
static struct mode_list_elem *dynconfig_read_mode_file(const gchar *filename)
static mode_list_elem_t *dynconfig_read_mode_file(const gchar *filename)
{
bool success = false;
GKeyFile *settingsfile = g_key_file_new();
struct mode_list_elem *list_item = NULL;
mode_list_elem_t *list_item = NULL;
if( !g_key_file_load_from_file(settingsfile, filename, G_KEY_FILE_NONE, NULL) ) {
log_err("%s: can't read mode configuration file", filename);
......
......@@ -93,7 +93,7 @@
/**
* Struct keeping all the data needed for the definition of a dynamic mode
*/
typedef struct mode_list_elem
typedef struct mode_list_elem_t
{
char *mode_name; /**< Mode name */
char *mode_module; /**< Needed module for given mode */
......@@ -119,7 +119,7 @@ typedef struct mode_list_elem
# ifdef CONNMAN
char* connman_tethering; /**< Connman's tethering technology path */
# endif
} mode_list_elem;
} mode_list_elem_t;
/* ========================================================================= *
* Prototypes
......@@ -127,7 +127,7 @@ typedef struct mode_list_elem
/* -- dynconfig -- */
void dynconfig_free_list_item(mode_list_elem *list_item);
void dynconfig_free_list_item(mode_list_elem_t *list_item);
void dynconfig_free_mode_list(GList *modelist);
GList *dynconfig_read_mode_list(int diag);
......
......@@ -64,8 +64,8 @@ int modesetting_write_to_file_real (const char *file, int l
static gboolean modesetting_network_retry_cb (gpointer data);
static bool modesetting_enter_mass_storage_mode (struct mode_list_elem *data);
static int modesetting_leave_mass_storage_mode (struct mode_list_elem *data);
static bool modesetting_enter_mass_storage_mode (mode_list_elem_t *data);
static int modesetting_leave_mass_storage_mode (mode_list_elem_t *data);
static void modesetting_report_mass_storage_blocker(const char *mountpoint, int try);
bool modesetting_enter_dynamic_mode (void);
......@@ -415,7 +415,7 @@ EXIT:
return *pcount = count, info;
}
static bool modesetting_enter_mass_storage_mode(struct mode_list_elem *data)
static bool modesetting_enter_mass_storage_mode(mode_list_elem_t *data)
{
bool ack = false;
size_t count = 0;
......@@ -551,7 +551,7 @@ EXIT:
return ack;
}
static int modesetting_leave_mass_storage_mode(struct mode_list_elem *data)
static int modesetting_leave_mass_storage_mode(mode_list_elem_t *data)
{
(void)data;
......@@ -685,7 +685,7 @@ bool modesetting_enter_dynamic_mode(void)
{
bool ack = false;
struct mode_list_elem *data;
mode_list_elem_t *data;
int network = 1;
log_debug("DYNAMIC MODE: SETUP");
......@@ -835,7 +835,7 @@ void modesetting_leave_dynamic_mode(void)
{
log_debug("DYNAMIC MODE: CLEANUP");
struct mode_list_elem *data;
mode_list_elem_t *data;
data = worker_get_usb_mode_data();
......
......@@ -59,7 +59,7 @@
* ========================================================================= */
/** IP forwarding configuration block */
typedef struct ipforward_data
typedef struct ipforward_data_t
{
/** Address of primary DNS */
char *dns1;
......@@ -67,7 +67,7 @@ typedef struct ipforward_data
char *dns2;
/** Interface from which packets should be forwarded */
char *nat_interface;
}ipforward_data;
}ipforward_data_t;
/* ========================================================================= *
* Prototypes
......@@ -75,16 +75,16 @@ typedef struct ipforward_data
/* -- network -- */
static void network_free_ipforward_data (struct ipforward_data *ipforward);
static void network_free_ipforward_data (ipforward_data_t *ipforward);
static int network_check_interface (char *interface);
static char *network_get_interface (struct mode_list_elem *data);
static int network_set_usb_ip_forward (struct mode_list_elem *data, struct ipforward_data *ipforward);
static char *network_get_interface (mode_list_elem_t *data);
static int network_set_usb_ip_forward (mode_list_elem_t *data, ipforward_data_t *ipforward);
static void network_clean_usb_ip_forward(void);
static int network_checklink (void);
static int network_write_udhcpd_conf (struct ipforward_data *ipforward, struct mode_list_elem *data);
int network_set_up_dhcpd (struct mode_list_elem *data);
int network_up (struct mode_list_elem *data);
int network_down (struct mode_list_elem *data);
static int network_write_udhcpd_conf (ipforward_data_t *ipforward, mode_list_elem_t *data);
int network_set_up_dhcpd (mode_list_elem_t *data);
int network_up (mode_list_elem_t *data);
int network_down (mode_list_elem_t *data);
int network_update (void);
/* -- connman -- */
......@@ -93,10 +93,10 @@ int network_update (void);
static gboolean connman_try_set_tethering (DBusConnection *connection, const char *path, gboolean on);
gboolean connman_set_tethering (const char *path, gboolean on);
static char *connman_parse_manager_reply (DBusMessage *reply, const char *req_service);
static int connman_fill_connection_data(DBusMessage *reply, struct ipforward_data *ipforward);
static int connman_fill_connection_data(DBusMessage *reply, ipforward_data_t *ipforward);
static int connman_set_cellular_online (DBusConnection *dbus_conn_connman, const char *service, int retry);
static int connman_wifi_power_control (DBusConnection *dbus_conn_connman, int on);
static int connman_get_connection_data (struct ipforward_data *ipforward);
static int connman_get_connection_data (ipforward_data_t *ipforward);
static int connman_reset_state (void);
#endif
......@@ -110,7 +110,7 @@ static const char default_interface[] = "usb0";
* Functions
* ========================================================================= */
static void network_free_ipforward_data (struct ipforward_data *ipforward)
static void network_free_ipforward_data (ipforward_data_t *ipforward)
{
if(ipforward)
{
......@@ -139,7 +139,7 @@ static int network_check_interface(char *interface)
return ret;
}
static char* network_get_interface(struct mode_list_elem *data)
static char* network_get_interface(mode_list_elem_t *data)
{
(void)data; // FIXME: why is this passed in the 1st place?
......@@ -174,7 +174,7 @@ static char* network_get_interface(struct mode_list_elem *data)
* Turn on ip forwarding on the usb interface
* @return: 0 on success, 1 on failure
*/
static int network_set_usb_ip_forward(struct mode_list_elem *data, struct ipforward_data *ipforward)
static int network_set_usb_ip_forward(mode_list_elem_t *data, ipforward_data_t *ipforward)
{
char *interface, *nat_interface;
char command[128];
......@@ -302,7 +302,7 @@ static int get_roaming(void)
/**
* Read dns settings from /etc/resolv.conf
*/
static int resolv_conf_dns(struct ipforward_data *ipforward)
static int resolv_conf_dns(ipforward_data_t *ipforward)
{
FILE *resolv;
int i = 0, count = 0;
......@@ -359,7 +359,7 @@ static int network_checklink(void)
* Write udhcpd.conf
* @ipforward : NULL if we want a simple config, otherwise include dns info etc...
*/
static int network_write_udhcpd_conf(struct ipforward_data *ipforward, struct mode_list_elem *data)
static int network_write_udhcpd_conf(ipforward_data_t *ipforward, mode_list_elem_t *data)
{
FILE *conffile;
char *ip, *interface, *netmask;
......@@ -594,7 +594,7 @@ static char * connman_parse_manager_reply(DBusMessage *reply, const char *req_se
return(0);
}
static int connman_fill_connection_data(DBusMessage *reply, struct ipforward_data *ipforward)
static int connman_fill_connection_data(DBusMessage *reply, ipforward_data_t *ipforward)
{
DBusMessageIter array_iter, dict_iter, inside_dict_iter, variant_iter;
DBusMessageIter sub_array_iter, string_iter;
......@@ -829,7 +829,7 @@ static int connman_wifi_power_control(DBusConnection *dbus_conn_connman, int on)
return(0);
}
static int connman_get_connection_data(struct ipforward_data *ipforward)
static int connman_get_connection_data(ipforward_data_t *ipforward)
{
DBusConnection *dbus_conn_connman = NULL;
DBusMessage *msg = NULL, *reply = NULL;
......@@ -915,9 +915,9 @@ static int connman_reset_state(void)
/**
* Write out /etc/udhcpd.conf conf so the config is available when it gets started
*/
int network_set_up_dhcpd(struct mode_list_elem *data)
int network_set_up_dhcpd(mode_list_elem_t *data)
{
struct ipforward_data *ipforward = NULL;
ipforward_data_t *ipforward = NULL;
int ret = 1;
/* Set up nat info only if it is required */
......@@ -932,8 +932,7 @@ int network_set_up_dhcpd(struct mode_list_elem *data)
goto end;
}
#endif /* OFONO */
ipforward = malloc(sizeof(struct ipforward_data));
memset(ipforward, 0, sizeof(struct ipforward_data));
ipforward = calloc(1, sizeof *ipforward);
#ifdef CONNMAN
if(connman_get_connection_data(ipforward))
{
......@@ -996,7 +995,7 @@ static int append_variant(DBusMessageIter *iter, const char *property,
* Activate the network interface
*
*/
int network_up(struct mode_list_elem *data)
int network_up(mode_list_elem_t *data)
{
char *ip = NULL, *gateway = NULL;
int ret = -1;
......@@ -1162,7 +1161,7 @@ int network_up(struct mode_list_elem *data)
* Deactivate the network interface
*
*/
int network_down(struct mode_list_elem *data)
int network_down(mode_list_elem_t *data)
{
#if CONNMAN_WORKS_BETTER
DBusConnection *dbus_conn_connman = NULL;
......@@ -1237,7 +1236,7 @@ int network_down(struct mode_list_elem *data)
int network_update(void)
{
if( control_get_cable_state() == CABLE_STATE_PC_CONNECTED ) {
struct mode_list_elem *data = worker_get_usb_mode_data();
mode_list_elem_t *data = worker_get_usb_mode_data();
if( data && data->network ) {
network_down(data);
network_up(data);
......
......@@ -41,9 +41,9 @@ gboolean connman_set_tethering(const char *path, gboolean on);
/* -- network -- */
int network_set_up_dhcpd(struct mode_list_elem *data);
int network_up (struct mode_list_elem *data);
int network_down (struct mode_list_elem *data);
int network_set_up_dhcpd(mode_list_elem_t *data);
int network_up (mode_list_elem_t *data);
int network_down (mode_list_elem_t *data);
int network_update (void);
#endif /* USB_MODED_NETWORK_H_ */
......@@ -56,8 +56,8 @@ static bool worker_switch_to_charging (void);
const char *worker_get_kernel_module (void);
bool worker_set_kernel_module (const char *module);
void worker_clear_kernel_module (void);
struct mode_list_elem *worker_get_usb_mode_data (void);
void worker_set_usb_mode_data (struct mode_list_elem *data);
mode_list_elem_t *worker_get_usb_mode_data (void);
void worker_set_usb_mode_data (mode_list_elem_t *data);
static const char *worker_get_activated_mode_locked(void);
static bool worker_set_activated_mode_locked(const char *mode);
static const char *worker_get_requested_mode_locked(void);
......@@ -311,24 +311,24 @@ void worker_clear_kernel_module(void)
* ------------------------------------------------------------------------- */
/** Contains the mode data */
static struct mode_list_elem *worker_mode_data = NULL;
static mode_list_elem_t *worker_mode_data = NULL;
/** get the usb mode data
*
* @return a pointer to the usb mode data
*
*/
struct mode_list_elem * worker_get_usb_mode_data(void)
mode_list_elem_t *worker_get_usb_mode_data(void)
{
return worker_mode_data;
}
/** set the mode_list_elem data
/** set the mode_list_elem_t data
*
* @param data mode_list_element pointer
*
*/
void worker_set_usb_mode_data(struct mode_list_elem *data)
void worker_set_usb_mode_data(mode_list_elem_t *data)
{
worker_mode_data = data;
}
......@@ -483,7 +483,7 @@ worker_switch_to_mode(const char *mode)
/* go through all the dynamic modes if the modelist exists*/
for( GList *iter = usbmoded_get_modelist(); iter; iter = g_list_next(iter) )
{
struct mode_list_elem *data = iter->data;
mode_list_elem_t *data = iter->data;
if( strcmp(mode, data->mode_name) )
continue;
......
......@@ -26,6 +26,8 @@
# include <stdbool.h>
# include "usb_moded-dyn-config.h"
/* ========================================================================= *
* Constants
* ========================================================================= */
......@@ -40,8 +42,8 @@ bool worker_bailing_out (void);
const char *worker_get_kernel_module (void);
bool worker_set_kernel_module (const char *module);
void worker_clear_kernel_module (void);
struct mode_list_elem *worker_get_usb_mode_data (void);
void worker_set_usb_mode_data (struct mode_list_elem *data);
mode_list_elem_t *worker_get_usb_mode_data (void);
void worker_set_usb_mode_data (mode_list_elem_t *data);
void worker_request_hardware_mode(const char *mode);
void worker_clear_hardware_mode (void);
void worker_switch_to_mode (const char *mode);
......
......@@ -97,12 +97,12 @@ int main (int argc, char **argv)
const char *udev_name;
int ret = 0, score = 0;
typedef struct power_device {
typedef struct power_device_t {
const char *syspath;
int score;
} power_device;
} power_device_t;
struct power_device power_dev;
power_device_t power_dev;
power_dev.score = 0;
......
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