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;
}
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;
}
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;
r = 0;
finish:
- for (i=0; i<num_section; i++)
+ for (i = 0; i < num_section; i++)
if (sections[i])
free(sections[i]);
#define EDBUS_INIT_RETRY_COUNT 5
-struct edbus_list{
+struct edbus_list {
char *signal_name;
char *signal_path;
value = va_arg(args, char *);
_I("key(%s), value(%s)", key, value);
dbus_message_iter_open_container(&aiter, DBUS_TYPE_DICT_ENTRY, NULL, &piter);
- dbus_message_iter_append_basic (&piter, DBUS_TYPE_STRING, &key);
- dbus_message_iter_append_basic (&piter, DBUS_TYPE_STRING, &value);
+ dbus_message_iter_append_basic(&piter, DBUS_TYPE_STRING, &key);
+ dbus_message_iter_append_basic(&piter, DBUS_TYPE_STRING, &value);
dbus_message_iter_close_container(&aiter, &piter);
}
}
int launch_system_app_by_dbus(const char *dest, const char *path,
- const char *iface, const char *method, int num, ...)
+ const char *iface, const char *method, int num, ...)
{
int ret;
va_list args;
} else {
unsigned new_offset;
root = filemap_node_new(fm, remaining, str_size, &new_offset);
- _D("insert node child remaining = %s",remaining);
+ _D("insert node child remaining = %s", remaining);
if (root)
g_atomic_int_set(¤t->children, new_offset);
}
}
if (!fgets(buffer, BUF_MAX, fp)) {
- _E ("fgets() failed");
+ _E("fgets() failed");
fclose(fp);
return RESOURCED_ERROR_FAIL;
}
fprintf(fp, "%d", oom_score_adj);
fclose(fp);
- if(!lowmem) {
+ if (!lowmem) {
lowmem = find_module("lowmem");
if (!lowmem)
return RESOURCED_ERROR_FAIL;
}
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;
}
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");
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);
}
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;
}
/* 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)
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;
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) {
assert(strv);
- while(strv[u++])
+ while (strv[u++])
;
return u - 1;
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);
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;
}
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;
}
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)
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");
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);
{
return get_resourced_options(NULL);
}
-
+
int data_usage_test_set_net_restriction()
{
return set_net_restriction(NULL, NULL);
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)();
"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);
};
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;