From 90ae6d2d18e9d58cbdf0ca115adb4618d3262566 Mon Sep 17 00:00:00 2001 From: Ickhee Woo Date: Fri, 2 Dec 2016 07:38:59 +0900 Subject: [PATCH] fix code for coding convention Change-Id: Ifcf7830008c30517c53d863079499aec26880910 Signed-off-by: Ickhee Woo --- packaging/account-parser.spec | 2 +- src/account-dlog.h | 18 ++--- src/account.c | 158 ++++++++++++++++++++---------------------- 3 files changed, 84 insertions(+), 94 deletions(-) diff --git a/packaging/account-parser.spec b/packaging/account-parser.spec index 1efe360..4cc100e 100644 --- a/packaging/account-parser.spec +++ b/packaging/account-parser.spec @@ -1,6 +1,6 @@ Name: account-parser Summary: Account Parser Library -Version: 0.1.2 +Version: 0.1.3 Release: 0 Group: Social & Content/Other License: Apache-2.0 diff --git a/src/account-dlog.h b/src/account-dlog.h index b7a6f80..46d0171 100644 --- a/src/account-dlog.h +++ b/src/account-dlog.h @@ -19,7 +19,7 @@ #include -#define COLOR_GREEN "\033[0;32m" +#define COLOR_GREEN "\033[0;32m" #define COLOR_END "\033[0;m" #ifdef LOG_TAG @@ -28,14 +28,14 @@ #define LOG_TAG "ACCOUNT_PARSER" -#define _E(fmt, arg...) LOGE("[%s:%d] "fmt,__FUNCTION__,__LINE__,##arg) -#define _D(fmt, arg...) LOGD("[%s:%d] "fmt,__FUNCTION__,__LINE__,##arg) -#define _SECURE_E(fmt, arg...) SECURE_LOGE("[%s:%d] "fmt,__FUNCTION__,__LINE__,##arg) -#define _SECURE_D(fmt, arg...) SECURE_LOGD("[%s:%d] "fmt,__FUNCTION__,__LINE__,##arg) +#define _E(fmt, arg...) LOGE("[%s:%d] "fmt, __FUNCTION__, __LINE__, ##arg) +#define _D(fmt, arg...) LOGD("[%s:%d] "fmt, __FUNCTION__, __LINE__, ##arg) +#define _SECURE_E(fmt, arg...) SECURE_LOGE("[%s:%d] "fmt, __FUNCTION__, __LINE__, ##arg) +#define _SECURE_D(fmt, arg...) SECURE_LOGD("[%s:%d] "fmt, __FUNCTION__, __LINE__, ##arg) #define ENTER() LOGD(COLOR_GREEN"BEGIN >>>"COLOR_END); #define retvm_if(expr, val, fmt, arg...) do { \ - if(expr) { \ + if (expr) { \ _E(fmt, ##arg); \ _E("(%s) -> %s() return", #expr, __FUNCTION__); \ return (val); \ @@ -43,14 +43,14 @@ } while (0) #define retv_if(expr, val) do { \ - if(expr) { \ + if (expr) { \ _E("(%s) -> %s() return", #expr, __FUNCTION__); \ return (val); \ } \ } while (0) #define retm_if(expr, fmt, arg...) do { \ - if(expr) { \ + if (expr) { \ _E(fmt, ##arg); \ _E("(%s) -> %s() return", #expr, __FUNCTION__); \ return; \ @@ -58,7 +58,7 @@ } while (0) #define ret_if(expr) do { \ - if(expr) { \ + if (expr) { \ _E("(%s) -> %s() return", #expr, __FUNCTION__); \ return; \ } \ diff --git a/src/account.c b/src/account.c index 9f44017..1739447 100644 --- a/src/account.c +++ b/src/account.c @@ -91,19 +91,18 @@ int _register_account_provider(xmlDocPtr docPtr, char* account_provider_app_id) _D("Registering the Account Provider."); int ret = ACCOUNT_ERROR_NONE; - int ret2 = ACCOUNT_ERROR_NONE; account_type_h account_type_handle = NULL; ret = account_type_create(&account_type_handle); - if(ret != ACCOUNT_ERROR_NONE || account_type_handle == NULL) { + if (ret != ACCOUNT_ERROR_NONE || account_type_handle == NULL) { _E("[%d]Memory allocation failed.", ret); return ret; } // Node: xmlNodePtr cur_ptr = xmlFirstElementChild(xmlDocGetRootElement(docPtr)); - if(cur_ptr == NULL) { + if (cur_ptr == NULL) { ret = -1; _E("Failed to get the element."); goto CATCH; @@ -113,20 +112,20 @@ int _register_account_provider(xmlDocPtr docPtr, char* account_provider_app_id) // Get the children nodes cur_ptr = cur_ptr->xmlChildrenNode; - if(cur_ptr == NULL) { + if (cur_ptr == NULL) { ret = -1; _E("Failed to get the child element."); goto CATCH; } - while(cur_ptr != NULL) { + while (cur_ptr != NULL) { _SECURE_D("Node: %s", cur_ptr->name); // Node: - if((!xmlStrcmp(cur_ptr->name, _NODE_ACCOUNT_PROVIDER))) { + if ((!xmlStrcmp(cur_ptr->name, _NODE_ACCOUNT_PROVIDER))) { // Attribute: appid xmlChar* attribute_app_id = xmlGetProp(cur_ptr, _ATTRIBUTE_APP_ID); - if(attribute_app_id == NULL) { + if (attribute_app_id == NULL) { ret = -1; _E("Failed to get the attribute."); goto CATCH; @@ -135,28 +134,27 @@ int _register_account_provider(xmlDocPtr docPtr, char* account_provider_app_id) _SECURE_D("Attribute: appid - %s", attribute_app_id); ret = account_type_set_app_id(account_type_handle, (char*)attribute_app_id); - if(ret != ACCOUNT_ERROR_NONE) { + if (ret != ACCOUNT_ERROR_NONE) { _E("Failed to set the app ID."); goto CATCH; } // Attribute: providerid xmlChar* attribute_provider_id = xmlGetProp(cur_ptr, _ATTRIBUTE_SERVICE_PROVIDER_ID); - if(attribute_provider_id != NULL) { + if (attribute_provider_id != NULL) { ret = -1; _E("Failed to get the attribute(providerid)."); _SECURE_D("Attribute: appid - %s", attribute_provider_id); ret = account_type_set_service_provider_id(account_type_handle, (char*)attribute_provider_id); - if(ret != ACCOUNT_ERROR_NONE) { + if (ret != ACCOUNT_ERROR_NONE) _E("Failed to set the service provider id."); - } } // Attribute: multiple-accounts-support xmlChar* multiple_accounts_support = xmlGetProp(cur_ptr, _ATTRIBUTE_MULTIPLE_ACCOUNTS_SUPPORT); - if(multiple_accounts_support == NULL) { + if (multiple_accounts_support == NULL) { ret = -1; _E("Failed to get the attribute."); goto CATCH; @@ -164,16 +162,15 @@ int _register_account_provider(xmlDocPtr docPtr, char* account_provider_app_id) _SECURE_D("Attribute: multiple-accounts-support - %s", multiple_accounts_support); - if((!xmlStrcmp(multiple_accounts_support, _VALUE_TRUE))) { + if ((!xmlStrcmp(multiple_accounts_support, _VALUE_TRUE))) { ret = account_type_set_multiple_account_support(account_type_handle, true); - if(ret != ACCOUNT_ERROR_NONE) { + if (ret != ACCOUNT_ERROR_NONE) { _E("Failed to set the multiple accounts support."); goto CATCH; } } else { ret = account_type_set_multiple_account_support(account_type_handle, false); - if (ret != ACCOUNT_ERROR_NONE) - { + if (ret != ACCOUNT_ERROR_NONE) { _E("Failed to set the multiple accounts support."); goto CATCH; } @@ -181,20 +178,20 @@ int _register_account_provider(xmlDocPtr docPtr, char* account_provider_app_id) // Get the children nodes cur_ptr = cur_ptr->xmlChildrenNode; - if(cur_ptr == NULL) { + if (cur_ptr == NULL) { ret = -1; _E("Failed to get the child element."); goto CATCH; } - while(cur_ptr != NULL) { + while (cur_ptr != NULL) { _SECURE_D("Node: %s", cur_ptr->name); // Node: - if((!xmlStrcmp(cur_ptr->name, _NODE_ICON))) { + if ((!xmlStrcmp(cur_ptr->name, _NODE_ICON))) { // Attribute: section xmlChar* section = xmlGetProp(cur_ptr, _ATTRIBUTE_SECTION); - if(section == NULL) { + if (section == NULL) { ret = -1; _E("Failed to get the attribute."); goto CATCH; @@ -203,9 +200,9 @@ int _register_account_provider(xmlDocPtr docPtr, char* account_provider_app_id) _SECURE_D("Attribute: section - %s", section); char *resource_path = NULL; - if((!xmlStrcmp(section, _VALUE_ACCOUNT))) { + if ((!xmlStrcmp(section, _VALUE_ACCOUNT))) { xmlChar* account_icon = xmlNodeListGetString(docPtr, cur_ptr->xmlChildrenNode, 1); - if(account_icon == NULL) { + if (account_icon == NULL) { ret = -1; _E("Failed to get the value."); goto CATCH; @@ -215,14 +212,14 @@ int _register_account_provider(xmlDocPtr docPtr, char* account_provider_app_id) if (!strncmp((const char*)account_icon, "/usr/share/icons", 16)) { ret = account_type_set_icon_path(account_type_handle, (char*)account_icon); - if(ret != ACCOUNT_ERROR_NONE) { + if (ret != ACCOUNT_ERROR_NONE) { _E("Failed to set the icon path."); goto CATCH; } } else { if (!strcmp((const char*)attribute_app_id, "com.samsung.samsungaccount")) { char *icon_path = g_strdup_printf("%s%s", "/usr/apps/com.samsung.samsungaccount/shared/res/", (const char*)account_icon); - if(icon_path == NULL) { + if (icon_path == NULL) { _E("icon_path is NULL."); free(resource_path); goto CATCH; @@ -230,7 +227,7 @@ int _register_account_provider(xmlDocPtr docPtr, char* account_provider_app_id) _D("icon_path[%s]", icon_path); ret = account_type_set_icon_path(account_type_handle, icon_path); - if(ret != ACCOUNT_ERROR_NONE) { + if (ret != ACCOUNT_ERROR_NONE) { _E("Failed to set the icon path."); g_free(icon_path); goto CATCH; @@ -238,7 +235,7 @@ int _register_account_provider(xmlDocPtr docPtr, char* account_provider_app_id) g_free(icon_path); } else if (!strcmp((const char*)attribute_app_id, "com.samsung.tizenaccount")) { char *icon_path = g_strdup_printf("%s%s", "/usr/apps/com.samsung.tizenaccount/shared/res/", (char*)account_icon); - if(icon_path == NULL) { + if (icon_path == NULL) { _E("icon_path is NULL."); free(resource_path); goto CATCH; @@ -246,7 +243,7 @@ int _register_account_provider(xmlDocPtr docPtr, char* account_provider_app_id) _D("icon_path[%s]", icon_path); ret = account_type_set_icon_path(account_type_handle, icon_path); - if(ret != ACCOUNT_ERROR_NONE) { + if (ret != ACCOUNT_ERROR_NONE) { _E("Failed to set the icon path."); g_free(icon_path); goto CATCH; @@ -260,13 +257,13 @@ int _register_account_provider(xmlDocPtr docPtr, char* account_provider_app_id) } ret = aul_get_usr_app_shared_resource_path_by_appid((char*)attribute_app_id, &resource_path, uid); - if(ret != APP_MANAGER_ERROR_NONE) { + if (ret != APP_MANAGER_ERROR_NONE) { _E("Failed to get the shared resource path. app_manager ret=[%d]", ret); goto CATCH; } char *icon_path = g_strdup_printf("%s%s", resource_path, (char*)account_icon); - if(icon_path == NULL) { + if (icon_path == NULL) { _E("icon_path is NULL."); free(resource_path); goto CATCH; @@ -276,7 +273,7 @@ int _register_account_provider(xmlDocPtr docPtr, char* account_provider_app_id) _D("icon_path[%s]", icon_path); ret = account_type_set_icon_path(account_type_handle, icon_path); - if(ret != ACCOUNT_ERROR_NONE) { + if (ret != ACCOUNT_ERROR_NONE) { _E("Failed to set the icon path."); g_free(icon_path); goto CATCH; @@ -284,9 +281,9 @@ int _register_account_provider(xmlDocPtr docPtr, char* account_provider_app_id) g_free(icon_path); } } - } else if((!xmlStrcmp(section, _VALUE_ACCOUNT_SMALL))) { + } else if ((!xmlStrcmp(section, _VALUE_ACCOUNT_SMALL))) { xmlChar* account_small_icon = xmlNodeListGetString(docPtr, cur_ptr->xmlChildrenNode, 1); - if(account_small_icon == NULL) { + if (account_small_icon == NULL) { ret = -1; _E("Failed to get the value."); goto CATCH; @@ -296,14 +293,14 @@ int _register_account_provider(xmlDocPtr docPtr, char* account_provider_app_id) if (!strncmp((const char*)account_small_icon, "/usr/share/icons", 16) || !strcmp((const char*)account_small_icon, "/usr/apps/com.samsung.tizenaccount/shared/res/TizenAccount.png")) { ret = account_type_set_small_icon_path(account_type_handle, (char*)account_small_icon); - if(ret != ACCOUNT_ERROR_NONE) { + if (ret != ACCOUNT_ERROR_NONE) { _E("Failed to set the small icon path."); goto CATCH; } } else { if (!strcmp((const char*)attribute_app_id, "com.samsung.samsungaccount")) { char *small_icon_path = g_strdup_printf("%s%s", "/usr/apps/com.samsung.samsungaccount/shared/res/", (char*)account_small_icon); - if(small_icon_path == NULL) { + if (small_icon_path == NULL) { _E("small_icon_path is NULL."); free(resource_path); goto CATCH; @@ -311,7 +308,7 @@ int _register_account_provider(xmlDocPtr docPtr, char* account_provider_app_id) _D("small_icon_path[%s]", small_icon_path); ret = account_type_set_small_icon_path(account_type_handle, (char*)small_icon_path); - if(ret != ACCOUNT_ERROR_NONE) { + if (ret != ACCOUNT_ERROR_NONE) { _E("Failed to set the small icon path."); g_free(small_icon_path); goto CATCH; @@ -325,13 +322,13 @@ int _register_account_provider(xmlDocPtr docPtr, char* account_provider_app_id) } ret = aul_get_usr_app_shared_resource_path_by_appid((char*)attribute_app_id, &resource_path, uid); - if(ret != APP_MANAGER_ERROR_NONE) { + if (ret != APP_MANAGER_ERROR_NONE) { _E("Failed to get the shared resource path."); goto CATCH; } char *small_icon_path = g_strdup_printf("%s%s", resource_path, (char*)account_small_icon); - if(small_icon_path == NULL) { + if (small_icon_path == NULL) { _E("small_icon_path is NULL."); free(resource_path); goto CATCH; @@ -341,7 +338,7 @@ int _register_account_provider(xmlDocPtr docPtr, char* account_provider_app_id) _D("small_icon_path[%s]", small_icon_path); ret = account_type_set_small_icon_path(account_type_handle, (char*)small_icon_path); - if(ret != ACCOUNT_ERROR_NONE) { + if (ret != ACCOUNT_ERROR_NONE) { _E("Failed to set the small icon path."); g_free(small_icon_path); goto CATCH; @@ -350,28 +347,28 @@ int _register_account_provider(xmlDocPtr docPtr, char* account_provider_app_id) } } } - } else if((!xmlStrcmp(cur_ptr->name, _NODE_LABEL))) { + } else if ((!xmlStrcmp(cur_ptr->name, _NODE_LABEL))) { // Node: