Adjust coding rules 61/68061/3 submit/tizen/20160502.063802
authorHwankyu Jhun <h.jhun@samsung.com>
Mon, 2 May 2016 05:13:08 +0000 (14:13 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Mon, 2 May 2016 07:20:33 +0000 (16:20 +0900)
Change-Id: Id16e76786fdc78b9f4b849e01e8d12e541b8fabe
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
12 files changed:
inc/key.h
inc/launchpad.h
inc/launchpad_common.h
inc/perf.h
inc/preexec.h
inc/preload.h
inc/process_pool_preload.h
inc/sigchild.h
src/launchpad.c
src/launchpad_common.c
src/launchpad_lib.c
src/launchpad_loader.c

index 25554cd970c81c2ef091720f9e81b72963d256e1..d2f09f898745e78875deab516c211651db2be179 100644 (file)
--- a/inc/key.h
+++ b/inc/key.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
  *
  * Licensed under the Apache License, Version 2.0 (the License);
  * you may not use this file except in compliance with the License.
index f4205ce856d384b31acad6d5816891e56b33ec26..aaa01a8862e233cf444b285f151b97a93a2ebdb8 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
  *
  * Licensed under the Apache License, Version 2.0 (the License);
  * you may not use this file except in compliance with the License.
@@ -25,13 +25,15 @@ extern "C" {
 
 typedef void (*loader_create_cb)(bundle *extra, int type, void *user_data);
 typedef int (*loader_launch_cb)(int argc, char **argv, const char *app_path,
-               const char *appid, const char *pkgid, const char *pkg_type, void *user_data);
+               const char *appid, const char *pkgid, const char *pkg_type,
+               void *user_data);
 typedef int (*loader_terminate_cb)(int argc, char **argv, void *user_data);
 
 typedef void (*loader_receiver_cb)(int fd);
 typedef void (*loader_loop_begin_cb)(void *user_data);
 typedef void (*loader_loop_quit_cb)(void *user_data);
-typedef void (*loader_add_fd_cb)(void *user_data, int fd, loader_receiver_cb receiver);
+typedef void (*loader_add_fd_cb)(void *user_data, int fd,
+               loader_receiver_cb receiver);
 typedef void (*loader_remove_fd_cb)(void *user_data, int fd);
 
 typedef struct {
@@ -58,7 +60,9 @@ enum LAUNCHPAD_TYPE {
        LAUNCHPAD_TYPE_MAX
 };
 
-int launchpad_loader_main(int argc, char **argv, loader_lifecycle_callback_s *callbacks, loader_adapter_s *adapter, void *user_data);
+int launchpad_loader_main(int argc, char **argv,
+               loader_lifecycle_callback_s *callbacks,
+               loader_adapter_s *adapter, void *user_data);
 
 #ifdef __cplusplus
 }
index d27fe289070963042f22adf793fea6e2e41c9537..6eaf630a33b164f447974bb55061b099bd278c9c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
  *
  * Licensed under the Apache License, Version 2.0 (the License);
  * you may not use this file except in compliance with the License.
@@ -14,8 +14,8 @@
  * limitations under the License.
  */
 
-#ifndef __LAUNCHPAD_COMMON__
-#define __LAUNCHPAD_COMMON__
+#ifndef __LAUNCHPAD_COMMON_H__
+#define __LAUNCHPAD_COMMON_H__
 
 #define _GNU_SOURCE
 
@@ -89,20 +89,21 @@ typedef struct {
 } appinfo_t;
 
 char *_proc_get_cmdline_bypid(int pid);
-void _modify_bundle(bundle * kb, int caller_pid, appinfo_t *menu_info, int cmd);
+void _modify_bundle(bundle *kb, int caller_pid, appinfo_t *menu_info, int cmd);
 
 int _create_server_sock(const char *name);
 app_pkt_t *_recv_pkt_raw(int fd, int *clifd, struct ucred *cr);
 int _send_pkt_raw(int client_fd, app_pkt_t *pkt);
 int  _connect_to_launchpad(int type, int id);
 void _set_sock_option(int fd, int cli);
-void _set_env(appinfo_t *menu_info, bundle * kb);
-char** _create_argc_argv(bundle * kb, int *margc);
+void _set_env(appinfo_t *menu_info, bundle *kb);
+char **_create_argc_argv(bundle *kb, int *margc);
 char *_get_libdir(const char *path);
 
-appinfo_t_appinfo_create(bundle *kb);
+appinfo_t *_appinfo_create(bundle *kb);
 void _appinfo_free(appinfo_t *menu_info);
 char *_appinfo_get_app_path(appinfo_t *menu_info);
 int _proc_get_attr_by_pid(int pid, char *buf, int size);
 
-#endif
+#endif /* __LAUNCHPAD_COMMON_H__ */
+
index 1dd847f3d610eefd91293b7b8573234c1e30d1ab..319219cc582c628606a7075f10b6f635acb2f1ed 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
  *
  * Licensed under the Apache License, Version 2.0 (the License);
  * you may not use this file except in compliance with the License.
@@ -25,31 +25,32 @@ static struct timeval __g_base_time = {
        .tv_usec = 0
 };
 
-#define INIT_PERF(kb)\
-do {\
-       const char *tmp;\
-       struct timeval tv;\
-       tmp = bundle_get_val(kb, AUL_K_STARTTIME);\
-       if (tmp != NULL)\
-               sscanf(tmp, "%ld/%ld", &tv.tv_sec, &tv.tv_usec);\
-       else\
-               gettimeofday(&tv, NULL);\
-       __g_base_time.tv_sec = tv.tv_sec;\
-       __g_base_time.tv_usec = tv.tv_usec;\
-} while (0);
-
-#define PERF(fmt, arg...)\
-do {\
-       struct timeval cur;\
-       struct timeval res;\
-       gettimeofday(&cur, NULL);\
-       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__, __LINE__, \
-                               res.tv_sec, res.tv_usec/1000, ##arg, 27);\
-       } \
-} while (0);
+#define INIT_PERF(kb) \
+       do { \
+               const char *tmp; \
+               struct timeval tv; \
+               tmp = bundle_get_val(kb, AUL_K_STARTTIME); \
+               if (tmp != NULL) \
+                       sscanf(tmp, "%ld/%ld", &tv.tv_sec, &tv.tv_usec); \
+               else \
+                       gettimeofday(&tv, NULL); \
+               __g_base_time.tv_sec = tv.tv_sec; \
+               __g_base_time.tv_usec = tv.tv_usec; \
+       } while (0)
+
+#define PERF(fmt, arg...) \
+       do { \
+               struct timeval cur; \
+               struct timeval res; \
+               gettimeofday(&cur, NULL); \
+               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__, \
+                                       __LINE__, res.tv_sec, \
+                                       res.tv_usec/1000, ##arg, 27);\
+               } \
+       } while (0)
 
 #else
 
