From 5f2d264ae75ac47dfcb9fa00783d0f96b29f8992 Mon Sep 17 00:00:00 2001 From: "sunm.lee" Date: Tue, 17 May 2016 12:03:13 +0900 Subject: [PATCH] common, tests, resourced-dbus, utils: Apply Tizen coding rule Apply Tizen coding rule to: common, tests, resourced-dbus, utils Change-Id: I8f1554a58b1dc03e459933cd9f6633a3bf8c5e56 Signed-off-by: sunm.lee --- src/common/appinfo-list.c | 2 +- src/common/cgroup.c | 2 +- src/common/config-parser.c | 4 ++-- src/common/edbus-handler.c | 8 ++++---- src/common/filemap.c | 2 +- src/common/proc-cpu.c | 2 +- src/common/procfs.c | 2 +- src/common/storage-helper.c | 6 +++--- src/common/time-helper.c | 2 +- src/common/util.c | 29 ++++++++++++++------------- src/resourced-dbus/resourced-dbus.c | 24 +++++++++++----------- src/tests/cpu/resourced_cpu_test.c | 2 +- src/tests/network/resourced_data_usage_test.c | 4 ++-- src/utils/datausage-tool.c | 6 +++--- 14 files changed, 48 insertions(+), 47 deletions(-) diff --git a/src/common/appinfo-list.c b/src/common/appinfo-list.c index 66ec5fd..2b2bd27 100644 --- a/src/common/appinfo-list.c +++ b/src/common/appinfo-list.c @@ -43,7 +43,7 @@ static struct resourced_appinfo *resourced_appinfo_create(const char *appid, assert(appid != NULL); assert(pkgname != NULL); - if (!appid || !pkgname){ + if (!appid || !pkgname) { _E("appid or pkgname was null, values: %s, %s", appid, pkgname); return NULL; } diff --git a/src/common/cgroup.c b/src/common/cgroup.c index 17a3965..90e869c 100644 --- a/src/common/cgroup.c +++ b/src/common/cgroup.c @@ -54,7 +54,7 @@ static bool is_cgroup_exists(const char *cgroup_full_path) static int create_cgroup(const char *cgroup_full_path) { - if (mkdir (cgroup_full_path, + if (mkdir(cgroup_full_path, S_IRUSR | S_IWUSR | S_IRGRP) < 0) return -errno; diff --git a/src/common/config-parser.c b/src/common/config-parser.c index fe3b28b..653f9c0 100644 --- a/src/common/config-parser.c +++ b/src/common/config-parser.c @@ -43,7 +43,7 @@ static inline char *trim_str(char *s) } int config_parse(const char *file_name, int cb(struct parse_result *result, - void *user_data), void *user_data) + void *user_data), void *user_data) { FILE *f = NULL; struct parse_result result; @@ -301,7 +301,7 @@ int config_parse_new(const char *filename, void *table) r = 0; finish: - for (i=0; ichildren, new_offset); } diff --git a/src/common/proc-cpu.c b/src/common/proc-cpu.c index 47f8a0f..e78d6ec 100755 --- a/src/common/proc-cpu.c +++ b/src/common/proc-cpu.c @@ -54,7 +54,7 @@ resourced_ret_c proc_cpu_stat(struct cpu_stat *cs) } if (!fgets(buffer, BUF_MAX, fp)) { - _E ("fgets() failed"); + _E("fgets() failed"); fclose(fp); return RESOURCED_ERROR_FAIL; } diff --git a/src/common/procfs.c b/src/common/procfs.c index 611dd92..f6dc490 100644 --- a/src/common/procfs.c +++ b/src/common/procfs.c @@ -159,7 +159,7 @@ int proc_set_oom_score_adj(int pid, int oom_score_adj) fprintf(fp, "%d", oom_score_adj); fclose(fp); - if(!lowmem) { + if (!lowmem) { lowmem = find_module("lowmem"); if (!lowmem) return RESOURCED_ERROR_FAIL; diff --git a/src/common/storage-helper.c b/src/common/storage-helper.c index 1b86a58..89309ef 100644 --- a/src/common/storage-helper.c +++ b/src/common/storage-helper.c @@ -89,9 +89,9 @@ resourced_ret_c get_storage_root_paths(int type, GSList **paths) } while (!readdir_r(dp, &dentry, &result) && result != NULL) { - if(dentry.d_name[0] == '.') + if (dentry.d_name[0] == '.') continue; - if(snprintf(buf, BUF_MAX, "%s/%s/content", RD_SYS_HOME, dentry.d_name) < 0) { + if (snprintf(buf, BUF_MAX, "%s/%s/content", RD_SYS_HOME, dentry.d_name) < 0) { _D("Fail to make root path of %s. This path will not be included", dentry.d_name); continue; } @@ -114,7 +114,7 @@ resourced_ret_c get_storage_root_paths(int type, GSList **paths) return RESOURCED_ERROR_FAIL; } - if(target.id >= 0) { + if (target.id >= 0) { if (storage_get_root_directory(target.id, &root_path) != STORAGE_ERROR_NONE) { _E("Failed to get root path of storage"); diff --git a/src/common/time-helper.c b/src/common/time-helper.c index 862f893..13f7b17 100644 --- a/src/common/time-helper.c +++ b/src/common/time-helper.c @@ -49,7 +49,7 @@ void time_stamp(char *timestamp) if (!localtime_r(&curTime.tv_sec, &local)) return; /* Current timestamp */ - strftime(ts,TIMESTAMP_LEN,"%y%m%d%H%M%S",&local); + strftime(ts, TIMESTAMP_LEN, "%y%m%d%H%M%S", &local); /* Append milliseconds */ snprintf(timestamp, sizeof(ts) + 8, "%s%d", ts, milli); } diff --git a/src/common/util.c b/src/common/util.c index dbfc391..fbca481 100644 --- a/src/common/util.c +++ b/src/common/util.c @@ -38,7 +38,7 @@ int exec_cmd(char *argv[], char *filename) int fd = -1; if (fork() == 0) { - fd= open(filename, O_WRONLY|O_TRUNC|O_CREAT, 0644); + fd = open(filename, O_WRONLY|O_TRUNC|O_CREAT, 0644); if (fd < 0) { _E("Failed to create/open file %s", filename); return RESOURCED_ERROR_FAIL; @@ -122,19 +122,20 @@ int parse_bytes(const char *b, size_t *s) } /* Split a string into words. */ -char *split(const char *c, size_t *l, const char *separator, char **state) { - char *current; +char *split(const char *c, size_t *l, const char *separator, char **state) +{ + char *current; - current = *state ? *state : (char*) c; + current = *state ? *state : (char*) c; - if (!*current || *c == 0) - return NULL; + if (!*current || *c == 0) + return NULL; - current += strspn(current, separator); - *l = strcspn(current, separator); - *state = current+*l; + current += strspn(current, separator); + *l = strcspn(current, separator); + *state = current + *l; - return (char*) current; + return (char*) current; } char *truncate_nl(char *s) @@ -155,7 +156,7 @@ char *strstrip(char *s) s += strspn(s, WHITESPACE); - for (e = strchr(s, 0); e > s; e --) + for (e = strchr(s, 0); e > s; e--) if (!strchr(WHITESPACE, e[-1])) break; @@ -166,9 +167,9 @@ char *strstrip(char *s) int str_to_strv(const char *str, char ***strv, const char *seperator) { - char *w, *state, *p; + char *w, *state, *p; char **v = NULL, **new = NULL; - size_t l; + size_t l; size_t i = 0; FOREACH_WORD_SEPARATOR(w, l, str, seperator, state) { @@ -204,7 +205,7 @@ size_t sizeof_strv(const char **strv) assert(strv); - while(strv[u++]) + while (strv[u++]) ; return u - 1; diff --git a/src/resourced-dbus/resourced-dbus.c b/src/resourced-dbus/resourced-dbus.c index 45342d2..7251f30 100644 --- a/src/resourced-dbus/resourced-dbus.c +++ b/src/resourced-dbus/resourced-dbus.c @@ -79,7 +79,7 @@ unsigned int resourced_dbus_pid_get_busnames(pid_t pid, char ***busnames) if (!names) return 0; - g_hash_table_iter_init (&iter, busname_hash); + g_hash_table_iter_init(&iter, busname_hash); for (i = 0; g_hash_table_iter_next(&iter, (void **)&busname, NULL); i++) names[i] = strndup(busname, strlen(busname)+1); @@ -197,7 +197,7 @@ static DBusMessage *resourced_dbus_handle_get_system_bus_pid_info(E_DBus_Object dbus_message_iter_init_append(reply, &iter); if (!dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "s", &sub)) { _E("Failed to open string array"); - dbus_message_unref (reply); + dbus_message_unref(reply); return NULL; } @@ -263,7 +263,7 @@ static DBusMessage *resourced_dbus_handle_get_system_bus_pid_info_all(E_DBus_Obj dbus_message_iter_init_append(reply, &iter); if (!dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "{uas}", &sub)) { _E("Failed to open string array"); - dbus_message_unref (reply); + dbus_message_unref(reply); return NULL; } @@ -432,7 +432,7 @@ static void resourced_dbus_get_list_names_callback(void *data, DBusMessage *msg, do { dbus_message_iter_get_basic(&sub, &busname); resourced_dbus_get_connection_unix_process_id(busname); - } while(dbus_message_iter_next(&sub)); + } while (dbus_message_iter_next(&sub)); } static bool resourced_dbus_get_list_names(void) @@ -584,15 +584,15 @@ static void resourced_dbus_name_owner_changed_callback(void *data, DBusMessage * return; } - /* If the name owner process is activated then: */ - /* arg_0: busname */ - /* arg_1: "" */ - /* arg_2: ":x.xxx" */ + /* If the name owner process is activated then: */ + /* arg_0: busname */ + /* arg_1: "" */ + /* arg_2: ":x.xxx" */ - /* If the name owner process is deactivated then: */ - /* arg_0: busname */ - /* arg_1: ":x.xxx" */ - /* arg_2: "" */ + /* If the name owner process is deactivated then: */ + /* arg_0: busname */ + /* arg_1: ":x.xxx" */ + /* arg_2: "" */ if (is_empty(busname)) { _E("NameOwnerChanged: arg_0 is empty"); diff --git a/src/tests/cpu/resourced_cpu_test.c b/src/tests/cpu/resourced_cpu_test.c index 7089100..d4f4c65 100644 --- a/src/tests/cpu/resourced_cpu_test.c +++ b/src/tests/cpu/resourced_cpu_test.c @@ -79,7 +79,7 @@ int cpu_app_cycle_check(void) req.tv_sec = time_sec; \ req.tv_nsec = 0; \ nanosleep(&req, &rem); \ - } while(0); + } while (0); printf("Checking app cycle. Launch an app and enter its pid:"); ret = scanf("%d", &app_pid); diff --git a/src/tests/network/resourced_data_usage_test.c b/src/tests/network/resourced_data_usage_test.c index cab7613..f8f6975 100644 --- a/src/tests/network/resourced_data_usage_test.c +++ b/src/tests/network/resourced_data_usage_test.c @@ -34,7 +34,7 @@ int data_usage_test_get_resourced_options() { return get_resourced_options(NULL); } - + int data_usage_test_set_net_restriction() { return set_net_restriction(NULL, NULL); @@ -161,7 +161,7 @@ int main(int argc, char *argv[]) TEST_START_MESSAGE("data-usage library"); - for(i = 0; data_usage_tests[i].test_func; ++i) { + for (i = 0; data_usage_tests[i].test_func; ++i) { _D("======================================="); _D("Current Test: %s", data_usage_tests[i].name); ret = (*data_usage_tests[i].test_func)(); diff --git a/src/utils/datausage-tool.c b/src/utils/datausage-tool.c index b281ecd..56925a0 100644 --- a/src/utils/datausage-tool.c +++ b/src/utils/datausage-tool.c @@ -425,7 +425,8 @@ const char *state_representation[] = { "EXCLUDED", }; -const char *convert_restriction_state(network_restriction_state state) { +const char *convert_restriction_state(network_restriction_state state) +{ if (state <= NETWORK_RESTRICTION_UNDEFINDED && state >= NETWORK_RESTRICTION_MAX_VALUE) { fprintf(stderr, "state not in range %d", state); @@ -536,8 +537,7 @@ int main(int argc, char **argv) }; ret_code = remove_restriction_full(param.app_id, &rst); - } - else + } else fprintf(stderr, "Revert restriction commands require -i\n"); if (ret_code != RESOURCED_ERROR_NONE) return ret_code; -- 2.7.4