Commit 3161f170 authored by spiiroin's avatar spiiroin

[usb-moded] Normalize use of return statement

As 'return' is not a function, do not make it look like one.
Signed-off-by: spiiroin's avatarSimo Piiroinen <simo.piiroinen@jollamobile.com>
parent 94a484c2
......@@ -258,7 +258,7 @@ int appsync_activate_sync(const char *mode)
#ifdef APP_SYNC_DBUS
appsync_enumerate_usb();
#endif
return(0);
return 0;
}
#ifdef APP_SYNC_DBUS
......@@ -307,11 +307,11 @@ int appsync_activate_sync(const char *mode)
}
}
return(0);
return 0;
error:
log_warning("Error launching a service!\n");
return(1);
return 1;
}
int appsync_activate_sync_post(const char *mode)
......@@ -365,11 +365,11 @@ int appsync_activate_sync_post(const char *mode)
}
}
return(0);
return 0;
error:
log_warning("Error launching a service!\n");
return(1);
return 1;
}
int appsync_mark_active(const gchar *name, int post)
......@@ -511,5 +511,5 @@ int appsync_stop(gboolean force)
#ifdef APP_SYNC_DBUS
appsync_cancel_enumerate_usb_timer();
#endif
return(0);
return 0;
}
......@@ -113,12 +113,12 @@ static int config_validate_ip(const char *ipadd)
unsigned char c;
if (sscanf(ipadd, "%3u.%3u.%3u.%3u%c", &b1, &b2, &b3, &b4, &c) != 4)
return(-1);
return -1;
if ((b1 | b2 | b3 | b4) > 255)
return(-1);
return -1;
if (strspn(ipadd, "0123456789.") < strlen(ipadd))
return(-1);
return -1;
/* all ok */
return 0;
}
......@@ -134,53 +134,53 @@ char *config_find_mounts(void)
ret = g_strdup(FS_MOUNT_DEFAULT);
log_debug("Default mount = %s\n", ret);
}
return(ret);
return ret;
}
int config_find_sync(void)
{
return(config_get_conf_int(FS_SYNC_ENTRY, FS_SYNC_KEY));
return config_get_conf_int(FS_SYNC_ENTRY, FS_SYNC_KEY);
}
char * config_find_alt_mount(void)
{
return(config_get_conf_string(ALT_MOUNT_ENTRY, ALT_MOUNT_KEY));
return config_get_conf_string(ALT_MOUNT_ENTRY, ALT_MOUNT_KEY);
}
char * config_find_udev_path(void)
{
return(config_get_conf_string(UDEV_PATH_ENTRY, UDEV_PATH_KEY));
return config_get_conf_string(UDEV_PATH_ENTRY, UDEV_PATH_KEY);
}
char * config_find_udev_subsystem(void)
{
return(config_get_conf_string(UDEV_PATH_ENTRY, UDEV_SUBSYSTEM_KEY));
return config_get_conf_string(UDEV_PATH_ENTRY, UDEV_SUBSYSTEM_KEY);
}
char * config_check_trigger(void)
{
return(config_get_conf_string(TRIGGER_ENTRY, TRIGGER_PATH_KEY));
return config_get_conf_string(TRIGGER_ENTRY, TRIGGER_PATH_KEY);
}
char * config_get_trigger_subsystem(void)
{
return(config_get_conf_string(TRIGGER_ENTRY, TRIGGER_UDEV_SUBSYSTEM));
return config_get_conf_string(TRIGGER_ENTRY, TRIGGER_UDEV_SUBSYSTEM);
}
char * config_get_trigger_mode(void)
{
return(config_get_conf_string(TRIGGER_ENTRY, TRIGGER_MODE_KEY));
return config_get_conf_string(TRIGGER_ENTRY, TRIGGER_MODE_KEY);
}
char * config_get_trigger_property(void)
{
return(config_get_conf_string(TRIGGER_ENTRY, TRIGGER_PROPERTY_KEY));
return config_get_conf_string(TRIGGER_ENTRY, TRIGGER_PROPERTY_KEY);
}
char * config_get_trigger_value(void)
{
return(config_get_conf_string(TRIGGER_ENTRY, TRIGGER_PROPERTY_VALUE_KEY));
return config_get_conf_string(TRIGGER_ENTRY, TRIGGER_PROPERTY_VALUE_KEY);
}
static char * config_get_network_ip(void)
......@@ -188,37 +188,37 @@ static char * config_get_network_ip(void)
char * ip = config_get_kcmdline_string(NETWORK_IP_KEY);
if (ip != NULL)
if(!config_validate_ip(ip))
return(ip);
return ip;
return(config_get_conf_string(NETWORK_ENTRY, NETWORK_IP_KEY));
return config_get_conf_string(NETWORK_ENTRY, NETWORK_IP_KEY);
}
static char * config_get_network_interface(void)
{
return(config_get_conf_string(NETWORK_ENTRY, NETWORK_INTERFACE_KEY));
return config_get_conf_string(NETWORK_ENTRY, NETWORK_INTERFACE_KEY);
}
static char * config_get_network_gateway(void)
{
char * gw = config_get_kcmdline_string(NETWORK_GATEWAY_KEY);
if (gw != NULL)
return(gw);
return gw;
return(config_get_conf_string(NETWORK_ENTRY, NETWORK_GATEWAY_KEY));
return config_get_conf_string(NETWORK_ENTRY, NETWORK_GATEWAY_KEY);
}
static char * config_get_network_netmask(void)
{
char * netmask = config_get_kcmdline_string(NETWORK_NETMASK_KEY);
if (netmask != NULL)
return(netmask);
return netmask;
return(config_get_conf_string(NETWORK_ENTRY, NETWORK_NETMASK_KEY));
return config_get_conf_string(NETWORK_ENTRY, NETWORK_NETMASK_KEY);
}
static char * config_get_network_nat_interface(void)
{
return(config_get_conf_string(NETWORK_ENTRY, NETWORK_NAT_INTERFACE_KEY));
return config_get_conf_string(NETWORK_ENTRY, NETWORK_NAT_INTERFACE_KEY);
}
/* create basic conffile with sensible defaults */
......@@ -281,7 +281,7 @@ static int config_get_conf_int(const gchar *entry, const gchar *key)
}
g_strfreev(origkeys);
g_key_file_free(settingsfile);
return(ret);
return ret;
}
......@@ -318,7 +318,7 @@ static char * config_get_conf_string(const gchar *entry, const gchar *key)
g_strfreev(origkeys);
end:
g_key_file_free(settingsfile);
return(tmp_char);
return tmp_char;
}
......@@ -337,7 +337,7 @@ static char * config_get_kcmdline_string(const char *entry)
if ((fd = open("/proc/cmdline", O_RDONLY)) < 0)
{
log_debug("could not read /proc/cmdline");
return(ret);
return ret;
}
len = read(fd, cmdLine, sizeof cmdLine - 1);
......@@ -346,7 +346,7 @@ static char * config_get_kcmdline_string(const char *entry)
if (len <= 0)
{
log_debug("kernel command line was empty");
return(ret);
return ret;
}
cmdLine[len] = '\0';
......@@ -356,7 +356,7 @@ static char * config_get_kcmdline_string(const char *entry)
if (!g_shell_parse_argv(cmdLine, &argc, &argv, &optErr))
{
g_error_free(optErr);
return(ret);
return ret;
}
/* find the ip token */
......@@ -395,7 +395,7 @@ static char * config_get_kcmdline_string(const char *entry)
g_strfreev(argv);
g_strfreev(network_tokens);
return(ret);
return ret;
}
char * config_get_mode_setting(void)
......@@ -464,14 +464,14 @@ set_config_result_t config_set_config_setting(const char *entry, const char *key
ret = SET_CONFIG_UPDATED;
g_free(keyfile);
return (ret);
return ret;
}
set_config_result_t config_set_mode_setting(const char *mode)
{
if (strcmp(mode, MODE_ASK) && common_valid_mode(mode))
return SET_CONFIG_ERROR;
return (config_set_config_setting(MODE_SETTING_ENTRY, MODE_SETTING_KEY, mode));
return config_set_config_setting(MODE_SETTING_ENTRY, MODE_SETTING_KEY, mode);
}
/* Builds the string used for hidden modes, when hide set to one builds the
......@@ -553,7 +553,7 @@ set_config_result_t config_set_hide_mode_setting(const char *mode)
g_free(hidden_modes);
return(ret);
return ret;
}
set_config_result_t config_set_unhide_mode_setting(const char *mode)
......@@ -574,7 +574,7 @@ set_config_result_t config_set_unhide_mode_setting(const char *mode)
g_free(hidden_modes);
return(ret);
return ret;
}
set_config_result_t config_set_mode_whitelist(const char *whitelist)
......@@ -619,7 +619,7 @@ set_config_result_t config_set_mode_in_whitelist(const char *mode, int allowed)
g_free(whitelist);
return(ret);
return ret;
}
/*
......@@ -708,7 +708,7 @@ char * config_get_network_setting(const char *config)
ret = strdup("usb0");
}
else if(!strcmp(config, NETWORK_GATEWAY_KEY))
return(config_get_network_gateway());
return config_get_network_gateway();
else if(!strcmp(config, NETWORK_NETMASK_KEY))
{
ret = config_get_network_netmask();
......@@ -716,12 +716,12 @@ char * config_get_network_setting(const char *config)
ret = strdup("255.255.255.0");
}
else if(!strcmp(config, NETWORK_NAT_INTERFACE_KEY))
return(config_get_network_nat_interface());
return config_get_network_nat_interface();
else
/* no matching keys, return error */
return(NULL);
return NULL;
end:
return(ret);
return ret;
}
/**
......@@ -896,7 +896,7 @@ char * config_get_android_manufacturer(void)
char * config_get_android_vendor_id(void)
{
return(config_get_conf_string(ANDROID_ENTRY, ANDROID_VENDOR_ID_KEY));
return config_get_conf_string(ANDROID_ENTRY, ANDROID_VENDOR_ID_KEY);
}
char * config_get_android_product(void)
......@@ -916,19 +916,19 @@ char * config_get_android_product(void)
char * config_get_android_product_id(void)
{
return(config_get_conf_string(ANDROID_ENTRY, ANDROID_PRODUCT_ID_KEY));
return config_get_conf_string(ANDROID_ENTRY, ANDROID_PRODUCT_ID_KEY);
}
char * config_get_hidden_modes(void)
{
return(config_get_conf_string(MODE_SETTING_ENTRY, MODE_HIDE_KEY));
return config_get_conf_string(MODE_SETTING_ENTRY, MODE_HIDE_KEY);
}
char * config_get_mode_whitelist(void)
{
return(config_get_conf_string(MODE_SETTING_ENTRY, MODE_WHITELIST_KEY));
return config_get_conf_string(MODE_SETTING_ENTRY, MODE_WHITELIST_KEY);
}
int config_is_roaming_not_allowed(void)
{
return(config_get_conf_int(NETWORK_ENTRY, NO_ROAMING_KEY));
return config_get_conf_int(NETWORK_ENTRY, NO_ROAMING_KEY);
}
......@@ -802,7 +802,7 @@ EXIT:
*/
int umdbus_send_state_signal(const char *state_ind)
{
return(umdbus_send_signal_ex(USB_MODE_SIGNAL_NAME, state_ind));
return umdbus_send_signal_ex(USB_MODE_SIGNAL_NAME, state_ind);
}
/**
......@@ -814,7 +814,7 @@ int umdbus_send_state_signal(const char *state_ind)
*/
int umdbus_send_error_signal(const char *error)
{
return(umdbus_send_signal_ex(USB_MODE_ERROR_SIGNAL_NAME, error));
return umdbus_send_signal_ex(USB_MODE_ERROR_SIGNAL_NAME, error);
}
/**
......@@ -826,7 +826,7 @@ int umdbus_send_error_signal(const char *error)
*/
int umdbus_send_supported_modes_signal(const char *supported_modes)
{
return(umdbus_send_signal_ex(USB_MODE_SUPPORTED_MODES_SIGNAL_NAME, supported_modes));
return umdbus_send_signal_ex(USB_MODE_SUPPORTED_MODES_SIGNAL_NAME, supported_modes);
}
/**
......@@ -838,7 +838,7 @@ int umdbus_send_supported_modes_signal(const char *supported_modes)
*/
int umdbus_send_available_modes_signal(const char *available_modes)
{
return(umdbus_send_signal_ex(USB_MODE_AVAILABLE_MODES_SIGNAL_NAME, available_modes));
return umdbus_send_signal_ex(USB_MODE_AVAILABLE_MODES_SIGNAL_NAME, available_modes);
}
/**
......@@ -850,7 +850,7 @@ int umdbus_send_available_modes_signal(const char *available_modes)
*/
int umdbus_send_hidden_modes_signal(const char *hidden_modes)
{
return(umdbus_send_signal_ex(USB_MODE_HIDDEN_MODES_SIGNAL_NAME, hidden_modes));
return umdbus_send_signal_ex(USB_MODE_HIDDEN_MODES_SIGNAL_NAME, hidden_modes);
}
/**
......@@ -861,7 +861,7 @@ int umdbus_send_hidden_modes_signal(const char *hidden_modes)
*/
int umdbus_send_whitelisted_modes_signal(const char *whitelist)
{
return(umdbus_send_signal_ex(USB_MODE_WHITELISTED_MODES_SIGNAL_NAME, whitelist));
return umdbus_send_signal_ex(USB_MODE_WHITELISTED_MODES_SIGNAL_NAME, whitelist);
}
/** Async reply handler for umdbus_get_name_owner_async()
......
......@@ -125,7 +125,7 @@ GList *dynconfig_read_mode_list(int diag)
log_debug("Mode confdir open failed or file is incomplete/invalid.\n");
modelist = g_list_sort (modelist, dynconfig_compare_modes);
return(modelist);
return modelist;
}
static mode_list_elem_t *dynconfig_read_mode_file(const gchar *filename)
......
......@@ -97,7 +97,7 @@ char * mac_read_mac(void)
if(!g_ether)
{
log_warning("Failed to read mac address from /etc/modprobe.d/g_ether.conf\n");
return(NULL);
return NULL;
}
test = fseek(g_ether, 26, SEEK_SET);
if(test == -1)
......@@ -115,5 +115,5 @@ char * mac_read_mac(void)
free(mac);
fclose(g_ether);
return(ret);
return ret;
}
......@@ -224,7 +224,7 @@ int modules_load_module(const char *module)
log_info("Module %s loaded successfully\n", module);
else
log_info("Module %s failed to load\n", module);
return(ret);
return ret;
}
/** unload module
......@@ -251,5 +251,5 @@ int modules_unload_module(const char *module)
ret = kmod_module_remove_module(mod, KMOD_REMOVE_NOWAIT);
kmod_module_unref(mod);
return(ret);
return ret;
}
......@@ -181,7 +181,7 @@ static int network_set_usb_ip_forward(mode_list_elem_t *data, ipforward_data_t *
interface = network_get_interface(data);
if(interface == NULL)
return(1);
return 1;
nat_interface = config_get_network_setting(NETWORK_NAT_INTERFACE_KEY);
if((nat_interface == NULL) && (ipforward->nat_interface != NULL))
nat_interface = strdup(ipforward->nat_interface);
......@@ -194,7 +194,7 @@ static int network_set_usb_ip_forward(mode_list_elem_t *data, ipforward_data_t *
#endif
free(interface);
free(nat_interface);
return(1);
return 1;
}
write_to_file("/proc/sys/net/ipv4/ip_forward", "1");
snprintf(command, 128, "/sbin/iptables -t nat -A POSTROUTING -o %s -j MASQUERADE", nat_interface);
......@@ -209,7 +209,7 @@ static int network_set_usb_ip_forward(mode_list_elem_t *data, ipforward_data_t *
free(interface);
free(nat_interface);
log_debug("ipforwarding success!\n");
return(0);
return 0;
}
/**
......@@ -294,7 +294,7 @@ static int get_roaming(void)
ret = 1;
}
return(ret);
return ret;
}
#endif
......@@ -312,7 +312,7 @@ static int resolv_conf_dns(ipforward_data_t *ipforward)
resolv = fopen("/etc/resolv.conf", "r");
if (resolv == NULL)
return(1);
return 1;
/* we don't expect more than 10 lines in /etc/resolv.conf */
for (i=0; i < 10; i++)
......@@ -337,7 +337,7 @@ static int resolv_conf_dns(ipforward_data_t *ipforward)
end:
free(line);
fclose(resolv);
return(0);
return 0;
}
#endif
......@@ -352,7 +352,7 @@ static int network_checklink(void)
dest[len] = 0;
ret = strcmp(dest, UDHCP_CONFIG_PATH);
}
return(ret);
return ret;
}
/**
......@@ -373,14 +373,14 @@ static int network_write_udhcpd_conf(ipforward_data_t *ipforward, mode_list_elem
if(conffile == NULL)
{
log_debug("Error creating "UDHCP_CONFIG_PATH"!\n");
return(1);
return 1;
}
interface = network_get_interface(data);
if(interface == NULL)
{
fclose(conffile);
return(1);
return 1;
}
/* generate start and end ip based on the setting */
ip = config_get_network_setting(NETWORK_IP_KEY);
......@@ -452,12 +452,12 @@ link:
{
log_debug("Error creating link "UDHCP_CONFIG_LINK" -> "UDHCP_CONFIG_PATH": %m\n");
unlink(UDHCP_CONFIG_PATH);
return(1);
return 1;
}
end:
log_debug(UDHCP_CONFIG_LINK" created\n");
return(0);
return 0;
}
#ifdef CONNMAN
......@@ -583,7 +583,7 @@ static char * connman_parse_manager_reply(DBusMessage *reply, const char *req_se
if(strstr(service, req_service))
{
log_debug("%s service found!\n", req_service);
return(strdup(service));
return strdup(service);
}
}
}
......@@ -592,7 +592,7 @@ static char * connman_parse_manager_reply(DBusMessage *reply, const char *req_se
iter = origiter;
}
log_debug("end of list\n");
return(0);
return 0;
}
static int connman_fill_connection_data(DBusMessage *reply, ipforward_data_t *ipforward)
......@@ -631,7 +631,7 @@ static int connman_fill_connection_data(DBusMessage *reply, ipforward_data_t *ip
if(type != DBUS_TYPE_STRING)
{
/* not online */
return(1);
return 1;
}
dbus_message_iter_get_basic(&string_iter, &string);
log_debug("dns = %s\n", string);
......@@ -642,12 +642,12 @@ static int connman_fill_connection_data(DBusMessage *reply, ipforward_data_t *ip
log_debug("No secundary dns\n");
/* FIXME: set the same dns for dns2 to avoid breakage */
ipforward->dns2 = strdup(string);
return(0);
return 0;
}
dbus_message_iter_get_basic(&string_iter, &string);
log_debug("dns2 = %s\n", string);
ipforward->dns2 = strdup(string);
return(0);
return 0;
}
}
else if(!strcmp(string, "State"))
......@@ -667,7 +667,7 @@ static int connman_fill_connection_data(DBusMessage *reply, ipforward_data_t *ip
/* if in ready state connection might be up anyway */
if(strcmp(string, "ready"))
log_debug("Not online. Turning on cellular data connection.\n");
return(1);
return 1;
}
}
......@@ -707,7 +707,7 @@ static int connman_fill_connection_data(DBusMessage *reply, ipforward_data_t *ip
dbus_message_iter_next (&dict_iter);
type = dbus_message_iter_get_arg_type(&dict_iter);
}
return(0);
return 0;
}
/**
......@@ -760,7 +760,7 @@ static int connman_set_cellular_online(DBusConnection *dbus_conn_connman, const
if(wifi)
free(wifi);
return(ret);
return ret;
}
/*
......@@ -827,7 +827,7 @@ static int connman_wifi_power_control(DBusConnection *dbus_conn_connman, int on)
/* turn on wifi after tethering is over and wifi was on before */
common_system("/bin/dbus-send --print-reply --type=method_call --system --dest=net.connman /net/connman/technology/wifi net.connman.Technology.SetProperty string:Powered variant:boolean:true");
return(0);
return 0;
}
static int connman_get_connection_data(ipforward_data_t *ipforward)
......@@ -888,7 +888,7 @@ try_again:
dbus_connection_unref(dbus_conn_connman);
dbus_error_free(&error);
free(service);
return(ret);
return ret;
}
static int connman_reset_state(void)
......@@ -909,7 +909,7 @@ static int connman_reset_state(void)
dbus_connection_unref(dbus_conn_connman);
dbus_error_free(&error);
return(0);
return 0;
}
#endif /* CONNMAN */
......@@ -955,7 +955,7 @@ int network_set_up_dhcpd(mode_list_elem_t *data)
end:
/* the function checks if ipforward is NULL or not */
network_free_ipforward_data(ipforward);
return(ret);
return ret;
}
#if CONNMAN_WORKS_BETTER
......@@ -1035,7 +1035,7 @@ int network_up(mode_list_elem_t *data)
}
if(service == NULL)
return(1);
return 1;
log_debug("gadget = %s\n", service);
/* now we need to configure the connection */
......@@ -1108,7 +1108,7 @@ int network_up(mode_list_elem_t *data)
free(ip);
if(gateway)
free(gateway);
return(ret);
return ret;
#else
char command[128];
......@@ -1118,7 +1118,7 @@ int network_up(mode_list_elem_t *data)
interface = network_get_interface(data);
if(interface == NULL)
return(1);
return 1;
/* interface found, so we can get all the rest */
ip = config_get_network_setting(NETWORK_IP_KEY);
......@@ -1154,7 +1154,7 @@ int network_up(mode_list_elem_t *data)
free(ip);
free(netmask);
return(0);
return 0;
#endif /* CONNMAN */
}
......@@ -1190,7 +1190,7 @@ int network_down(mode_list_elem_t *data)
}
if(service == NULL)
return(1);
return 1;
/* Finally we can shut it down */
if ((msg = dbus_message_new_method_call("net.connman", service, "net.connman.Service", "Disconnect")) != NULL)
......@@ -1208,14 +1208,14 @@ int network_down(mode_list_elem_t *data)
network_clean_usb_ip_forward();
dbus_error_free(&error);
return(ret);
return ret;
#else
char *interface;
char command[128];
interface = network_get_interface(data);
if(interface == NULL)
return(0);
return 0;
sprintf(command, "ifconfig %s down\n", interface);
common_system(command);
......@@ -1226,7 +1226,7 @@ int network_down(mode_list_elem_t *data)
free(interface);
return(0);
return 0;
#endif /* CONNMAN_IS_EVER_FIXED_FOR_USB */
}
......
......@@ -83,7 +83,7 @@ static int check_device_is_usb_power_supply(const char *syspath)
printf("type property found\n");
}
return(score);
return score;
}
int main (int argc, char **argv)
......
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