@@ -58,5 +59,5 @@ do {\
 
 #endif
 
-#endif
+#endif /* __PERF_H__ */
 
index 98de3c611a071c6f60644903e457a840a8945bb4..d6a937ec3ea85e324dc992b2ea8f914ff578b11d 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
  *
  * Licensed under the Apache License, Version 2.0 (the License);
  * you may not use this file except in compliance with the License.
index eb1e9edcb98f3204504220d1802f053290a8ae4c..c4dac2ae2f8abea1dc1bfcd193294ec58d0ad7cb 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
  *
  * Licensed under the Apache License, Version 2.0 (the License);
  * you may not use this file except in compliance with the License.
@@ -108,7 +108,7 @@ static inline int __change_cmdline(char *cmdline)
 static inline void __preload_exec(int argc, char **argv)
 {
        void *handle = NULL;
-       int (*dl_main) (int, char **);
+       int (*dl_main)(int, char **);
        char *error = NULL;
 
        if (!preload_initialized)
@@ -134,10 +134,9 @@ static inline void __preload_exec(int argc, char **argv)
                }
 
 #ifdef _APPFW_FEATURE_PRIORITY_CHANGE
-               int res = setpriority(PRIO_PROCESS, 0, 0);
-               if (res == -1)
-               {
-                       SECURE_LOGE("Setting process (%d) priority to 0 failed, errno: %d (%s)",
+               if (setpriority(PRIO_PROCESS, 0, 0) == -1) {
+                       SECURE_LOGE("Setting process (%d) priority to 0 failed,"
+                                       " errno: %d (%s)",
                                        getpid(), errno, strerror(errno));
                }
 #endif
index d2b1d418fb55a43a4d92d7e7ba1ed61bea6842f3..aa84e515fec55055f551c284f9c38b5f9828ec9d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
  *
  * Licensed under the Apache License, Version 2.0 (the License);
  * you may not use this file except in compliance with the License.
 #include <string.h>
 #include <dlfcn.h>
 
-#define PROCESS_POOL_PRELOAD_FILE SHARE_PREFIX"/launchpad-process-pool-preload-list.txt"
+#define PROCESS_POOL_PRELOAD_FILE \
+       SHARE_PREFIX"/launchpad-process-pool-preload-list.txt"
 
 static int g_dlopen_size = 5;
 static int g_dlopen_count = 0;
-static void** g_dlopen_handle_list = NULL;
+static void **g_dlopen_handle_list = NULL;
 
 static inline int __preload_save_dlopen_handle(void *handle)
 {
+       void **tmp;
+
        if (!handle)
                return 1;
 
        if (g_dlopen_count == g_dlopen_size || !g_dlopen_handle_list) {
-               void** tmp =
-                       realloc(g_dlopen_handle_list, 2 * g_dlopen_size * sizeof(void *));
-               if (NULL == tmp) {
+               tmp = realloc(g_dlopen_handle_list,
+                               2 * g_dlopen_size * sizeof(void *));
+               if (tmp == NULL) {
                        _E("out of memory\n");
                        dlclose(handle);
                        return 1;
@@ -51,11 +54,13 @@ static inline int __preload_save_dlopen_handle(void *handle)
 static inline void __preload_fini_for_process_pool(void)
 {
        int i = 0;
+       void *handle;
+
        if (!g_dlopen_handle_list)
                return;
 
        for (i = 0; i < g_dlopen_count; ++i) {
-               void *handle = g_dlopen_handle_list[i];
+               handle = g_dlopen_handle_list[i];
                if (handle) {
                        if (0 != dlclose(handle))
                                _E("dlclose failed\n");
@@ -69,12 +74,15 @@ static inline void __preload_fini_for_process_pool(void)
 
 static inline void __preload_init_for_process_pool(void)
 {
-       if (atexit(__preload_fini_for_process_pool) != 0)
-               _E("Cannot register atexit callback. Libraries will not be unloaded");
-
        void *handle = NULL;
        char soname[MAX_LOCAL_BUFSZ] = { 0, };
        FILE *preload_list = NULL;
+       size_t len;
+
+       if (atexit(__preload_fini_for_process_pool) != 0) {
+               _E("Cannot register atexit callback. "
+                               "Libraries will not be unloaded");
+       }
 
        preload_list = fopen(PROCESS_POOL_PRELOAD_FILE, "rt");
        if (preload_list == NULL) {
@@ -83,7 +91,7 @@ static inline void __preload_init_for_process_pool(void)
        }
 
        while (fgets(soname, MAX_LOCAL_BUFSZ, preload_list) > 0) {
-               size_t len = strnlen(soname, MAX_LOCAL_BUFSZ);
+               len = strnlen(soname, MAX_LOCAL_BUFSZ);
                if (len > 0)
                        soname[len - 1] = '\0';
 
@@ -103,4 +111,5 @@ static inline void __preload_init_for_process_pool(void)
        fclose(preload_list);
 }
 
-#endif //__PROCESS_POOL_PRELOAD_H__
+#endif /* __PROCESS_POOL_PRELOAD_H__ */
+
index 6228662fe39979924d38daa3a2ce8ba727592a29..c982fba3081df939a1b45049d9625f107be41bec 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
  *
  * Licensed under the Apache License, Version 2.0 (the License);
  * you may not use this file except in compliance with the License.
@@ -62,7 +62,8 @@ static inline int __send_app_dead_signal_dbus(int dead_pid)
        if (bus == NULL) {
                bus = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
                if (bus == NULL) {
-                       _E("Failed to connect to the D-BUS daemon: %s", err->message);
+                       _E("Failed to connect to the D-BUS daemon: %s",
+                                       err->message);
                        g_error_free(err);
                        return -1;
                }
@@ -93,25 +94,29 @@ static inline int __send_app_dead_signal_dbus(int dead_pid)
        return 0;
 }
 
-static inline int __send_app_launch_signal_dbus(int launch_pid, const char *app_id)
+static inline int __send_app_launch_signal_dbus(int launch_pid,
+               const char *app_id)
 {
        GError *err = NULL;
+       GVariant *param;
 
        if (bus == NULL) {
                bus = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
                if (bus == NULL) {
-                       _E("Failed to connect to the D-BUS daemon: %s", err->message);
+                       _E("Failed to connect to the D-BUS daemon: %s",
+                                       err->message);
                        g_error_free(err);
                        return -1;
                }
        }
 
+       param = g_variant_new("(us)", launch_pid, app_id);
        if (g_dbus_connection_emit_signal(bus,
                                        NULL,
                                        AUL_DBUS_PATH,
                                        AUL_DBUS_SIGNAL_INTERFACE,
                                        AUL_DBUS_APPLAUNCH_SIGNAL,
-                                       g_variant_new("(us)", launch_pid, app_id),
+                                       param,
                                        &err) == FALSE) {
                _E("g_dbus_connection_emit_signal() is failed: %s",
                                        err->message);
index 9a6da8fb4343283c33ce4644a8a91e82a9d3ef20..665f2ec54169beb5f207504cd7a50b753b33aaf5 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
  *
  * Licensed under the Apache License, Version 2.0 (the License);
  * you may not use this file except in compliance with the License.
@@ -79,8 +79,9 @@ typedef struct {
 
 static GList *candidate_slot_list;
 static int sys_hwacc = -1;
-static candidate_process_context_t *__add_slot(int type, int loader_id, int caller_pid, const char *loader_path,
-               const char *extra, bool enabled, int detection_method, int timeout_val);
+static candidate_process_context_t *__add_slot(int type, int loader_id,
+               int caller_pid, const char *loader_path, const char *extra,
+               bool enabled, int detection_method, int timeout_val);
 static int __remove_slot(int type, int loader_id);
 static int __add_default_slots();
 
@@ -93,13 +94,15 @@ static int __make_loader_id()
 
 static candidate_process_context_t *__find_slot_from_static_type(int type)
 {
+       candidate_process_context_t *cpc;
        GList *iter = candidate_slot_list;
 
-       if (type == LAUNCHPAD_TYPE_DYNAMIC || type == LAUNCHPAD_TYPE_UNSUPPORTED)
+       if (type == LAUNCHPAD_TYPE_DYNAMIC ||
+                       type == LAUNCHPAD_TYPE_UNSUPPORTED)
                return NULL;
 
        while (iter) {
-               candidate_process_context_t *cpc = (candidate_process_context_t *)iter->data;
+               cpc = (candidate_process_context_t *)iter->data;
                if (type == cpc->type)
                        return cpc;
 
@@ -111,10 +114,11 @@ static candidate_process_context_t *__find_slot_from_static_type(int type)
 
 static candidate_process_context_t *__find_slot_from_pid(int pid)
 {
+       candidate_process_context_t *cpc;
        GList *iter = candidate_slot_list;
 
        while (iter) {
-               candidate_process_context_t *cpc = (candidate_process_context_t *)iter->data;
+               cpc = (candidate_process_context_t *)iter->data;
                if (pid == cpc->pid)
                        return cpc;
 
@@ -126,10 +130,11 @@ static candidate_process_context_t *__find_slot_from_pid(int pid)
 
 static candidate_process_context_t *__find_slot_from_caller_pid(int caller_pid)
 {
+       candidate_process_context_t *cpc;
        GList *iter = candidate_slot_list;
 
        while (iter) {
-               candidate_process_context_t *cpc = (candidate_process_context_t *)iter->data;
+               cpc = (candidate_process_context_t *)iter->data;
                if (caller_pid == cpc->caller_pid)
                        return cpc;
 
@@ -141,10 +146,11 @@ static candidate_process_context_t *__find_slot_from_caller_pid(int caller_pid)
 
 static candidate_process_context_t *__find_slot_from_loader_id(int id)
 {
+       candidate_process_context_t *cpc;
        GList *iter = candidate_slot_list;
 
        while (iter) {
-               candidate_process_context_t *cpc = (candidate_process_context_t *)iter->data;
+               cpc = (candidate_process_context_t *)iter->data;
                if (id == cpc->loader_id)
                        return cpc;
 
@@ -166,8 +172,10 @@ static void __kill_process(int pid)
 {
        char err_str[MAX_LOCAL_BUFSZ] = { 0, };
 
-       if (kill(pid, SIGKILL) == -1)
-               _E("send SIGKILL: %s", strerror_r(errno, err_str, sizeof(err_str)));
+       if (kill(pid, SIGKILL) == -1) {
+               _E("send SIGKILL: %s",
+                               strerror_r(errno, err_str, sizeof(err_str)));
+       }
 }
 
 static void __refuse_candidate_process(int server_fd)
@@ -199,13 +207,13 @@ static int __accept_candidate_process(int server_fd, int *out_client_fd,
        int client_pid = 0;
        int recv_ret = 0;
 
-       if (server_fd == -1 || out_client_fd == NULL || out_client_pid == NULL) {
+       if (server_fd == -1 || out_client_fd == NULL ||
+                       out_client_pid == NULL) {
                _E("arguments error!");
                goto error;
        }
 
        client_fd = accept(server_fd, NULL, NULL);
-
        if (client_fd == -1) {
                _E("accept error!");
                goto error;
@@ -213,8 +221,8 @@ static int __accept_candidate_process(int server_fd, int *out_client_fd,
 
        _set_sock_option(client_fd, 1);
 
-       recv_ret = recv(client_fd, &client_pid, sizeof(client_pid), MSG_WAITALL);
-
+       recv_ret = recv(client_fd, &client_pid, sizeof(client_pid),
+                       MSG_WAITALL);
        if (recv_ret == -1) {
                _E("recv error!");
                goto error;
@@ -241,8 +249,9 @@ static int __listen_candidate_process(int type, int loader_id)
 
        memset(&addr, 0x00, sizeof(struct sockaddr_un));
        addr.sun_family = AF_UNIX;
-       snprintf(addr.sun_path, sizeof(addr.sun_path), "%s/%d/%s%d-%d", SOCKET_PATH, getuid(),
-               LAUNCHPAD_LOADER_SOCKET_NAME, type, loader_id);
+       snprintf(addr.sun_path, sizeof(addr.sun_path), "%s/%d/%s%d-%d",
+                       SOCKET_PATH, getuid(), LAUNCHPAD_LOADER_SOCKET_NAME,
+                       type, loader_id);
 
        fd = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0);
        if (fd < 0) {
@@ -280,12 +289,13 @@ error:
        return -1;
 }
 
-static int __set_access(const char* appId)
+static int __set_access(const char *appid)
 {
-       return security_manager_prepare_app(appId) == SECURITY_MANAGER_SUCCESS ? 0 : -1;
+       return security_manager_prepare_app(appid);
 }
 
-static int __get_launchpad_type(const char* internal_pool, const char* hwacc, const char *app_type)
+static int __get_launchpad_type(const char *internal_pool, const char *hwacc,
+               const char *app_type)
 {
        if (app_type && strcmp(app_type, "webapp") == 0) {
                _D("[launchpad] launchpad type: wrt");
@@ -297,19 +307,21 @@ static int __get_launchpad_type(const char* internal_pool, const char* hwacc, co
 
        if (internal_pool && strcmp(internal_pool, "true") == 0 && hwacc) {
                if (strcmp(hwacc, "NOT_USE") == 0) {
-                       _D("[launchpad] launchpad type: S/W(%d)", LAUNCHPAD_TYPE_SW);
+                       _D("[launchpad] launchpad type: S/W(%d)",
+                                       LAUNCHPAD_TYPE_SW);
                        return LAUNCHPAD_TYPE_SW;
-               }
-               if (strcmp(hwacc, "USE") == 0) {
-                       _D("[launchpad] launchpad type: H/W(%d)", LAUNCHPAD_TYPE_HW);
+               } else if (strcmp(hwacc, "USE") == 0) {
+                       _D("[launchpad] launchpad type: H/W(%d)",
+                                       LAUNCHPAD_TYPE_HW);
                        return LAUNCHPAD_TYPE_HW;
-               }
-               if (strcmp(hwacc, "SYS") == 0) {
+               } else if (strcmp(hwacc, "SYS") == 0) {
                        if (sys_hwacc == SETTING_HW_ACCELERATION_ON) {
-                               _D("[launchpad] launchpad type: H/W(%d)", LAUNCHPAD_TYPE_HW);
+                               _D("[launchpad] launchpad type: H/W(%d)",
+                                               LAUNCHPAD_TYPE_HW);
                                return LAUNCHPAD_TYPE_HW;
                        } else if (sys_hwacc == SETTING_HW_ACCELERATION_OFF) {
-                               _D("[launchpad] launchpad type: S/W(%d)", LAUNCHPAD_TYPE_SW);
+                               _D("[launchpad] launchpad type: S/W(%d)",
+                                               LAUNCHPAD_TYPE_SW);
                                return LAUNCHPAD_TYPE_SW;
                        }
                }
@@ -352,7 +364,7 @@ static int __real_send(int clifd, int ret)
        return 0;
 }
 
-static void __send_result_to_caller(int clifd, int ret, const charapp_path)
+static void __send_result_to_caller(int clifd, int ret, const char *app_path)
 {
        char *cmdline;
 
@@ -369,7 +381,8 @@ static void __send_result_to_caller(int clifd, int ret, const char* app_path)
 
        cmdline = _proc_get_cmdline_bypid(ret);
        if (cmdline == NULL) {
-               _E("The app process might be terminated while we are wating %d", ret);
+               _E("The app process might be terminated while we are wating %d",
+                               ret);
                __real_send(clifd, -1); /* abnormally launched*/
                return;
        }
@@ -387,7 +400,7 @@ static int __prepare_candidate_process(int type, int loader_id)
        char loader_id_str[10] = {0, };
        char argbuf[LOADER_ARG_LEN];
        char *argv[] = {NULL, NULL, NULL, NULL, NULL, NULL};
-       candidate_process_context_tcpt = __find_slot(type, loader_id);
+       candidate_process_context_t *cpt = __find_slot(type, loader_id);
 
        if (cpt == NULL)
                return -1;
@@ -426,8 +439,9 @@ static int __prepare_candidate_process(int type, int loader_id)
 
 static gboolean __handle_preparing_candidate_process(gpointer user_data)
 {
-       candidate_process_context_t *cpc = (candidate_process_context_t *)user_data;
+       candidate_process_context_t *cpc;
 
+       cpc = (candidate_process_context_t *)user_data;
        __prepare_candidate_process(cpc->type, cpc->loader_id);
        _D("Prepare another candidate process");
        cpc->timer = 0;
@@ -439,13 +453,14 @@ static void __set_timer(candidate_process_context_t *cpc)
        if (cpc == NULL)
                return;
 
-       if (cpc->detection_method & METHOD_TIMEOUT)
+       if (cpc->detection_method & METHOD_TIMEOUT) {
                cpc->timer = g_timeout_add(cpc->timeout_val,
-                                       __handle_preparing_candidate_process, cpc);
+                               __handle_preparing_candidate_process, cpc);
+       }
 }
 
-static int __send_launchpad_loader(candidate_process_context_t *cpc, app_pkt_t *pkt,
-                               const char *app_path, int clifd)
+static int __send_launchpad_loader(candidate_process_context_t *cpc,
+               app_pkt_t *pkt, const char *app_path, int clifd)
 {
        char sock_path[PATH_MAX];
        int pid = -1;
@@ -522,7 +537,7 @@ static void __real_launch(const char *app_path, bundle * kb)
        __normal_fork_exec(app_argc, app_argv);
 }
 
-static int __prepare_exec(const char *appId, const char *app_path,
+static int __prepare_exec(const char *appid, const char *app_path,
                        appinfo_t *menu_info, bundle * kb)
 {
        char *file_name;
@@ -536,9 +551,12 @@ static int __prepare_exec(const char *appId, const char *app_path,
 
        /* SET PRIVILEGES*/
        if (bundle_get_val(kb, AUL_K_PRIVACY_APPID) == NULL) {
-               _D("appId: %s / app_path : %s ", appId, app_path);
-               if ((ret = __set_access(appId)) != 0) {
-                       _D("fail to set privileges - check your package's credential : %d\n", ret);
+               _D("appId: %s / app_path : %s ", appid, app_path);
+               ret = __set_access(appid);
+               if (ret != 0) {
+                       _D("fail to set privileges - check "
+                                       "your package's credential : %d\n",
+                                       ret);
                        return -1;
                }
        }
@@ -566,7 +584,8 @@ static int __prepare_exec(const char *appId, const char *app_path,
 }
 
 static int __launch_directly(const char *appid, const char *app_path, int clifd,
-                               bundle* kb, appinfo_t *menu_info, candidate_process_context_t *cpc)
+               bundle *kb, appinfo_t *menu_info,
+               candidate_process_context_t *cpc)
 {
        char sock_path[PATH_MAX];
        int pid = fork();
@@ -584,14 +603,14 @@ static int __launch_directly(const char *appid, const char *app_path, int clifd,
                for (iter_fd = 3; iter_fd <= max_fd; iter_fd++)
                        close(iter_fd);
 
-               snprintf(sock_path, sizeof(sock_path), "/run/user/%d/%d", getuid(), getpid());
+               snprintf(sock_path, sizeof(sock_path), "/run/user/%d/%d",
+                               getuid(), getpid());
                unlink(sock_path);
 
                PERF("prepare exec - first done");
                _D("lock up test log(no error) : prepare exec - first done");
 
-               if (__prepare_exec(appid, app_path,
-                               menu_info, kb) < 0) {
+               if (__prepare_exec(appid, app_path, menu_info, kb) < 0) {
                        SECURE_LOGE("preparing work fail to launch - "
                                "can not launch %s\n", appid);
                        exit(-1);
@@ -663,7 +682,8 @@ static gboolean __glib_check(GSource *src)
        fd_list = src->poll_fds;
        do {
                tmp = (GPollFD *) fd_list->data;
-               if ((tmp->revents & (G_IO_IN | G_IO_PRI | G_IO_HUP | G_IO_NVAL)))
+               if ((tmp->revents & (G_IO_IN | G_IO_PRI | G_IO_HUP |
+                                               G_IO_NVAL)))
                        return TRUE;
                fd_list = fd_list->next;
        } while (fd_list);
@@ -704,7 +724,8 @@ static GSourceFuncs funcs = {
        .finalize = __glib_finalize
 };
 
-static guint __poll_fd(int fd, gushort events, GSourceFunc func, int type, int loader_id)
+static guint __poll_fd(int fd, gushort events, GSourceFunc func, int type,
+               int loader_id)
 {
        int r;
        GPollFD *gpollfd;
@@ -758,15 +779,14 @@ static gboolean __handle_loader_client_event(gpointer data)
        int type = lc->type;
        int loader_id = lc->loader_id;
        gushort revents = lc->gpollfd->revents;
-
        candidate_process_context_t *cpc = __find_slot(type, loader_id);
 
        if (cpc == NULL)
                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;
@@ -792,6 +812,7 @@ static gboolean __handle_loader_event(gpointer data)
        int loader_id = lc->loader_id;
        int client_fd;
        int client_pid;
+       int ret;
 
        candidate_process_context_t *cpc = __find_slot(type, loader_id);
 
@@ -799,15 +820,16 @@ static gboolean __handle_loader_event(gpointer data)
                return G_SOURCE_REMOVE;
 
        if (!cpc->prepared) {
-               if (__accept_candidate_process(fd, &client_fd, &client_pid) >= 0) {
+               ret = __accept_candidate_process(fd, &client_fd, &client_pid);
+               if (ret >= 0) {
                        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,
-                                                       (GSourceFunc)__handle_loader_client_event, type, loader_id);
+                                       __handle_loader_client_event, type,
+                                       loader_id);
                        if (cpc->source == 0)
                                close(client_fd);
                }
@@ -821,6 +843,7 @@ static gboolean __handle_loader_event(gpointer data)
 
 static gboolean __handle_sigchild(gpointer data)
 {
+       candidate_process_context_t *cpc;
        loader_context_t *lc = (loader_context_t *) data;
        int fd = lc->gpollfd->fd;
        struct signalfd_siginfo siginfo;
@@ -836,8 +859,7 @@ static gboolean __handle_sigchild(gpointer data)
                        break;
                }
                __launchpad_process_sigchld(&siginfo);
-               candidate_process_context_t *cpc = __find_slot_from_pid(siginfo.ssi_pid);
-
+               cpc = __find_slot_from_pid(siginfo.ssi_pid);
                if (cpc != NULL) {
                        cpc->prepared = false;
                        __prepare_candidate_process(cpc->type, cpc->loader_id);
@@ -848,7 +870,6 @@ static gboolean __handle_sigchild(gpointer data)
                        __remove_slot(LAUNCHPAD_TYPE_DYNAMIC, cpc->loader_id);
                        cpc = __find_slot_from_caller_pid(siginfo.ssi_pid);
                }
-
        } while (s > 0);
 
        return G_SOURCE_CONTINUE;
@@ -856,12 +877,12 @@ static gboolean __handle_sigchild(gpointer data)
 
 static int __dispatch_cmd_hint(bundle *kb, int detection_method)
 {
+       candidate_process_context_t *cpc;
        GList *iter = candidate_slot_list;
 
        _W("cmd hint %d", detection_method);
        while (iter) {
-               candidate_process_context_t *cpc = (candidate_process_context_t *)iter->data;
-
+               cpc = (candidate_process_context_t *)iter->data;
                if (cpc->pid == CANDIDATE_NONE &&
                                (cpc->detection_method & detection_method)) {
                        if (cpc->timer > 0) {
@@ -883,6 +904,7 @@ static int __dispatch_cmd_add_loader(bundle *kb)
        const char *caller_pid = NULL;
        const char *extra;
        int lid;
+       candidate_process_context_t *cpc;
 
        _W("cmd add loader");
        add_slot_str = bundle_get_val(kb, AUL_K_LOADER_PATH);
@@ -891,8 +913,9 @@ static int __dispatch_cmd_add_loader(bundle *kb)
 
        if (add_slot_str && caller_pid) {
                lid = __make_loader_id();
-               candidate_process_context_t *cpc = __add_slot(LAUNCHPAD_TYPE_DYNAMIC, lid,
-                               atoi(caller_pid), add_slot_str, extra, true, METHOD_TIMEOUT | METHOD_VISIBILITY, 2000);
+               cpc = __add_slot(LAUNCHPAD_TYPE_DYNAMIC, lid, atoi(caller_pid),
+                               add_slot_str, extra, true,
+                               METHOD_TIMEOUT | METHOD_VISIBILITY, 2000);
                __set_timer(cpc);
                return lid;
        }
@@ -939,7 +962,6 @@ static gboolean __handle_launch_event(gpointer data)
        app_pkt_t *pkt = NULL;
        appinfo_t *menu_info = NULL;
        candidate_process_context_t *cpc;
-
        const char *app_path = NULL;
        int pid = -1;
        int clifd = -1;
@@ -1028,14 +1050,15 @@ static gboolean __handle_launch_event(gpointer data)
        SECURE_LOGD("pkg_type : %s\n", menu_info->pkg_type);
 
        if ((loader_id = __get_loader_id(kb)) <= PAD_LOADER_ID_STATIC) {
-               type = __get_launchpad_type(menu_info->internal_pool, menu_info->hwacc,
-                                       menu_info->app_type);
+               type = __get_launchpad_type(menu_info->internal_pool,
+                               menu_info->hwacc, menu_info->app_type);
                if (type < 0) {
                        _E("failed to get launchpad type");
                        goto end;
                }
 
-               if (menu_info->comp_type && strcmp(menu_info->comp_type, "svcapp") == 0)
+               if (menu_info->comp_type &&
+                               strcmp(menu_info->comp_type, "svcapp") == 0)
                        loader_id = PAD_LOADER_ID_DIRECT;
                else
                        loader_id = PAD_LOADER_ID_STATIC;
@@ -1054,23 +1077,30 @@ static gboolean __handle_launch_event(gpointer data)
        if (loader_id == PAD_LOADER_ID_DIRECT ||
                (cpc = __find_slot(type, loader_id)) == NULL) {
                _W("Launch directly");
-               pid = __launch_directly(menu_info->appid, app_path, clifd, kb, menu_info, NULL);
+               pid = __launch_directly(menu_info->appid, app_path, clifd, kb,
+                               menu_info, NULL);
        } else {
                if (cpc->prepared) {
                        _W("Launch %d type process", type);
-                       pid = __send_launchpad_loader(cpc, pkt, app_path, clifd);
-               } else if (cpc->type == LAUNCHPAD_TYPE_SW || cpc->type == LAUNCHPAD_TYPE_HW) {
-                               cpc = __find_slot(LAUNCHPAD_TYPE_COMMON, loader_id);
-                               if (cpc != NULL && cpc->prepared) {
-                                       _W("Launch common type process");
-                                       pid = __send_launchpad_loader(cpc, pkt, app_path, clifd);
-                               } else {
-                                       _W("Launch directly");
-                                       pid = __launch_directly(menu_info->appid, app_path, clifd, kb, menu_info, NULL);
-                               }
+                       pid = __send_launchpad_loader(cpc, pkt, app_path,
+                                       clifd);
+               } else if (cpc->type == LAUNCHPAD_TYPE_SW ||
+                               cpc->type == LAUNCHPAD_TYPE_HW) {
+                       cpc = __find_slot(LAUNCHPAD_TYPE_COMMON, loader_id);
+                       if (cpc != NULL && cpc->prepared) {
+                               _W("Launch common type process");
+                               pid = __send_launchpad_loader(cpc, pkt,
+                                               app_path, clifd);
+                       } else {
+                               _W("Launch directly");
+                               pid = __launch_directly(menu_info->appid,
+                                               app_path, clifd, kb, menu_info,
+                                               NULL);
+                       }
                } else {
                        _W("Launch directly");
-                       pid = __launch_directly(menu_info->appid, app_path, clifd, kb, menu_info, cpc);
+                       pid = __launch_directly(menu_info->appid, app_path,
+                                       clifd, kb, menu_info, cpc);
                }
        }
 
@@ -1096,16 +1126,20 @@ end:
        return G_SOURCE_CONTINUE;
 }
 
-static candidate_process_context_t *__add_slot(int type, int loader_id, int caller_pid, const char *loader_path,
-               const char *loader_extra, bool enabled, int detection_method, int timeout_val)
+static candidate_process_context_t *__add_slot(int type, int loader_id,
+               int caller_pid, const char *loader_path,
+               const char *loader_extra, bool enabled, int detection_method,
+               int timeout_val)
 {
        candidate_process_context_t *cpc;
        int fd = -1;
+       guint pollfd;
 
        if (__find_slot(type, loader_id) != NULL)
                return NULL;
 
-       cpc = (candidate_process_context_t *)malloc(sizeof(candidate_process_context_t));
+       cpc = (candidate_process_context_t *)malloc(
+                       sizeof(candidate_process_context_t));
        if (cpc == NULL)
                return NULL;
 
@@ -1126,13 +1160,16 @@ static candidate_process_context_t *__add_slot(int type, int loader_id, int call
 
        fd = __listen_candidate_process(cpc->type, cpc->loader_id);
        if (fd == -1) {
-               _E("[launchpad] Listening the socket to the type %d candidate process failed.",
-                  cpc->type);
+               _E("[launchpad] Listening the socket to "
+                               "the type %d candidate process failed.",
+                               cpc->type);
                free(cpc);
                return NULL;
        }
 
-       if (__poll_fd(fd, G_IO_IN, (GSourceFunc)__handle_loader_event, cpc->type, cpc->loader_id) == 0) {
+       pollfd = __poll_fd(fd, G_IO_IN, (GSourceFunc)__handle_loader_event,
+                       cpc->type, cpc->loader_id);
+       if (pollfd == 0) {
                close(fd);
                free(cpc);
                return NULL;
@@ -1145,12 +1182,12 @@ static candidate_process_context_t *__add_slot(int type, int loader_id, int call
 
 static int __remove_slot(int type, int loader_id)
 {
+       candidate_process_context_t *cpc;
        GList *iter;
        iter = candidate_slot_list;
 
        while (iter) {
-               candidate_process_context_t *cpc = (candidate_process_context_t *)iter->data;
-
+               cpc = (candidate_process_context_t *)iter->data;
                if (type == cpc->type && loader_id == cpc->loader_id) {
                        if (cpc->pid > 0)
                                __kill_process(cpc->pid);
@@ -1159,7 +1196,8 @@ static int __remove_slot(int type, int loader_id)
                        if (cpc->source > 0)
                                g_source_remove(cpc->source);
 
-                       candidate_slot_list = g_list_delete_link(candidate_slot_list, iter);
+                       candidate_slot_list = g_list_delete_link(
+                                       candidate_slot_list, iter);
                        free(cpc->loader_path);
                        if (cpc->loader_extra)
                                free(cpc->loader_extra);
@@ -1177,6 +1215,7 @@ static int __remove_slot(int type, int loader_id)
 static int __init_launchpad_fd(int argc, char **argv)
 {
        int fd = -1;
+       guint pollfd;
 
        fd = __launchpad_pre_init(argc, argv);
        if (fd < 0) {
@@ -1184,7 +1223,9 @@ static int __init_launchpad_fd(int argc, char **argv)
                return -1;
        }
 
-       if (__poll_fd(fd, G_IO_IN, (GSourceFunc)__handle_launch_event, 0, 0) == 0) {
+       pollfd = __poll_fd(fd, G_IO_IN, (GSourceFunc)__handle_launch_event, 0,
+                       0);
+       if (pollfd == 0) {
                close(fd);
                return -1;
        }
@@ -1195,6 +1236,7 @@ static int __init_launchpad_fd(int argc, char **argv)
 static int __init_sigchild_fd(void)
 {
        int fd = -1;
+       guint pollfd;
 
        fd = __signal_get_sigchld_fd();
        if (fd < 0) {
@@ -1202,7 +1244,8 @@ static int __init_sigchild_fd(void)
                return -1;
        }
 
-       if (__poll_fd(fd, G_IO_IN, (GSourceFunc)__handle_sigchild, 0, 0) == 0) {
+       pollfd = __poll_fd(fd, G_IO_IN, (GSourceFunc)__handle_sigchild, 0, 0);
+       if (pollfd == 0) {
                close(fd);
                return -1;
        }
@@ -1210,45 +1253,75 @@ static int __init_sigchild_fd(void)
        return 0;
 }
 
-static int __add_default_slots()
+static int __add_default_slots(void)
 {
-       if (__add_slot(LAUNCHPAD_TYPE_COMMON, PAD_LOADER_ID_STATIC, 0, LOADER_PATH_DEFAULT,
-                       NULL, true, METHOD_TIMEOUT | METHOD_VISIBILITY, 5000) == NULL)
+       candidate_process_context_t *cpc;
+       int ret;
+
+       cpc = __add_slot(LAUNCHPAD_TYPE_COMMON, PAD_LOADER_ID_STATIC, 0,
+                       LOADER_PATH_DEFAULT, NULL, true,
+                       METHOD_TIMEOUT | METHOD_VISIBILITY, 5000);
+       if (cpc == NULL)
                return -1;
-       if (__prepare_candidate_process(LAUNCHPAD_TYPE_COMMON, PAD_LOADER_ID_STATIC) != 0)
+
+       ret = __prepare_candidate_process(LAUNCHPAD_TYPE_COMMON,
+                       PAD_LOADER_ID_STATIC);
+       if (ret != 0)
                return -1;
 
-       if (__add_slot(LAUNCHPAD_TYPE_SW, PAD_LOADER_ID_STATIC, 0, LOADER_PATH_DEFAULT,
-               NULL, true, METHOD_TIMEOUT | METHOD_VISIBILITY, 5000) == NULL)
+       cpc = __add_slot(LAUNCHPAD_TYPE_SW, PAD_LOADER_ID_STATIC, 0,
+                       LOADER_PATH_DEFAULT, NULL, true,
+                       METHOD_TIMEOUT | METHOD_VISIBILITY, 5000);
+       if (cpc == NULL)
                return -1;
-       if (__prepare_candidate_process(LAUNCHPAD_TYPE_SW, PAD_LOADER_ID_STATIC) != 0)
+
+       ret = __prepare_candidate_process(LAUNCHPAD_TYPE_SW,
+                       PAD_LOADER_ID_STATIC);
+       if (ret != 0)
                return -1;
 
-       if (__add_slot(LAUNCHPAD_TYPE_HW, PAD_LOADER_ID_STATIC, 0, LOADER_PATH_DEFAULT,
-               NULL, true, METHOD_TIMEOUT | METHOD_VISIBILITY, 5000) == NULL)
+       cpc = __add_slot(LAUNCHPAD_TYPE_HW, PAD_LOADER_ID_STATIC, 0,
+                       LOADER_PATH_DEFAULT, NULL, true,
+                       METHOD_TIMEOUT | METHOD_VISIBILITY, 5000);
+       if (cpc == NULL)
                return -1;
-       if (__prepare_candidate_process(LAUNCHPAD_TYPE_HW, PAD_LOADER_ID_STATIC) != 0)
+
+       ret = __prepare_candidate_process(LAUNCHPAD_TYPE_HW,
+                       PAD_LOADER_ID_STATIC);
+       if (ret != 0)
                return -1;
 
        if (access(LOADER_PATH_WRT, F_OK | X_OK) == 0) {
 #ifdef _APPFW_FEATURE_LAZY_LOADER
-               if (__add_slot(LAUNCHPAD_TYPE_WRT, PAD_LOADER_ID_STATIC, 0, LOADER_PATH_WRT,
-                               NULL, false, METHOD_TIMEOUT | METHOD_DEMAND, 5000) == NULL)
+               cpc = __add_slot(LAUNCHPAD_TYPE_WRT, PAD_LOADER_ID_STATIC, 0,
+                               LOADER_PATH_WRT, NULL, false,
+                               METHOD_TIMEOUT | METHOD_DEMAND, 5000);
+               if (cpc == NULL)
                        return -1;
 #else
-               if (__add_slot(LAUNCHPAD_TYPE_WRT, PAD_LOADER_ID_STATIC, 0, LOADER_PATH_WRT,
-                               NULL, true, METHOD_TIMEOUT | METHOD_DEMAND, 5000) == NULL)
+               cpc = __add_slot(LAUNCHPAD_TYPE_WRT, PAD_LOADER_ID_STATIC, 0,
+                               LOADER_PATH_WRT, NULL, true,
+                               METHOD_TIMEOUT | METHOD_DEMAND, 5000);
+               if (cpc == NULL)
                        return -1;
-               if (__prepare_candidate_process(LAUNCHPAD_TYPE_WRT, PAD_LOADER_ID_STATIC) != 0)
+
+               ret = __prepare_candidate_process(LAUNCHPAD_TYPE_WRT,
+                               PAD_LOADER_ID_STATIC);
+               if (ret != 0)
                        return -1;
 #endif
        }
 
        if (access(LOADER_PATH_JS_NATIVE, F_OK | X_OK) == 0) {
-               if (__add_slot(LAUNCHPAD_TYPE_JS_NATIVE, PAD_LOADER_ID_STATIC, 0, LOADER_PATH_JS_NATIVE,
-                               NULL, true, METHOD_TIMEOUT | METHOD_VISIBILITY, 5000) == NULL)
+               cpc = __add_slot(LAUNCHPAD_TYPE_JS_NATIVE, PAD_LOADER_ID_STATIC,
+                               0, LOADER_PATH_JS_NATIVE, NULL, true,
+                               METHOD_TIMEOUT | METHOD_VISIBILITY, 5000);
+               if (cpc == NULL)
                        return -1;
-               if (__prepare_candidate_process(LAUNCHPAD_TYPE_JS_NATIVE, PAD_LOADER_ID_STATIC) != 0)
+
+               ret = __prepare_candidate_process(LAUNCHPAD_TYPE_JS_NATIVE,
+                               PAD_LOADER_ID_STATIC);
+               if (ret != 0)
                        return -1;
        }
 
@@ -1268,23 +1341,34 @@ static void __vconf_cb(keynode_t *key, void *data)
 
 static int __before_loop(int argc, char **argv)
 {
-       if (__init_sigchild_fd() != 0) {
+       int ret;
+
+       ret = __init_sigchild_fd();
+       if (ret != 0) {
                _E("__init_sigchild_fd() failed");
                return -1;
        }
 
-       if (__init_launchpad_fd(argc, argv) != 0) {
+       ret = __init_launchpad_fd(argc, argv);
+       if (ret != 0) {
                _E("__init_launchpad_fd() failed");
                return -1;
        }
 
-       if (vconf_get_int(VCONFKEY_SETAPPL_APP_HW_ACCELERATION, &sys_hwacc) != VCONF_OK)
-               _E("Failed to get vconf int: %s", VCONFKEY_SETAPPL_APP_HW_ACCELERATION);
+       ret = vconf_get_int(VCONFKEY_SETAPPL_APP_HW_ACCELERATION, &sys_hwacc);
+       if (ret != VCONF_OK) {
+               _E("Failed to get vconf int: %s",
+                               VCONFKEY_SETAPPL_APP_HW_ACCELERATION);
+       }
 
        SECURE_LOGD("sys hwacc: %d", sys_hwacc);
 
-       if (vconf_notify_key_changed(VCONFKEY_SETAPPL_APP_HW_ACCELERATION, __vconf_cb, NULL) != 0)
-               _E("Failed to register callback for %s", VCONFKEY_SETAPPL_APP_HW_ACCELERATION);
+       ret = vconf_notify_key_changed(VCONFKEY_SETAPPL_APP_HW_ACCELERATION,
+                       __vconf_cb, NULL);
+       if (ret != 0) {
+               _E("Failed to register callback for %s",
+                               VCONFKEY_SETAPPL_APP_HW_ACCELERATION);
+       }
 
        return 0;
 }
@@ -1293,11 +1377,14 @@ static int __before_loop(int argc, char **argv)
 static void __set_priority(void)
 {
        char err_str[MAX_LOCAL_BUFSZ] = { 0, };
-       int res = setpriority(PRIO_PROCESS, 0, -12);
+       int res;
 
-       if (res == -1)
-               SECURE_LOGE("Setting process (%d) priority to -12 failed, errno: %d (%s)",
-                       getpid(), errno, strerror_r(errno, err_str, sizeof(err_str)));
+       res = setpriority(PRIO_PROCESS, 0, -12);
+       if (res == -1) {
+               SECURE_LOGE("Setting process (%d) priority to -12 failed, "
+                               "errno: %d (%s)", getpid(), errno,
+                               strerror_r(errno, err_str, sizeof(err_str)));
+       }
 }
 #endif
 
@@ -1307,7 +1394,7 @@ int main(int argc, char **argv)
 
        mainloop = g_main_loop_new(NULL, FALSE);
        if (!mainloop) {
-               _E("failed to create glib main loop");
+               _E("Failed to create glib main loop");
                return -1;
        }
 
@@ -1323,3 +1410,4 @@ int main(int argc, char **argv)
 
        return -1;
 }
+
index a6fba4efb10cba4cbb124e2892af75bca238a163..5403984bdacb109936ec949f6698684a7758cbe5 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
  *
  * Licensed under the Apache License, Version 2.0 (the License);
  * you may not use this file except in compliance with the License.
@@ -201,7 +201,8 @@ int _create_server_sock(const char *name)
 
        memset(&saddr, 0, sizeof(saddr));
        saddr.sun_family = AF_UNIX;
-       snprintf(saddr.sun_path, sizeof(saddr.sun_path), "/run/user/%d/%s", getuid(), name);
+       snprintf(saddr.sun_path, sizeof(saddr.sun_path), "/run/user/%d/%s",
+                       getuid(), name);
        unlink(saddr.sun_path);
 
        if (bind(fd, (struct sockaddr *)&saddr, sizeof(saddr)) < 0) {
@@ -335,6 +336,7 @@ char *_proc_get_cmdline_bypid(int pid)
        char buf[MAX_CMD_BUFSZ];
        int ret;
        char *ptr;
+       int len;
 
        snprintf(buf, sizeof(buf), "/proc/%d/cmdline", pid);
        ret = __read_proc(buf, buf, sizeof(buf));
@@ -363,10 +365,14 @@ char *_proc_get_cmdline_bypid(int pid)
 
                return strdup(ptr);
        } else if (strncmp(buf, BASH_NAME, BASH_SIZE) == 0) {
-               if (strncmp(&buf[BASH_SIZE + 1], OPROFILE_NAME, OPROFILE_SIZE) == 0) {
-                       if (strncmp(&buf[BASH_SIZE + OPROFILE_SIZE + 2], OPTION_VALGRIND_NAME,
-                                       OPTION_VALGRIND_SIZE) == 0) {
-                               return strdup(&buf[BASH_SIZE + OPROFILE_SIZE + OPTION_VALGRIND_SIZE + 3]);
+               if (strncmp(&buf[BASH_SIZE + 1], OPROFILE_NAME,
+                                       OPROFILE_SIZE) == 0) {
+                       if (strncmp(&buf[BASH_SIZE + OPROFILE_SIZE + 2],
+                                               OPTION_VALGRIND_NAME,
+                                               OPTION_VALGRIND_SIZE) == 0) {
+                               len = BASH_SIZE + OPROFILE_SIZE +
+                                       OPTION_VALGRIND_SIZE + 3;
+                               return strdup(&buf[len]);
                        }
                }
        }
@@ -374,7 +380,7 @@ char *_proc_get_cmdline_bypid(int pid)
        return strdup(buf);
 }
 
-appinfo_t_appinfo_create(bundle *kb)
+appinfo_t *_appinfo_create(bundle *kb)
 {
        appinfo_t *menu_info;
        const char *ptr = NULL;
@@ -488,7 +494,7 @@ void _appinfo_free(appinfo_t *menu_info)
        free(menu_info);
 }
 
-void _modify_bundle(bundle * kb, int caller_pid, appinfo_t *menu_info, int cmd)
+void _modify_bundle(bundle *kb, int caller_pid, appinfo_t *menu_info, int cmd)
 {
        char *ptr;
        char exe[MAX_PATH_LEN];
@@ -520,7 +526,8 @@ void _modify_bundle(bundle * kb, int caller_pid, appinfo_t *menu_info, int cmd)
                                        break;
                                ptr += flag;
 
-                               flag = __parse_app_path(ptr, value, sizeof(value));
+                               flag = __parse_app_path(ptr, value,
+                                               sizeof(value));
                                if (flag < 0)
                                        break;
                                ptr += flag;
@@ -553,8 +560,9 @@ int _connect_to_launchpad(int type, int id)
 
        memset(&addr, 0x00, sizeof(struct sockaddr_un));
        addr.sun_family = AF_UNIX;
-       snprintf(addr.sun_path, sizeof(addr.sun_path), "%s/%d/%s%d-%d", SOCKET_PATH, getuid(),
-               LAUNCHPAD_LOADER_SOCKET_NAME, type, id);
+       snprintf(addr.sun_path, sizeof(addr.sun_path), "%s/%d/%s%d-%d",
+                       SOCKET_PATH, getuid(), LAUNCHPAD_LOADER_SOCKET_NAME,
+                       type, id);
 
        _D("connect to %s", addr.sun_path);
        while (connect(fd, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
@@ -586,7 +594,7 @@ error:
        return -1;
 }
 
-void _set_env(appinfo_t *menu_info, bundle * kb)
+void _set_env(appinfo_t *menu_info, bundle *kb)
 {
        const char *str;
 
@@ -612,7 +620,7 @@ void _set_env(appinfo_t *menu_info, bundle * kb)
                setenv("TIZEN_API_VERSION", str, 1);
 }
 
-char** _create_argc_argv(bundle * kb, int *margc)
+char **_create_argc_argv(bundle *kb, int *margc)
 {
        char **argv;
        int argc;
index 8e486a26c695b4767d25a4cfd5cb5588c352c46a..f4cf1809448795f90f428ae25534ce886639a256 100644 (file)
@@ -1,3 +1,19 @@
+/*
+ * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 #define _GNU_SOURCE
 #include <stdio.h>
 #include <stdlib.h>
@@ -54,10 +70,10 @@ static void __release_at_exit(void)
                free(__root_path);
 }
 
-static int __set_access(const char* appId, const char* pkg_type,
-                       const char* app_path)
+static int __set_access(const char *appid, const char *pkg_type,
+               const char *app_path)
 {
-       return security_manager_prepare_app(appId) == SECURITY_MANAGER_SUCCESS ? 0 : -1;
+       return security_manager_prepare_app(appid);
 }
 
 static int __prepare_exec(const char *appid, const char *app_path,
@@ -65,21 +81,24 @@ static int __prepare_exec(const char *appid, const char *app_path,
 {
        const char *file_name = NULL;
        char process_name[AUL_PR_NAME] = { 0, };
-       int ret = 0;
+       int ret;
 
        __preexec_run(pkg_type, appid, app_path);
 
        /* SET PRIVILEGES*/
        SECURE_LOGD("[candidata] appid : %s / pkg_type : %s / app_path : %s",
                appid, pkg_type, app_path);
-       if ((ret = __set_access(appid, pkg_type, app_path)) < 0) {
-               _D("fail to set privileges - check your package's credential : %d\n", ret);
+       ret = __set_access(appid, pkg_type, app_path);
+       if (ret < 0) {
+               _D("fail to set privileges - check your package's credential: "
+                               "%d\n", ret);
                return -1;
        }
 
        /*
         * SET DUMPABLE - for coredump
-        * This dumpable flag should be set after calling perm_app_set_privilege()
+        * This dumpable flag should be set after
+        * calling perm_app_set_privilege().
         */
        prctl(PR_SET_DUMPABLE, 1);
 
@@ -102,7 +121,7 @@ static int __prepare_exec(const char *appid, const char *app_path,
 }
 
 static int __default_launch_cb(bundle *kb, const char *appid,
-                               const char *app_path, const char *pkg_type, int loader_type)
+               const char *app_path, const char *pkg_type, int loader_type)
 {
        char err_str[MAX_LOCAL_BUFSZ] = { 0, };
 #ifdef _APPFW_FEATURE_PRIORITY_CHANGE
@@ -112,29 +131,33 @@ static int __default_launch_cb(bundle *kb, const char *appid,
        _D("high_priority: %s", high_priority);
        if (strncmp(high_priority, "true", 4) == 0) {
                res = setpriority(PRIO_PROCESS, 0, -10);
-               if (res == -1)
-                       SECURE_LOGE("Setting process (%d) priority to -10 failed, errno: %d (%s)",
-                                       getpid(), errno, strerror_r(errno, err_str, sizeof(err_str)));
+               if (res == -1) {
+                       SECURE_LOGE("Setting process (%d) priority "
+                               "to -10 failed, errno: %d (%s)",
+                               getpid(), errno,
+                               strerror_r(errno, err_str, sizeof(err_str)));
+               }
        }
        bundle_del(kb, AUL_K_HIGHPRIORITY);
 #endif
 
        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\", error: %d (%s)",
-                                       app_path, errno, strerror_r(errno, err_str, sizeof(err_str)));
-
+               if (access(app_path, F_OK | R_OK)) {
+                       SECURE_LOGE("access() failed for file: \"%s\", "
+                               "error: %d (%s)", app_path, errno,
+                               strerror_r(errno, err_str, sizeof(err_str)));
+               }
                exit(-1);
        }
 
        return 0;
 }
 
-static int __candidate_process_launchpad_main_loop(app_pkt_tpkt,
-       char* out_app_path, int* out_argc, char ***out_argv, int type)
+static int __candidate_process_launchpad_main_loop(app_pkt_t *pkt,
+               char *out_app_path, int *out_argc, char ***out_argv, int type)
 {
-       bundle *kb = NULL;
+       bundle *kb;
        appinfo_t *menu_info = NULL;
        const char *app_path = NULL;
        int tmp_argc = 0;
@@ -184,7 +207,8 @@ static int __candidate_process_launchpad_main_loop(app_pkt_t* pkt,
                exit(-1);
        }
 
-       _modify_bundle(kb, /*cr.pid - unused parameter*/ 0, menu_info, pkt->cmd);
+       _modify_bundle(kb, /*cr.pid - unused parameter*/ 0, menu_info,
+                       pkt->cmd);
 
        __appid = strdup(menu_info->appid);
        if (__appid == NULL) {
@@ -218,8 +242,9 @@ static int __candidate_process_launchpad_main_loop(app_pkt_t* pkt,
        __default_launch_cb(kb, __appid, app_path, menu_info->pkg_type, type);
 
        if (__loader_callbacks->launch) {
-               ret = __loader_callbacks->launch(tmp_argc, tmp_argv, app_path, __appid, __pkgid,
-                                               menu_info->pkg_type, __loader_user_data);
+               ret = __loader_callbacks->launch(tmp_argc, tmp_argv, app_path,
+                               __appid, __pkgid, menu_info->pkg_type,
+                               __loader_user_data);
        }
 
        /* SET ENVIROMENT*/
@@ -233,10 +258,13 @@ static int __candidate_process_launchpad_main_loop(app_pkt_t* pkt,
                *out_argc = tmp_argc;
                (*out_argv)[0] = out_app_path;
 
-               for (i = 0; i < *out_argc; i++)
-                       SECURE_LOGD("input argument %d : %s##", i, (*out_argv)[i]);
-       } else
+               for (i = 0; i < *out_argc; i++) {
+                       SECURE_LOGD("input argument %d : %s##", i,
+                                       (*out_argv)[i]);
+               }
+       } else {
                exit(-1);
+       }
 
        if (menu_info != NULL)
                _appinfo_free(menu_info);
@@ -256,7 +284,7 @@ static void __receiver_cb(int fd)
        app_pkt_t *pkt;
 
        _D("[candidate] ECORE_FD_READ");
-       pkt = (app_pkt_t*) malloc(sizeof(char) * AUL_SOCK_MAXBUFF);
+       pkt = (app_pkt_t *)malloc(sizeof(char) * AUL_SOCK_MAXBUFF);
        if (!pkt) {
                _D("[candidate] out of memory1");
                exit(-1);
@@ -295,9 +323,11 @@ static int __before_loop(int argc, char **argv)
        char err_str[MAX_LOCAL_BUFSZ] = { 0, };
        int res = setpriority(PRIO_PROCESS, 0, LOWEST_PRIO);
 
-       if (res == -1)
-               SECURE_LOGE("Setting process (%d) priority to %d failed, errno: %d (%s)",
-                       getpid(), LOWEST_PRIO, errno, strerror_r(errno, err_str, sizeof(err_str)));
+       if (res == -1) {
+               SECURE_LOGE("Setting process (%d) priority to %d failed, "
+                               "errno: %d (%s)", getpid(), LOWEST_PRIO, errno,
+                               strerror_r(errno, err_str, sizeof(err_str)));
+       }
 #endif
        __preexec_init(argc, argv);
 
@@ -306,11 +336,14 @@ static int __before_loop(int argc, char **argv)
        /* TODO : should be add to check permission in the kernel*/
        setsid();
 
-       if (argc > 3)
-               extra = bundle_decode((const bundle_raw *)argv[3], strlen(argv[3]));
+       if (argc > 3) {
+               extra = bundle_decode((bundle_raw *)argv[3],
+                               strlen(argv[3]));
+       }
 
        if (__loader_callbacks->create) {
-               __loader_callbacks->create(extra, __loader_type, __loader_user_data);
+               __loader_callbacks->create(extra, __loader_type,
+                               __loader_user_data);
                ret = 0;
        }
 
@@ -319,9 +352,11 @@ 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, errno: %d (%s)",
-                       getpid(), errno, strerror_r(errno, err_str, sizeof(err_str)));
+       if (res == -1) {
+               SECURE_LOGE("Setting process (%d) priority to 0 failed, "
+                               "errno: %d (%s)", getpid(), errno,
+                               strerror_r(errno, err_str, sizeof(err_str)));
+       }
 #endif
        client_fd = _connect_to_launchpad(__loader_type, __loader_id);
        if (client_fd == -1) {
@@ -336,15 +371,17 @@ static int __before_loop(int argc, char **argv)
 
 static int __after_loop(void)
 {
-       if (__loader_callbacks->terminate)
-               return __loader_callbacks->terminate(__argc, __argv, __loader_user_data);
+       if (__loader_callbacks->terminate) {
+               return __loader_callbacks->terminate(__argc, __argv,
+                               __loader_user_data);
+       }
 
        return -1;
 }
 
 API int launchpad_loader_main(int argc, char **argv,
-                               loader_lifecycle_callback_s *callbacks, loader_adapter_s *adapter,
-                               void *user_data)
+               loader_lifecycle_callback_s *callbacks,
+               loader_adapter_s *adapter, void *user_data)
 {
        if (argc < 3) {
                _E("too few argument.");
@@ -389,3 +426,4 @@ API int launchpad_loader_main(int argc, char **argv,
 
        return __after_loop();
 }
+
index ec79b743d98ea94d91b9e2ebdbc01de231e44ce4..8362b072cb4c253f75cd5ad0d7b2087101568658 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
  *
  * Licensed under the Apache License, Version 2.0 (the License);
  * you may not use this file except in compliance with the License.
@@ -35,40 +35,47 @@ static Ecore_Fd_Handler *__fd_handler;
 static loader_receiver_cb __receiver;
 
 static int __argc;
-static char** __argv;
+static char **__argv;
 
 static void __init_window(void)
 {
-       Evas_Object *win = elm_win_add(NULL, "package_name", ELM_WIN_BASIC);
-       if (win) {
-               elm_win_precreated_object_set(win);
-
-               Evas_Object *bg = elm_bg_add(win);
-               if (bg) {
-                       evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-                       elm_win_resize_object_add(win, bg);
-                       elm_bg_precreated_object_set(bg);
-               } else {
-                       _E("[candidate] elm_bg_add() failed");
-               }
+       Evas_Object *win;
+       Evas_Object *bg;
+       Evas_Object *conform;
 
-               Evas_Object *conform = elm_conformant_add(win);
-               if (conform) {
-                       evas_object_size_hint_weight_set(conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-                       elm_win_resize_object_add(win, conform);
-                       elm_conformant_precreated_object_set(conform);
-               } else {
-                       _E("elm_conformant_add() failed");
-               }
-       } else {
+       win = elm_win_add(NULL, "package_name", ELM_WIN_BASIC);
+       if (win == NULL) {
                _E("[candidate] elm_win_add() failed");
+               return;
+       }
+
+       elm_win_precreated_object_set(win);
+
+       bg = elm_bg_add(win);
+       if (bg) {
+               evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND,
+                               EVAS_HINT_EXPAND);
+               elm_win_resize_object_add(win, bg);
+               elm_bg_precreated_object_set(bg);
+       } else {
+               _E("[candidate] elm_bg_add() failed");
+       }
+
+       conform = elm_conformant_add(win);
+       if (conform) {
+               evas_object_size_hint_weight_set(conform, EVAS_HINT_EXPAND,
+                               EVAS_HINT_EXPAND);
+               elm_win_resize_object_add(win, conform);
+               elm_conformant_precreated_object_set(conform);
+       } else {
+               _E("elm_conformant_add() failed");
        }
 }
 
 static void __init_theme(void)
 {
        char *theme = elm_theme_list_item_path_get(eina_list_data_get(
-                       elm_theme_list_get(NULL)), NULL);
+                               elm_theme_list_get(NULL)), NULL);
        Eina_Bool is_exist = edje_file_group_exists(theme, "*");
        if (!is_exist)
                _D("theme path: %s", theme);
@@ -103,7 +110,8 @@ static void __loader_create_cb(bundle *extra, int type, void *user_data)
 }
 
 static int __loader_launch_cb(int argc, char **argv, const char *app_path,
-                       const char *appid, const char *pkgid, const char *pkg_type, void *user_data)
+               const char *appid, const char *pkgid, const char *pkg_type,
+               void *user_data)
 {
        return 0;
 }
@@ -139,8 +147,8 @@ static int __loader_terminate_cb(int argc, char **argv, void *user_data)
 do_dlopen:
        handle = dlopen(argv[0], RTLD_LAZY | RTLD_GLOBAL);
        if (handle == NULL) {
-               _E("dlopen failed(%s). Please complile with -fPIE and link with -pie flag",
-                       dlerror());
+               _E("dlopen failed(%s). Please complile with -fPIE and "
+                               "link with -pie flag", dlerror());
                goto do_exec;
        }
 
@@ -151,7 +159,8 @@ do_dlopen:
 
        dl_main = dlsym(handle, "main");
        if (dl_main == NULL) {
-               _E("dlsym not founded(%s). Please export 'main' function", dlerror());
+               _E("dlsym not founded(%s). Please export 'main' function",
+                               dlerror());
                dlclose(handle);
                goto do_exec;
        }
@@ -165,25 +174,28 @@ do_dlopen:
 do_exec:
        if (access(argv[0], F_OK | R_OK)) {
                SECURE_LOGE("access() failed for file: \"%s\", error: %d (%s)",
-                       argv[0], errno, strerror_r(errno, err_str, sizeof(err_str)));
+                               argv[0], errno,
+                               strerror_r(errno, err_str, sizeof(err_str)));
        } else {
                SECURE_LOGD("[candidate] Exec application (%s)", __argv[0]);
                if (libdir)
                        setenv("LD_LIBRARY_PATH", libdir, 1);
                free(libdir);
-               if (execv(argv[0], argv) < 0)
-                       SECURE_LOGE("execv() failed for file: \"%s\", error: %d (%s)",
-                               argv[0], errno, strerror_r(errno, err_str, sizeof(err_str)));
+               if (execv(argv[0], argv) < 0) {
+                       SECURE_LOGE("execv() failed for file: \"%s\", "
+                               "error: %d (%s)", argv[0], errno,
+                               strerror_r(errno, err_str, sizeof(err_str)));
+               }
        }
 
        return -1;
-
 }
 
-static Eina_Bool __process_fd_handler(voiddata, Ecore_Fd_Handler *handler)
+static Eina_Bool __process_fd_handler(void *data, Ecore_Fd_Handler *handler)
 {
-       int fd = ecore_main_fd_handler_fd_get(handler);
+       int fd;
 
+       fd = ecore_main_fd_handler_fd_get(handler);
        if (fd == -1) {
                _D("[candidate] ECORE_FD_GET");
                exit(-1);
@@ -215,8 +227,8 @@ static void __adapter_add_fd(void *user_data, int fd,
                loader_receiver_cb receiver)
 {
        __fd_handler = ecore_main_fd_handler_add(fd,
-                       (Ecore_Fd_Handler_Flags)(ECORE_FD_READ | ECORE_FD_ERROR),
-                       __process_fd_handler, NULL, NULL, NULL);
+                       ECORE_FD_READ | ECORE_FD_ERROR, __process_fd_handler,
+                       NULL, NULL, NULL);
        if (__fd_handler == NULL) {
                _D("fd_handler is NULL");
                close(fd);
@@ -255,3 +267,4 @@ int main(int argc, char **argv)
 
        return launchpad_loader_main(argc, argv, &callbacks, &adapter, NULL);
 }
+