summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHwankyu Jhun <h.jhun@samsung.com>2016-07-15 10:38:48 +0900
committerHwankyu Jhun <h.jhun@samsung.com>2016-07-18 10:30:51 +0900
commit2b57faf66cf945af5d712728cc2d9b02fe739e38 (patch)
treefbd95c11de413b589b61fd56ba07bfbb26137603
parent34f7cb59af5f28b66c5b958c3fbf4a9183bc4988 (diff)
downloadlaunchpad-2b57faf66cf945af5d712728cc2d9b02fe739e38.tar.gz
launchpad-2b57faf66cf945af5d712728cc2d9b02fe739e38.tar.bz2
launchpad-2b57faf66cf945af5d712728cc2d9b02fe739e38.zip
Adjust coding style
Change-Id: Ifac527030c050873f7e3be4d59716d224c7a2eaa Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
-rw-r--r--inc/launchpad_common.h15
-rw-r--r--inc/perf.h2
-rwxr-xr-xinc/preexec.h13
-rw-r--r--inc/sigchild.h9
-rwxr-xr-xsrc/launchpad.c76
-rw-r--r--src/launchpad_common.c13
-rw-r--r--src/launchpad_lib.c14
-rw-r--r--src/launchpad_loader.c13
-rw-r--r--src/loader_info.c25
9 files changed, 96 insertions, 84 deletions
diff --git a/inc/launchpad_common.h b/inc/launchpad_common.h
index 1c07962..4d7d43f 100644
--- a/inc/launchpad_common.h
+++ b/inc/launchpad_common.h
@@ -53,21 +53,6 @@
#define _D(fmt, arg...) LOGD(fmt, ##arg)
#define _W(fmt, arg...) LOGW(fmt, ##arg)
-#define retvm_if(expr, val, fmt, arg...) do { \
- if (expr) { \
- _E(fmt, ##arg); \
- _E("(%s) -> %s() return", #expr, __FUNCTION__); \
- return (val); \
- } \
-} while (0)
-
-#define retv_if(expr, val) do { \
- if (expr) { \
- _E("(%s) -> %s() return", #expr, __FUNCTION__); \
- return (val); \
- } \
-} while (0)
-
enum loader_arg {
LOADER_ARG_PATH,
LOADER_ARG_TYPE,
diff --git a/inc/perf.h b/inc/perf.h
index 319219c..3bc169f 100644
--- a/inc/perf.h
+++ b/inc/perf.h
@@ -46,7 +46,7 @@ static struct timeval __g_base_time = {
if (__g_base_time.tv_sec != 0) { \
timersub(&cur, &__g_base_time, &res); \
printf("%c[1;31m[%s,%d] %ld sec %ld msec "fmt \
- " %c[0m\n", 27, __FUNCTION__, \
+ " %c[0m\n", 27, __func__, \
__LINE__, res.tv_sec, \
res.tv_usec/1000, ##arg, 27);\
} \
diff --git a/inc/preexec.h b/inc/preexec.h
index d6a937e..23bc9c5 100755
--- a/inc/preexec.h
+++ b/inc/preexec.h
@@ -20,17 +20,17 @@
#include <glib.h>
#define PREEXEC_FILE SHARE_PREFIX"/preexec_list.txt"
-static int preexec_initialized = 0;
+static int preexec_initialized;
-GSList *preexec_list = NULL;
+static GSList *preexec_list;
typedef struct _preexec_list_t {
char *pkg_type;
char *so_path;
- int (*dl_do_pre_exe) (char *, char *);
+ int (*dl_do_pre_exe)(char *, char *);
} preexec_list_t;
-static void __preexec_list_free()
+static void __preexec_list_free(void)
{
GSList *iter = NULL;
preexec_list_t *type_t;
@@ -47,7 +47,6 @@ static void __preexec_list_free()
}
g_slist_free(preexec_list);
preexec_initialized = 0;
- return;
}
static inline void __preexec_init(int argc, char **argv)
@@ -59,7 +58,7 @@ static inline void __preexec_init(int argc, char **argv)
char *type = NULL;
char *sopath = NULL;
char *symbol = NULL;
- int (*func) (char *, char *) = NULL;
+ int (*func)(char *, char *) = NULL;
preexec_list_t *type_t = NULL;
preexec_file = fopen(PREEXEC_FILE, "rt");
@@ -166,7 +165,7 @@ static inline void __preexec_run(const char *pkg_type, const char *pkg_name,
#else
-static void __preexec_list_free()
+static void __preexec_list_free(void)
{
}
diff --git a/inc/sigchild.h b/inc/sigchild.h
index 9ea5b0f..cfa6476 100644
--- a/inc/sigchild.h
+++ b/inc/sigchild.h
@@ -27,7 +27,7 @@
#define AUL_DBUS_APPDEAD_SIGNAL "app_dead"
#define AUL_DBUS_APPLAUNCH_SIGNAL "app_launch"
-static GDBusConnection *bus = NULL;
+static GDBusConnection *bus;
static sigset_t oldmask;
static inline void __socket_garbage_collector(void)
@@ -165,8 +165,6 @@ static void __launchpad_process_sigchld(struct signalfd_siginfo *info)
killpg(child_pgid, SIGKILL);
__sigchild_action(child_pid);
}
-
- return;
}
static inline int __signal_init(void)
@@ -233,11 +231,14 @@ static inline int __signal_unblock_sigchld(void)
static inline int __signal_fini(void)
{
+#ifndef PRELOAD_ACTIVATE
+ int i;
+#endif
+
if (bus)
g_object_unref(bus);
#ifndef PRELOAD_ACTIVATE
- int i;
for (i = 0; i < _NSIG; i++)
signal(i, SIG_DFL);
#endif
diff --git a/src/launchpad.c b/src/launchpad.c
index 57a92e4..16fadc7 100755
--- a/src/launchpad.c
+++ b/src/launchpad.c
@@ -88,9 +88,9 @@ static candidate_process_context_t *__add_slot(int type, int loader_id,
int caller_pid, const char *loader_path, const char *extra,
int detection_method, int timeout_val);
static int __remove_slot(int type, int loader_id);
-static int __add_default_slots();
+static int __add_default_slots(void);
-static int __make_loader_id()
+static int __make_loader_id(void)
{
static int id = PAD_LOADER_ID_DYNAMIC_BASE;
@@ -346,8 +346,6 @@ static void __send_result_to_caller(int clifd, int ret, const char *app_path)
if (__real_send(clifd, ret) < 0)
__kill_process(ret);
-
- return;
}
static int __prepare_candidate_process(int type, int loader_id)
@@ -472,7 +470,7 @@ static int __normal_fork_exec(int argc, char **argv)
return 0;
}
-static void __real_launch(const char *app_path, bundle * kb)
+static void __real_launch(const char *app_path, bundle *kb)
{
int app_argc;
char **app_argv;
@@ -495,7 +493,7 @@ static void __real_launch(const char *app_path, bundle * kb)
}
static int __prepare_exec(const char *appid, const char *app_path,
- appinfo_t *menu_info, bundle * kb)
+ appinfo_t *menu_info, bundle *kb)
{
char *file_name;
char process_name[AUL_PR_NAME];
@@ -558,7 +556,8 @@ static int __launch_directly(const char *appid, const char *app_path, int clifd,
_delete_sock_path(getpid(), getuid());
PERF("prepare exec - first done");
- if ((ret = __prepare_exec(appid, app_path, menu_info, kb)) < 0)
+ ret = __prepare_exec(appid, app_path, menu_info, kb);
+ if (ret < 0)
exit(ret);
PERF("prepare exec - second done");
@@ -667,6 +666,7 @@ static guint __poll_fd(int fd, gushort events, GSourceFunc func, int type,
int r;
GPollFD *gpollfd;
GSource *src;
+ loader_context_t *lc;
src = g_source_new(&funcs, sizeof(GSource));
if (!src) {
@@ -674,7 +674,7 @@ static guint __poll_fd(int fd, gushort events, GSourceFunc func, int type,
return 0;
}
- gpollfd = (GPollFD *) g_malloc(sizeof(GPollFD));
+ gpollfd = (GPollFD *)g_malloc(sizeof(GPollFD));
if (!gpollfd) {
_E("out of memory");
g_source_destroy(src);
@@ -684,7 +684,7 @@ static guint __poll_fd(int fd, gushort events, GSourceFunc func, int type,
gpollfd->events = events;
gpollfd->fd = fd;
- loader_context_t *lc = malloc(sizeof(loader_context_t));
+ lc = malloc(sizeof(loader_context_t));
if (lc == NULL) {
g_free(gpollfd);
g_source_destroy(src);
@@ -722,8 +722,9 @@ static gboolean __handle_loader_client_event(gpointer data)
return G_SOURCE_REMOVE;
if (revents & (G_IO_HUP | G_IO_NVAL)) {
- SECURE_LOGE("Type %d candidate process was (POLLHUP|POLLNVAL), "
- "pid: %d", cpc->type, cpc->pid);
+ SECURE_LOGE("Type %d candidate process was " \
+ "(POLLHUP|POLLNVAL), pid: %d",
+ cpc->type, cpc->pid);
close(cpc->send_fd);
cpc->prepared = false;
@@ -762,8 +763,8 @@ static gboolean __handle_loader_event(gpointer data)
cpc->prepared = true;
cpc->send_fd = client_fd;
- SECURE_LOGD("Type %d candidate process was connected, "
- "pid: %d", type, cpc->pid);
+ SECURE_LOGD("Type %d candidate process was connected," \
+ " pid: %d", type, cpc->pid);
cpc->source = __poll_fd(client_fd, G_IO_IN | G_IO_HUP,
__handle_loader_client_event, type,
loader_id);
@@ -944,10 +945,13 @@ static candidate_process_context_t *__find_available_slot(const char *hwacc,
int len = 0;
int i;
- if (loader_name)
- type = _loader_info_find_type_by_loader_name(loader_info_list, loader_name);
- else
- type = _loader_info_find_type(loader_info_list, app_type, __is_hw_acc(hwacc));
+ if (loader_name) {
+ type = _loader_info_find_type_by_loader_name(loader_info_list,
+ loader_name);
+ } else {
+ type = _loader_info_find_type(loader_info_list,
+ app_type, __is_hw_acc(hwacc));
+ }
cpc = __find_slot(type, PAD_LOADER_ID_STATIC);
if (!cpc)
return NULL;
@@ -1073,11 +1077,16 @@ static gboolean __handle_launch_event(gpointer data)
if (menu_info->comp_type &&
strcmp(menu_info->comp_type, "svcapp") == 0) {
loader_id = PAD_LOADER_ID_DIRECT;
- } else if ((loader_id = __get_loader_id(kb)) <= PAD_LOADER_ID_STATIC) {
- cpc = __find_available_slot(menu_info->hwacc, menu_info->app_type, menu_info->loader_name);
} else {
- type = LAUNCHPAD_TYPE_DYNAMIC;
- cpc = __find_slot(type, loader_id);
+ loader_id = __get_loader_id(kb);
+ if (loader_id <= PAD_LOADER_ID_STATIC) {
+ cpc = __find_available_slot(menu_info->hwacc,
+ menu_info->app_type,
+ menu_info->loader_name);
+ } else {
+ type = LAUNCHPAD_TYPE_DYNAMIC;
+ cpc = __find_slot(type, loader_id);
+ }
}
_modify_bundle(kb, cr.pid, menu_info, pkt->cmd);
@@ -1152,7 +1161,7 @@ static candidate_process_context_t *__add_slot(int type, int loader_id,
fd = __listen_candidate_process(cpc->type, cpc->loader_id);
if (fd == -1) {
- _E("[launchpad] Listening the socket to "
+ _E("[launchpad] Listening the socket to " \
"the type %d candidate process failed.",
cpc->type);
free(cpc);
@@ -1176,8 +1185,8 @@ static int __remove_slot(int type, int loader_id)
{
candidate_process_context_t *cpc;
GList *iter;
- iter = candidate_slot_list;
+ iter = candidate_slot_list;
while (iter) {
cpc = (candidate_process_context_t *)iter->data;
if (type == cpc->type && loader_id == cpc->loader_id) {
@@ -1263,7 +1272,8 @@ static int __init_label_monitor_fd(void)
return -1;
}
- pollfd = __poll_fd(fd, G_IO_IN, (GSourceFunc)__handle_label_monitor, 0, 0);
+ pollfd = __poll_fd(fd, G_IO_IN,
+ (GSourceFunc)__handle_label_monitor, 0, 0);
if (pollfd == 0) {
close(fd);
return -1;
@@ -1278,9 +1288,11 @@ static void __add_slot_from_info(gpointer data, gpointer user_data)
candidate_process_context_t *cpc;
bundle_raw *extra = NULL;
int len;
+ int ret;
if (!strcmp(info->exe, "null")) {
- cpc = __add_slot(LAUNCHPAD_TYPE_USER + user_slot_offset, PAD_LOADER_ID_DIRECT,
+ cpc = __add_slot(LAUNCHPAD_TYPE_USER + user_slot_offset,
+ PAD_LOADER_ID_DIRECT,
0, info->exe, NULL, 0, 0);
if (cpc == NULL)
return;
@@ -1294,13 +1306,17 @@ static void __add_slot_from_info(gpointer data, gpointer user_data)
if (info->extra)
bundle_encode(info->extra, &extra, &len);
- cpc = __add_slot(LAUNCHPAD_TYPE_USER + user_slot_offset, PAD_LOADER_ID_STATIC,
- 0, info->exe, (char *)extra, info->detection_method, info->timeout_val);
+ cpc = __add_slot(LAUNCHPAD_TYPE_USER + user_slot_offset,
+ PAD_LOADER_ID_STATIC,
+ 0, info->exe, (char *)extra,
+ info->detection_method, info->timeout_val);
if (cpc == NULL)
return;
- if (__prepare_candidate_process(LAUNCHPAD_TYPE_USER + user_slot_offset,
- PAD_LOADER_ID_STATIC) != 0)
+ ret = __prepare_candidate_process(
+ LAUNCHPAD_TYPE_USER + user_slot_offset,
+ PAD_LOADER_ID_STATIC);
+ if (ret != 0)
return;
info->type = LAUNCHPAD_TYPE_USER + user_slot_offset;
@@ -1381,7 +1397,7 @@ static void __set_priority(void)
res = setpriority(PRIO_PROCESS, 0, -12);
if (res == -1) {
- SECURE_LOGE("Setting process (%d) priority to -12 failed, "
+ SECURE_LOGE("Setting process (%d) priority to -12 failed, " \
"errno: %d (%s)", getpid(), errno,
strerror_r(errno, err_str, sizeof(err_str)));
}
diff --git a/src/launchpad_common.c b/src/launchpad_common.c
index 7109129..42c6267 100644
--- a/src/launchpad_common.c
+++ b/src/launchpad_common.c
@@ -47,7 +47,7 @@
#define MAX_CMD_BUFSZ 1024
#define MAX_PENDING_CONNECTIONS 10
-#define CONNECT_RETRY_TIME 100 * 1000
+#define CONNECT_RETRY_TIME (100 * 1000)
#define CONNECT_RETRY_COUNT 3
#define AUL_PKT_HEADER_SIZE (sizeof(int) + sizeof(int) + sizeof(int))
@@ -67,9 +67,9 @@ static int __read_proc(const char *path, char *buf, int size)
if (ret <= 0) {
close(fd);
return -1;
- } else
- buf[ret] = 0;
+ }
+ buf[ret] = 0;
close(fd);
return ret;
@@ -269,8 +269,9 @@ app_pkt_t *_recv_pkt_raw(int fd, int *clifd, struct ucred *cr)
sun_size = sizeof(struct sockaddr_un);
- if ((*clifd = accept(fd, (struct sockaddr *)&aul_addr,
- (socklen_t *) &sun_size)) == -1) {
+ *clifd = accept(fd, (struct sockaddr *)&aul_addr,
+ (socklen_t *) &sun_size);
+ if (*clifd == -1) {
if (errno != EINTR)
_E("accept error");
return NULL;
@@ -742,7 +743,7 @@ static int __delete_dir(const char *path)
ret = stat(buf, &statbuf);
if (ret == 0) {
if (S_ISDIR(statbuf.st_mode))
- __delete_dir(buf);
+ __delete_dir(buf);
else
unlink(buf);
}
diff --git a/src/launchpad_lib.c b/src/launchpad_lib.c
index 3f5b1ef..aa4a4b9 100644
--- a/src/launchpad_lib.c
+++ b/src/launchpad_lib.c
@@ -50,7 +50,7 @@ static bundle *__bundle;
static int __loader_type = LAUNCHPAD_TYPE_UNSUPPORTED;
static int __loader_id;
-static void __at_exit_to_release_bundle()
+static void __at_exit_to_release_bundle(void)
{
if (__bundle)
bundle_free(__bundle);
@@ -70,8 +70,8 @@ static int __prepare_exec(const char *appid, const char *app_path,
appid, pkg_type, app_path);
ret = security_manager_prepare_app(appid);
if (ret != SECURITY_MANAGER_SUCCESS) {
- _D("fail to set privileges - check your package's credential: "
- "%d\n", ret);
+ _D("fail to set privileges - " \
+ "check your package's credential: %d\n", ret);
return -1;
}
@@ -121,7 +121,7 @@ static int __default_launch_cb(bundle *kb, const char *appid,
if (strncmp(high_priority, "true", 4) == 0) {
res = setpriority(PRIO_PROCESS, 0, -10);
if (res == -1) {
- SECURE_LOGE("Setting process (%d) priority "
+ SECURE_LOGE("Setting process (%d) priority " \
"to -10 failed, errno: %d (%s)",
getpid(), errno,
strerror_r(errno, err_str, sizeof(err_str)));
@@ -133,7 +133,7 @@ static int __default_launch_cb(bundle *kb, const char *appid,
if (__prepare_exec(appid, app_path, pkg_type, loader_type) < 0) {
_E("__candidate_process_prepare_exec() failed");
if (access(app_path, F_OK | R_OK)) {
- SECURE_LOGE("access() failed for file: \"%s\", "
+ SECURE_LOGE("access() failed for file: \"%s\", " \
"error: %d (%s)", app_path, errno,
strerror_r(errno, err_str, sizeof(err_str)));
}
@@ -294,7 +294,7 @@ static int __before_loop(int argc, char **argv)
int res = setpriority(PRIO_PROCESS, 0, LOWEST_PRIO);
if (res == -1) {
- SECURE_LOGE("Setting process (%d) priority to %d failed, "
+ SECURE_LOGE("Setting process (%d) priority to %d failed, " \
"errno: %d (%s)", getpid(), LOWEST_PRIO, errno,
strerror_r(errno, err_str, sizeof(err_str)));
}
@@ -324,7 +324,7 @@ static int __before_loop(int argc, char **argv)
#ifdef _APPFW_FEATURE_LOADER_PRIORITY
res = setpriority(PRIO_PGRP, 0, 0);
if (res == -1) {
- SECURE_LOGE("Setting process (%d) priority to 0 failed, "
+ SECURE_LOGE("Setting process (%d) priority to 0 failed, " \
"errno: %d (%s)", getpid(), errno,
strerror_r(errno, err_str, sizeof(err_str)));
}
diff --git a/src/launchpad_loader.c b/src/launchpad_loader.c
index c7d7220..0868cd1 100644
--- a/src/launchpad_loader.c
+++ b/src/launchpad_loader.c
@@ -37,7 +37,7 @@
#define LOADER_TYPE_SW "sw-loader"
-extern bundle *launchpad_loader_get_bundle();
+extern bundle *launchpad_loader_get_bundle(void);
static Ecore_Fd_Handler *__fd_handler;
static loader_receiver_cb __receiver;
@@ -81,6 +81,7 @@ static void __init_theme(void)
char *theme = elm_theme_list_item_path_get(eina_list_data_get(
elm_theme_list_get(NULL)), NULL);
Eina_Bool is_exist = edje_file_group_exists(theme, "*");
+
if (!is_exist)
_D("theme path: %s", theme);
@@ -241,8 +242,10 @@ static int __loader_launch_cb(int argc, char **argv, const char *app_path,
const char *hwacc;
bundle *kb = launchpad_loader_get_bundle();
int acc = SW_ACC;
+ loader_convertible convert;
- vconf_ignore_key_changed(VCONFKEY_SETAPPL_APP_HW_ACCELERATION, __vconf_cb);
+ vconf_ignore_key_changed(VCONFKEY_SETAPPL_APP_HW_ACCELERATION,
+ __vconf_cb);
if (kb == NULL)
return 0;
@@ -257,7 +260,7 @@ static int __loader_launch_cb(int argc, char **argv, const char *app_path,
acc = HW_ACC;
}
- loader_convertible convert = __converter_table[__type][acc];
+ convert = __converter_table[__type][acc];
if (convert)
convert();
@@ -309,7 +312,7 @@ do_dlopen:
handle = dlopen(argv[LOADER_ARG_PATH],
RTLD_LAZY | RTLD_GLOBAL | RTLD_DEEPBIND);
if (handle == NULL) {
- _E("dlopen failed(%s). Please complile with -fPIE and "
+ _E("dlopen failed(%s). Please complile with -fPIE and " \
"link with -pie flag", dlerror());
goto do_exec;
}
@@ -346,7 +349,7 @@ do_exec:
setenv("LD_LIBRARY_PATH", libdir, 1);
free(libdir);
if (execv(argv[LOADER_ARG_PATH], argv) < 0) {
- SECURE_LOGE("execv() failed for file: \"%s\", "
+ SECURE_LOGE("execv() failed for file: \"%s\", " \
"error: %d (%s)", argv[LOADER_ARG_PATH], errno,
strerror_r(errno, err_str, sizeof(err_str)));
}
diff --git a/src/loader_info.c b/src/loader_info.c
index b683539..c0ded9f 100644
--- a/src/loader_info.c
+++ b/src/loader_info.c
@@ -92,8 +92,11 @@ static void __parse_app_types(loader_info_t *info, char *line)
while (token) {
refined_tok[0] = '\0';
sscanf(token, "%s", refined_tok);
- if (refined_tok[0] != '\0' && strcasecmp("null", refined_tok) != 0)
- info->app_types = g_list_append(info->app_types, strdup(refined_tok));
+ if (refined_tok[0] != '\0' &&
+ strcasecmp("null", refined_tok) != 0) {
+ info->app_types = g_list_append(info->app_types,
+ strdup(refined_tok));
+ }
token = strtok_r(NULL, "|", &savedptr);
}
}
@@ -194,7 +197,7 @@ static GList *__parse_file(GList *list, const char *path)
cur_info->timeout_val = atoi(tok2);
} else if (strcasecmp(TAG_EXTRA, tok1) == 0) {
__parse_extra(cur_info, buf);
- } else if (strcasecmp(TAG_EXTRA_ARRAY,tok1) == 0) {
+ } else if (strcasecmp(TAG_EXTRA_ARRAY, tok1) == 0) {
__flush_extra_array(cur_info->extra, key, extra_array);
extra_array = NULL;
key = strdup(tok2);
@@ -320,12 +323,15 @@ static int __comp_name(gconstpointer a, gconstpointer b)
int _loader_info_find_type(GList *info, const char *app_type, bool hwacc)
{
- GList *cur = NULL;
+ GList *cur;
- if (hwacc)
- cur = g_list_find_custom(info, app_type, __comp_app_type_with_hw_acc);
- else
- cur = g_list_find_custom(info, app_type, __comp_app_type_with_sw_acc);
+ if (hwacc) {
+ cur = g_list_find_custom(info, app_type,
+ __comp_app_type_with_hw_acc);
+ } else {
+ cur = g_list_find_custom(info, app_type,
+ __comp_app_type_with_sw_acc);
+ }
if (cur == NULL)
return -1;
@@ -399,7 +405,8 @@ int *_loader_get_alternative_types(GList *info, int type, int *len)
if (!i->alternative_loaders)
return NULL;
- return __make_type_array(info, i->alternative_loaders, len);
+ return __make_type_array(info, i->alternative_loaders,
+ len);
}
cur = g_list_next(cur);
}