Fix to follow coding style
[platform/core/connectivity/wifi-mesh-manager.git] / src / mesh-request.c
index 103235c..1acfc3b 100644 (file)
@@ -49,7 +49,7 @@ int mesh_request_set_mesh_gate(const char* bridge_interface,
        if (state) {
                /* Turn STP on */
                ret = mesh_bridge_set_stp(bridge_interface, TRUE);
-               if(MESHD_ERROR_NONE != ret) {
+               if (MESHD_ERROR_NONE != ret) {
                        MESH_LOGE("Failed to turn STP on !");
                        return ret;
                }
@@ -57,15 +57,13 @@ int mesh_request_set_mesh_gate(const char* bridge_interface,
                /* Set mesh parameters */
                ret = mesh_netlink_set_mesh_parameter(mesh_interface,
                                "mesh_hwmp_rootmode", 4);
-               if (MESHD_ERROR_NONE != ret) {
+               if (MESHD_ERROR_NONE != ret)
                        MESH_LOGE("Failed to set [mesh_hwmp_rootmode] : 4");
-               }
 
                ret = mesh_netlink_set_mesh_parameter(mesh_interface,
                                "mesh_gate_announcements", 1);
-               if (MESHD_ERROR_NONE != ret) {
+               if (MESHD_ERROR_NONE != ret)
                        MESH_LOGE("Failed to set [mesh_gate_announcements] : 1");
-               }
        } else {
                MESH_LOGE("External interface is not available !");
                return MESHD_ERROR_OPERATION_FAILED;
@@ -84,19 +82,17 @@ int mesh_request_unset_mesh_gate(const char* bridge_interface,
        /* Set mesh parameters */
        ret = mesh_netlink_set_mesh_parameter(mesh_interface,
                        "mesh_hwmp_rootmode", 0);
-       if (MESHD_ERROR_NONE != ret) {
+       if (MESHD_ERROR_NONE != ret)
                MESH_LOGE("Failed to set [mesh_hwmp_rootmode] : 0");
-       }
 
        ret = mesh_netlink_set_mesh_parameter(mesh_interface,
                        "mesh_gate_announcements", 0);
-       if (MESHD_ERROR_NONE != ret) {
+       if (MESHD_ERROR_NONE != ret)
                MESH_LOGE("Failed to set [mesh_gate_announcements] : 0");
-       }
 
        /* Turn STP off */
        ret = mesh_bridge_set_stp(bridge_interface, FALSE);
-       if(MESHD_ERROR_NONE != ret) {
+       if (MESHD_ERROR_NONE != ret) {
                MESH_LOGE("Failed to turn STP off!");
                return ret;
        }
@@ -118,21 +114,21 @@ int mesh_request_add_bridge_interface(const char* bridge_interface,
 
        /* Add external interface into bridge */
        ret = mesh_bridge_add_interface(bridge_interface, interface);
-       if(MESHD_ERROR_NONE != ret) {
+       if (MESHD_ERROR_NONE != ret) {
                MESH_LOGE("Failed to add interface !");
                return ret;
        }
 
        /* Make external interface down */
        ret = mesh_interface_set(interface, NULL, MESH_INTERFACE_DOWN);
-       if(MESHD_ERROR_NONE != ret) {
+       if (MESHD_ERROR_NONE != ret) {
                MESH_LOGE("Failed to change external interface state");
                return ret;
        }
 
        /* Make external interface up with cleared IP */
        ret = mesh_interface_set(interface, "0.0.0.0", MESH_INTERFACE_UP);
-       if(MESHD_ERROR_NONE != ret) {
+       if (MESHD_ERROR_NONE != ret) {
                MESH_LOGE("Failed to change external interface state");
                return ret;
        }
@@ -154,7 +150,7 @@ int mesh_request_remove_bridge_interface(const char* bridge_interface,
 
        /* Remove external interface into bridge */
        ret = mesh_bridge_del_interface(bridge_interface, interface);
-       if(MESHD_ERROR_NONE != ret) {
+       if (MESHD_ERROR_NONE != ret) {
                MESH_LOGE("Failed to remove interface !");
                return ret;
        }
@@ -172,7 +168,7 @@ int mesh_request_set_softap_config(const char* softap_interface,
 
        ret = mesh_softap_set_configuration(softap_interface, ssid, mode, channel,
                        visibility, max_sta, security, passphrase);
-       if(MESHD_ERROR_NONE != ret) {
+       if (MESHD_ERROR_NONE != ret) {
                MESH_LOGE("Failed to set Configuration for SoftAP");
                return ret;
        }
@@ -194,9 +190,8 @@ int mesh_request_enable_softap(
 
        /* Add softAP interface into bridge */
        ret = mesh_request_add_bridge_interface(bridge_interface, softap_interface);
-       if (MESHD_ERROR_NONE != ret) {
+       if (MESHD_ERROR_NONE != ret)
                return ret;
-       }
 
        return ret;
 }
@@ -211,9 +206,8 @@ int mesh_request_disable_softap(
 
        /* Remove softAP interface from bridge */
        ret = mesh_request_remove_bridge_interface(bridge_interface, softap_interface);
-       if (MESHD_ERROR_NONE != ret) {
+       if (MESHD_ERROR_NONE != ret)
                return ret;
-       }
 
        return ret;
 }
@@ -226,9 +220,8 @@ int mesh_request_get_station_info(const char* mesh_interface, GList **station_li
 
        /* Get station info */
        ret = mesh_netlink_get_station_info(mesh_interface, station_list);
-       if (MESHD_ERROR_NONE != ret) {
+       if (MESHD_ERROR_NONE != ret)
                return ret;
-       }
 
        return MESHD_ERROR_NONE;
 }
@@ -241,9 +234,8 @@ int mesh_request_get_mpath_info(const char* mesh_interface, GList **mpath_list)
 
        /* Get MPath info */
        ret = mesh_netlink_get_mpath_info(mesh_interface, mpath_list);
-       if (MESHD_ERROR_NONE != ret) {
+       if (MESHD_ERROR_NONE != ret)
                return ret;
-       }
 
        return MESHD_ERROR_NONE;
 }
@@ -256,9 +248,8 @@ int mesh_request_register_event_handler()
 
        /* Get MPath info */
        ret = mesh_netlink_register_event_handler();
-       if (MESHD_ERROR_NONE != ret) {
+       if (MESHD_ERROR_NONE != ret)
                return ret;
-       }
 
        return MESHD_ERROR_NONE;
 }
@@ -271,9 +262,8 @@ int mesh_request_unregister_event_handler()
 
        /* Get MPath info */
        ret = mesh_netlink_unregister_event_handler();
-       if (MESHD_ERROR_NONE != ret) {
+       if (MESHD_ERROR_NONE != ret)
                return ret;
-       }
 
        return MESHD_ERROR_NONE;
 }
@@ -289,7 +279,7 @@ int mesh_request_enable_network(mesh_service *service)
        MESH_LOGD("[IPC] Enable mesh network");
 
        ret = mesh_gdbus_create_mesh_interface(service);
-       if(MESHD_ERROR_NONE != ret) {
+       if (MESHD_ERROR_NONE != ret) {
                MESH_LOGE("Failed to create mesh network");
                return ret;
        }
@@ -308,7 +298,7 @@ int mesh_request_disable_network(mesh_service *service)
        MESH_LOGD("[IPC] Disable mesh network");
 
        ret = mesh_gdbus_remove_mesh_interface(service);
-       if(MESHD_ERROR_NONE != ret) {
+       if (MESHD_ERROR_NONE != ret) {
                MESH_LOGE("Failed to create mesh network");
                return ret;
        }
@@ -327,7 +317,7 @@ int mesh_request_scan(mesh_service *service)
        MESH_LOGD("[IPC] Request scan for mesh network");
 
        ret = mesh_gdbus_mesh_scan(service);
-       if(MESHD_ERROR_NONE != ret) {
+       if (MESHD_ERROR_NONE != ret) {
                MESH_LOGE("Failed to request scan for mesh network");
                return ret;
        }
@@ -335,8 +325,7 @@ int mesh_request_scan(mesh_service *service)
        return MESHD_ERROR_NONE;
 }
 
-int mesh_request_specific_scan(mesh_service *service, gchar *mesh_id,
-        gint channel)
+int mesh_request_specific_scan(mesh_service *service, gchar *mesh_id, gint channel)
 {
        int ret;
        if (NULL == service) {
@@ -347,7 +336,7 @@ int mesh_request_specific_scan(mesh_service *service, gchar *mesh_id,
        MESH_LOGD("[IPC] Request specific scan for mesh network");
 
        ret = mesh_gdbus_mesh_specific_scan(service, mesh_id, channel);
-       if(MESHD_ERROR_NONE != ret) {
+       if (MESHD_ERROR_NONE != ret) {
                MESH_LOGE("Failed to request specific scan for mesh network");
                return ret;
        }
@@ -366,7 +355,7 @@ int mesh_request_cancel_scan(mesh_service *service)
        MESH_LOGD("[IPC] Cancel scan for mesh network");
 
        ret = mesh_gdbus_mesh_cancel_scan(service);
-       if(MESHD_ERROR_NONE != ret) {
+       if (MESHD_ERROR_NONE != ret) {
                MESH_LOGE("Failed to cancel scan for mesh network");
                return ret;
        }
@@ -385,7 +374,7 @@ int mesh_request_get_networks(mesh_service *service)
        MESH_LOGD("[IPC] Get mesh networks");
 
        ret = mesh_gdbus_get_mesh_networks(service);
-       if(MESHD_ERROR_NONE != ret) {
+       if (MESHD_ERROR_NONE != ret) {
                MESH_LOGE("Failed to get mesh networks !");
                return ret;
        }
@@ -410,8 +399,7 @@ static int _select_matched_network(GList *scanned_network,
                item = (mesh_scan_result_s*)iter->data;
 
                if (g_strcmp0(mesh_id, item->mesh_id) == 0) {
-                       if (item->channel == mesh_channel && item->security == sec)
-                       {
+                       if (item->channel == mesh_channel && item->security == sec) {
                                *info = item;
                                found = TRUE;
                                break;
@@ -438,7 +426,7 @@ int mesh_request_get_joined_network(mesh_service *service)
        MESH_LOGD("[IPC] Get joined mesh network");
 
        ret = mesh_gdbus_get_joined_mesh_network(service);
-       if(MESHD_ERROR_NONE != ret) {
+       if (MESHD_ERROR_NONE != ret) {
                MESH_LOGE("Failed to get joined mesh network");
                return ret;
        }
@@ -458,7 +446,7 @@ int mesh_request_get_connected_peers(mesh_service *service)
        MESH_LOGD("[IPC] Get connected mesh peers");
 
        ret = mesh_gdbus_get_connected_peers(service);
-       if(MESHD_ERROR_NONE != ret) {
+       if (MESHD_ERROR_NONE != ret) {
                MESH_LOGE("Failed to get connected mesh peers");
                return ret;
        }
@@ -479,7 +467,7 @@ int mesh_request_create_mesh_network(mesh_service *service, gchar *mesh_id,
        MESH_LOGD("[IPC] Create a new mesh network");
 
        ret = mesh_gdbus_create_network(service, mesh_id, channel, sec);
-       if(MESHD_ERROR_NONE != ret) {
+       if (MESHD_ERROR_NONE != ret) {
                MESH_LOGE("Failed to create mesh network");
                return ret;
        }
@@ -503,7 +491,7 @@ int mesh_request_connect_mesh_network(mesh_service *service, gchar *mesh_id,
        /* Get mesh_id and channel from saved network */
        ret = _select_matched_network(service->scanned_mesh_network,
                        mesh_id, channel, sec, &info);
-       if(MESHD_ERROR_NONE != ret) {
+       if (MESHD_ERROR_NONE != ret) {
                MESH_LOGE("Failed to mesh_network_get_first_mesh_network");
                return ret;
        }
@@ -512,7 +500,7 @@ int mesh_request_connect_mesh_network(mesh_service *service, gchar *mesh_id,
        if (MESHD_SECURITY_NONE != sec) {
                if (NULL != passphrase) {
                        ret = mesh_gdbus_set_passphrase(service, info, passphrase);
-                       if(MESHD_ERROR_NONE != ret) {
+                       if (MESHD_ERROR_NONE != ret) {
                                MESH_LOGE("Failed to set passphrase for mesh network");
                                return ret;
                        }
@@ -523,7 +511,7 @@ int mesh_request_connect_mesh_network(mesh_service *service, gchar *mesh_id,
        }
 
        ret = mesh_gdbus_connect_network(service, info);
-       if(MESHD_ERROR_NONE != ret) {
+       if (MESHD_ERROR_NONE != ret) {
                MESH_LOGE("Failed to connect mesh network");
                return ret;
        }
@@ -547,13 +535,13 @@ int mesh_request_disconnect_mesh_network(mesh_service *service,
        /* Get mesh_id and channel from saved network */
        ret = _select_matched_network(service->scanned_mesh_network,
                        mesh_id, channel, sec, &info);
-       if(MESHD_ERROR_NONE != ret) {
+       if (MESHD_ERROR_NONE != ret) {
                MESH_LOGE("Failed to _select_matched_network");
                return ret;
        }
 
        ret = mesh_gdbus_disconnect_network(service, info);
-       if(MESHD_ERROR_NONE != ret) {
+       if (MESHD_ERROR_NONE != ret) {
                MESH_LOGE("Failed to disconnect mesh network");
                return ret;
        }
@@ -577,13 +565,13 @@ int mesh_request_remove_mesh_network(mesh_service *service,
        /* Get mesh_id and channel from saved network */
        ret = _select_matched_network(service->scanned_mesh_network,
                        mesh_id, channel, sec, &info);
-       if(MESHD_ERROR_NONE != ret) {
+       if (MESHD_ERROR_NONE != ret) {
                MESH_LOGE("Failed to _select_matched_network");
                return ret;
        }
 
        ret = mesh_gdbus_remove_network(service, info);
-       if(MESHD_ERROR_NONE != ret) {
+       if (MESHD_ERROR_NONE != ret) {
                MESH_LOGE("Failed to remove mesh network");
                return ret;
        }