pkgmgr plugin, coding convention, AUL exception
authorSung-jae Park <nicesj.park@samsung.com>
Tue, 13 Aug 2013 00:51:14 +0000 (09:51 +0900)
committerSung-jae Park <nicesj.park@samsung.com>
Tue, 13 Aug 2013 00:51:14 +0000 (09:51 +0900)
Package manager plugin handles updating packages correctly.
Coding convention is updated.
AUL launch exception is updated

Change-Id: I6be04e432ec9fbc698df377ef8b198855ecb76e1

35 files changed:
packaging/data-provider-master.spec
pkgmgr_livebox/src/service_register.c
res/edje/CMakeLists.txt
src/abi.c
src/badge_service.c
src/buffer_handler.c
src/client_life.c
src/client_rpc.c
src/conf.c
src/critical_log.c
src/dead_monitor.c
src/event.c
src/fault_manager.c
src/fb.c
src/file_service.c
src/group.c
src/instance.c
src/io.c
src/liveinfo.c
src/main.c
src/notification_service.c
src/package.c
src/parser.c
src/pkgmgr.c
src/script_handler.c
src/server.c
src/service_common.c
src/setting.c
src/shortcut_service.c
src/slave_life.c
src/slave_rpc.c
src/util.c
src/utility_service.c
src/xmonitor.c
util_liveinfo/src/liveinfo.c

index 3f989e5..686a902 100644 (file)
@@ -1,6 +1,6 @@
 Name: data-provider-master
 Summary: Master service provider for liveboxes.
-Version: 0.25.3
+Version: 0.25.5
 Release: 1
 Group: HomeTF/Livebox
 License: Flora License
@@ -55,9 +55,9 @@ export FFLAGS="${FFLAGS} -DTIZEN_ENGINEER_MODE"
 %endif
 
 %if 0%{?sec_product_feature_livebox_shm}
-       cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DPRODUCT=baltic
+       %cmake . -DPRODUCT=baltic
 %else
-       cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DPRODUCT=private
+       %cmake . -DPRODUCT=private
 %endif
 
 CFLAGS="${CFLAGS} -Wall -Winline -Werror" LDFLAGS="${LDFLAGS}" make %{?jobs:-j%jobs}
index dd725cb..55fff79 100644 (file)
@@ -303,8 +303,9 @@ static inline int db_create_pkgmap(void)
                return -EIO;
        }
 
-       if (sqlite3_changes(s_info.handle) == 0)
+       if (sqlite3_changes(s_info.handle) == 0) {
                ErrPrint("No changes to DB\n");
+       }
 
        return 0;
 }
@@ -315,8 +316,9 @@ static inline int db_insert_pkgmap(const char *appid, const char *pkgid, const c
        static const char *dml;
        sqlite3_stmt *stmt;
 
-       if (!uiappid)
+       if (!uiappid) {
                uiappid = ""; /*!< Could we replace this with Main AppId of this package? */
+       }
 
        dml = "INSERT INTO pkgmap ( appid, pkgid, uiapp, prime ) VALUES (? ,?, ?, ?)";
        ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
@@ -416,8 +418,9 @@ static inline int db_create_provider(void)
                return -EIO;
        }
 
-       if (sqlite3_changes(s_info.handle) == 0)
+       if (sqlite3_changes(s_info.handle) == 0) {
                ErrPrint("No changes to DB\n");
+       }
 
        return 0;
 }
@@ -469,32 +472,41 @@ static inline int db_insert_provider(struct livebox *livebox)
        char *period = (char *)livebox->period;
        char *script = (char *)livebox->script;
 
-       if (!abi)
+       if (!abi) {
                abi = "c";
+       }
 
-       if (!box_src)
+       if (!box_src) {
                box_src = "";
+       }
 
-       if (!box_group)
+       if (!box_group) {
                box_group = "";
+       }
 
-       if (!pd_src)
+       if (!pd_src) {
                pd_src = "";
+       }
 
-       if (!pd_group)
+       if (!pd_group) {
                pd_group = "";
+       }
 
-       if (!libexec)
+       if (!libexec) {
                libexec = "";
+       }
 
-       if (!timeout)
+       if (!timeout) {
                timeout = "10";
+       }
 
-       if (!period)
+       if (!period) {
                period = "0.0";
+       }
 
-       if (!script)
+       if (!script) {
                script = "edje";
+       }
 
        dml = "INSERT INTO provider ( pkgid, network, abi, secured, box_type, box_src, box_group, pd_type, pd_src, pd_group, libexec, timeout, period, script, pinup ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
        ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
@@ -634,8 +646,9 @@ static inline int db_create_client(void)
                return -EIO;
        }
 
-       if (sqlite3_changes(s_info.handle) == 0)
+       if (sqlite3_changes(s_info.handle) == 0) {
                ErrPrint("No changes to DB\n");
+       }
 
        return 0;
 }
@@ -774,8 +787,9 @@ static inline int db_create_i18n(void)
                return -EIO;
        }
 
-       if (sqlite3_changes(s_info.handle) == 0)
+       if (sqlite3_changes(s_info.handle) == 0) {
                ErrPrint("No changes to DB\n");
+       }
 
        return 0;
 }
@@ -861,8 +875,9 @@ static inline int db_remove_i18n(const char *pkgid)
                ret = -EIO;
        }
 
-       if (sqlite3_changes(s_info.handle) == 0)
+       if (sqlite3_changes(s_info.handle) == 0) {
                DbgPrint("No changes\n");
+       }
 
 out:
        sqlite3_reset(stmt);
@@ -882,8 +897,9 @@ static inline int db_create_group(void)
                return -EIO;
        }
 
-       if (sqlite3_changes(s_info.handle) == 0)
+       if (sqlite3_changes(s_info.handle) == 0) {
                ErrPrint("No changes to DB\n");
+       }
 
        return 0;
 }
@@ -1003,8 +1019,9 @@ static inline int db_remove_group(const char *pkgid)
                ret = -EIO;
        }
 
-       if (sqlite3_changes(s_info.handle) == 0)
+       if (sqlite3_changes(s_info.handle) == 0) {
                DbgPrint("No changes\n");
+       }
 
 out:
        sqlite3_reset(stmt);
@@ -1024,8 +1041,9 @@ static inline int db_create_groupmap(void)
                return -EIO;
        }
 
-       if (sqlite3_changes(s_info.handle) == 0)
+       if (sqlite3_changes(s_info.handle) == 0) {
                ErrPrint("No changes to DB\n");
+       }
 
        return 0;
 }
@@ -1155,8 +1173,9 @@ static inline int db_remove_groupmap(const char *pkgid)
                ret = -EIO;
        }
 
-       if (sqlite3_changes(s_info.handle) == 0)
+       if (sqlite3_changes(s_info.handle) == 0) {
                DbgPrint("No changes\n");
+       }
 
 out:
        sqlite3_reset(stmt);
@@ -1178,8 +1197,9 @@ static inline int db_create_option(void)
                return -EIO;
        }
 
-       if (sqlite3_changes(s_info.handle) == 0)
+       if (sqlite3_changes(s_info.handle) == 0) {
                ErrPrint("No changes to DB\n");
+       }
 
        return 0;
 }
@@ -1263,8 +1283,9 @@ static inline int db_remove_option(const char *pkgid)
                ret = -EIO;
        }
 
-       if (sqlite3_changes(s_info.handle) == 0)
+       if (sqlite3_changes(s_info.handle) == 0) {
                DbgPrint("No changes\n");
+       }
 
 out:
        sqlite3_reset(stmt);
@@ -1285,8 +1306,9 @@ static inline int db_create_box_size(void)
                return -EIO;
        }
 
-       if (sqlite3_changes(s_info.handle) == 0)
+       if (sqlite3_changes(s_info.handle) == 0) {
                ErrPrint("No changes to DB\n");
+       }
 
        return 0;
 }
@@ -1379,8 +1401,9 @@ static inline int db_remove_box_size(const char *pkgid)
                ret = -EIO;
        }
 
-       if (sqlite3_changes(s_info.handle) == 0)
+       if (sqlite3_changes(s_info.handle) == 0) {
                DbgPrint("No changes\n");
+       }
 
 out:
        sqlite3_reset(stmt);
@@ -1470,16 +1493,18 @@ static inline int db_init(void)
                return -EINVAL;
        }
 
-       if (!stat.st_size)
+       if (!stat.st_size) {
                db_create_table();
+       }
 
        return 0;
 }
 
 static inline int db_fini(void)
 {
-       if (!s_info.handle)
+       if (!s_info.handle) {
                return 0;
+       }
 
        db_util_close(s_info.handle);
        s_info.handle = NULL;
@@ -1775,14 +1800,15 @@ static inline void update_box(struct livebox *livebox, xmlNodePtr node)
                        ErrPrint("Type is NIL\n");
                        livebox->lb_type = LB_TYPE_FILE;
                } else {
-                       if (!xmlStrcasecmp(type, (const xmlChar *)"text"))
+                       if (!xmlStrcasecmp(type, (const xmlChar *)"text")) {
                                livebox->lb_type = LB_TYPE_TEXT;
-                       else if (!xmlStrcasecmp(type, (const xmlChar *)"buffer"))
+                       } else if (!xmlStrcasecmp(type, (const xmlChar *)"buffer")) {
                                livebox->lb_type = LB_TYPE_BUFFER;
-                       else if (!xmlStrcasecmp(type, (const xmlChar *)"script"))
+                       } else if (!xmlStrcasecmp(type, (const xmlChar *)"script")) {
                                livebox->lb_type = LB_TYPE_SCRIPT;
-                       else /* Default */
+                       } else { /* Default */
                                livebox->lb_type = LB_TYPE_FILE;
+                       }
 
                        xmlFree(type);
                }
@@ -2099,12 +2125,13 @@ static inline void update_pd(struct livebox *livebox, xmlNodePtr node)
                        return;
                }
 
-               if (!xmlStrcasecmp(type, (const xmlChar *)"text"))
+               if (!xmlStrcasecmp(type, (const xmlChar *)"text")) {
                        livebox->pd_type = PD_TYPE_TEXT;
-               else if (!xmlStrcasecmp(type, (const xmlChar *)"buffer"))
+               } else if (!xmlStrcasecmp(type, (const xmlChar *)"buffer")) {
                        livebox->pd_type = PD_TYPE_BUFFER;
-               else
+               } else {
                        livebox->pd_type = PD_TYPE_SCRIPT;
+               }
 
                xmlFree(type);
        }
@@ -2175,99 +2202,116 @@ static inline int db_insert_livebox(struct livebox *livebox, const char *appid)
 
        begin_transaction();
        ret = db_insert_pkgmap(appid, (char *)livebox->pkgid, (char *)livebox->uiapp, livebox->primary);
-       if (ret < 0)
+       if (ret < 0) {
                goto errout;
+       }
 
        ret = db_insert_provider(livebox);
-       if (ret < 0)
+       if (ret < 0) {
                goto errout;
+       }
 
        ret = db_insert_client(livebox);
-       if (ret < 0)
+       if (ret < 0) {
                goto errout;
+       }
 
        dlist_foreach(livebox->i18n_list, l, i18n) {
                ret = db_insert_i18n((char *)livebox->pkgid, (char *)i18n->lang, (char *)i18n->name, (char *)i18n->icon);
-               if (ret < 0)
+               if (ret < 0) {
                        goto errout;
+               }
        }
 
        if (livebox->size_list & LB_SIZE_TYPE_1x1) {
                ret = db_insert_box_size((char *)livebox->pkgid, LB_SIZE_TYPE_1x1, (char *)livebox->preview[0], livebox->touch_effect[0], livebox->need_frame[0]);
-               if (ret < 0)
+               if (ret < 0) {
                        goto errout;
+               }
        }
 
        if (livebox->size_list & LB_SIZE_TYPE_2x1) {
                ret = db_insert_box_size((char *)livebox->pkgid, LB_SIZE_TYPE_2x1, (char *)livebox->preview[1], livebox->touch_effect[1], livebox->need_frame[1]);
-               if (ret < 0)
+               if (ret < 0) {
                        goto errout;
+               }
        }
 
        if (livebox->size_list & LB_SIZE_TYPE_2x2) {
                ret = db_insert_box_size((char *)livebox->pkgid, LB_SIZE_TYPE_2x2, (char *)livebox->preview[2], livebox->touch_effect[2], livebox->need_frame[2]);
-               if (ret < 0)
+               if (ret < 0) {
                        goto errout;
+               }
        }
 
        if (livebox->size_list & LB_SIZE_TYPE_4x1) {
                ret = db_insert_box_size((char *)livebox->pkgid, LB_SIZE_TYPE_4x1, (char *)livebox->preview[3], livebox->touch_effect[3], livebox->need_frame[3]);
-               if (ret < 0)
+               if (ret < 0) {
                        goto errout;
+               }
        }
 
        if (livebox->size_list & LB_SIZE_TYPE_4x2) {
                ret = db_insert_box_size((char *)livebox->pkgid, LB_SIZE_TYPE_4x2, (char *)livebox->preview[4], livebox->touch_effect[4], livebox->need_frame[4]);
-               if (ret < 0)
+               if (ret < 0) {
                        goto errout;
+               }
        }
 
        if (livebox->size_list & LB_SIZE_TYPE_4x3) {
                ret = db_insert_box_size((char *)livebox->pkgid, LB_SIZE_TYPE_4x3, (char *)livebox->preview[5], livebox->touch_effect[5], livebox->need_frame[5]);
-               if (ret < 0)
+               if (ret < 0) {
                        goto errout;
+               }
        }
 
        if (livebox->size_list & LB_SIZE_TYPE_4x4) {
                ret = db_insert_box_size((char *)livebox->pkgid, LB_SIZE_TYPE_4x4, (char *)livebox->preview[6], livebox->touch_effect[6], livebox->need_frame[6]);
-               if (ret < 0)
+               if (ret < 0) {
                        goto errout;
+               }
        }
 
        if (livebox->size_list & LB_SIZE_TYPE_4x5) {
                ret = db_insert_box_size((char *)livebox->pkgid, LB_SIZE_TYPE_4x5, (char *)livebox->preview[7], livebox->touch_effect[7], livebox->need_frame[7]);
-               if (ret < 0)
+               if (ret < 0) {
                        goto errout;
+               }
        }
 
        if (livebox->size_list & LB_SIZE_TYPE_4x6) {
                ret = db_insert_box_size((char *)livebox->pkgid, LB_SIZE_TYPE_4x6, (char *)livebox->preview[8], livebox->touch_effect[8], livebox->need_frame[8]);
-               if (ret < 0)
+               if (ret < 0) {
                        goto errout;
+               }
        }
 
        if (livebox->size_list & LB_SIZE_TYPE_EASY_1x1) {
                ret = db_insert_box_size((char *)livebox->pkgid, LB_SIZE_TYPE_EASY_1x1, (char *)livebox->preview[9], livebox->touch_effect[9], livebox->need_frame[9]);
-               if (ret < 0)
+               if (ret < 0) {
                        goto errout;
+               }
        }
 
        if (livebox->size_list & LB_SIZE_TYPE_EASY_3x1) {
                ret = db_insert_box_size((char *)livebox->pkgid, LB_SIZE_TYPE_EASY_3x1, (char *)livebox->preview[10], livebox->touch_effect[10], livebox->need_frame[10]);
-               if (ret < 0)
+               if (ret < 0) {
                        goto errout;
+               }
        }
 
        if (livebox->size_list & LB_SIZE_TYPE_EASY_3x3) {
                ret = db_insert_box_size((char *)livebox->pkgid, LB_SIZE_TYPE_EASY_3x3, (char *)livebox->preview[11], livebox->touch_effect[11], livebox->need_frame[11]);
-               if (ret < 0)
+               if (ret < 0) {
                        goto errout;
+               }
        }
 
        if (livebox->size_list & LB_SIZE_TYPE_0x0) {
                ret = db_insert_box_size((char *)livebox->pkgid, LB_SIZE_TYPE_0x0, (char *)livebox->preview[12], livebox->touch_effect[12], livebox->need_frame[12]);
-               if (ret < 0)
+               if (ret < 0) {
                        goto errout;
+               }
        }
 
        dlist_foreach(livebox->group_list, l, group) {
@@ -2296,18 +2340,21 @@ static inline int db_insert_livebox(struct livebox *livebox, const char *appid)
                }
 
                ret = db_insert_groupmap(id, (char *)livebox->pkgid, (char *)group->ctx_item);
-               if (ret < 0)
+               if (ret < 0) {
                        goto errout;
+               }
 
                /* REUSE "id" from here , option ID */
                id = db_get_option_id(id, (char *)livebox->pkgid, (char *)group->ctx_item);
-               if (id < 0)
+               if (id < 0) {
                        goto errout;
+               }
 
                dlist_foreach(group->option_list, il, option) {
                        ret = db_insert_option((char *)livebox->pkgid, id, (char *)option->key, (char *)option->value);
-                       if (ret < 0)
+                       if (ret < 0) {
                                goto errout;
+                       }
                }
        }
 
@@ -2359,8 +2406,9 @@ static inline int do_install(xmlNodePtr node, const char *appid)
 
        if (xmlHasProp(node, (const xmlChar *)"script")) {
                livebox->script = xmlGetProp(node, (const xmlChar *)"script");
-               if (!livebox->script)
+               if (!livebox->script) {
                        ErrPrint("script is NIL\n");
+               }
        }
 
        if (xmlHasProp(node, (const xmlChar *)"nodisplay")) {
@@ -2377,14 +2425,16 @@ static inline int do_install(xmlNodePtr node, const char *appid)
 
        if (xmlHasProp(node, (const xmlChar *)"period")) {
                livebox->period = xmlGetProp(node, (const xmlChar *)"period");
-               if (!livebox->period)
+               if (!livebox->period) {
                        ErrPrint("Period is NIL\n");
+               }
        }
 
        if (xmlHasProp(node, (const xmlChar *)"timeout")) {
                livebox->timeout = xmlGetProp(node, (const xmlChar *)"timeout");
-               if (!livebox->timeout)
+               if (!livebox->timeout) {
                        ErrPrint("Timeout is NIL\n");
+               }
        }
 
        if (xmlHasProp(node, (const xmlChar *)"secured")) {
@@ -2446,8 +2496,9 @@ static inline int do_install(xmlNodePtr node, const char *appid)
        }
 
        for (node = node->children; node; node = node->next) {
-               if (!xmlStrcmp(node->name, (const xmlChar *)"text"))
+               if (!xmlStrcmp(node->name, (const xmlChar *)"text")) {
                        continue;
+               }
 
                DbgPrint("Nodename: %s\n", node->name);
                if (!xmlStrcasecmp(node->name, (const xmlChar *)"label")) {
@@ -2499,35 +2550,6 @@ static inline int do_install(xmlNodePtr node, const char *appid)
        return db_insert_livebox(livebox, appid);
 }
 
-int PKGMGR_PARSER_PLUGIN_INSTALL(xmlDocPtr docPtr, const char *appid)
-{
-       xmlNodePtr node;
-       int ret;
-
-       if (!s_info.handle) {
-               if (db_init() < 0) {
-                       ErrPrint("Failed to init DB\n");
-                       return -EIO;
-               }
-       }
-
-       node = xmlDocGetRootElement(docPtr);
-       if (!node) {
-               ErrPrint("Invalid document\n");
-               return -EINVAL;
-       }
-
-       for (node = node->children; node; node = node->next) {
-               DbgPrint("node->name: %s\n", node->name);
-               if (!xmlStrcasecmp(node->name, (const xmlChar *)"livebox")) {
-                       ret = do_install(node, appid);
-                       DbgPrint("Returns: %d\n", ret);
-               }
-       }
-
-       return 0;
-}
-
 static inline int do_uninstall(xmlNodePtr node, const char *appid)
 {
        xmlChar *pkgid;
@@ -2547,20 +2569,24 @@ static inline int do_uninstall(xmlNodePtr node, const char *appid)
 
        begin_transaction();
        ret = db_remove_box_size((char *)pkgid);
-       if (ret < 0)
+       if (ret < 0) {
                goto errout;
+       }
 
        ret = db_remove_i18n((char *)pkgid);
-       if (ret < 0)
+       if (ret < 0) {
                goto errout;
+       }
 
        ret = db_remove_client((char *)pkgid);
-       if (ret < 0)
+       if (ret < 0) {
                goto errout;
+       }
 
        ret = db_remove_provider((char *)pkgid);
-       if (ret < 0)
+       if (ret < 0) {
                goto errout;
+       }
 
        ret = db_remove_option((char *)pkgid);
        DbgPrint("Remove option: %d\n", ret);
@@ -2569,12 +2595,14 @@ static inline int do_uninstall(xmlNodePtr node, const char *appid)
        DbgPrint("Remove groupmap: %d\n", ret);
 
        ret = db_remove_group((char *)pkgid);
-       if (ret < 0)
+       if (ret < 0) {
                goto errout;
+       }
 
        ret = db_remove_pkgmap((char *)pkgid);
-       if (ret < 0)
+       if (ret < 0) {
                goto errout;
+       }
 
        commit_transaction();
        xmlFree(pkgid);
@@ -2587,7 +2615,126 @@ errout:
        return ret;
 }
 
-int PKGMGR_PARSER_PLUGIN_UPGRADE(xmlDocPtr docPtr, const char *appid)
+static inline int pkglist_get_via_callback(const char *appid, void (*cb)(const char *appid, const char *pkgid, int prime, void *data), void *data)
+{
+       const char *dml = "SELECT pkgid, prime FROM pkgmap WHERE appid = ?";
+       int ret;
+       sqlite3_stmt *stmt;
+       const char *pkgid;
+       int prime;
+       int cnt = 0;
+
+       if (!cb || !appid || !strlen(appid)) {
+               return -EINVAL;
+       }
+
+       if (!s_info.handle) {
+               if (db_init() < 0) {
+                       ErrPrint("Failed to init DB\n");
+                       return -EIO;
+               }
+       }
+
+       ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
+       if (ret != SQLITE_OK) {
+               ErrPrint("Failed to prepare the intial DML(%s)\n", sqlite3_errmsg(s_info.handle));
+               return -EIO;
+       }
+
+       ret = -EIO;
+       if (sqlite3_bind_text(stmt, 1, appid, -1, SQLITE_TRANSIENT) != SQLITE_OK) {
+               ErrPrint("Failed to bind a cluster - %s\n", sqlite3_errmsg(s_info.handle));
+               goto out;
+       }
+
+       while (sqlite3_step(stmt) == SQLITE_ROW) {
+               pkgid = (const char *)sqlite3_column_text(stmt, 0);
+               if (!pkgid || !strlen(pkgid)) {
+                       continue;
+               }
+
+               prime = sqlite3_column_int(stmt, 1);
+               cb(appid, pkgid, prime, data);
+               cnt++;
+       }
+
+out:
+       sqlite3_reset(stmt);
+       sqlite3_clear_bindings(stmt);
+       sqlite3_finalize(stmt);
+       return cnt;
+}
+
+static void clear_all_pkg(const char *appid, const char *pkgid, int prime, void *data)
+{
+       int ret;
+
+       ret = db_remove_box_size((char *)pkgid);
+       if (ret < 0) {
+               ErrPrint("Remove box size: %d\n", ret);
+       }
+
+       ret = db_remove_i18n((char *)pkgid);
+       if (ret < 0) {
+               ErrPrint("Remove i18n: %d\n", ret);
+       }
+
+       ret = db_remove_client((char *)pkgid);
+       if (ret < 0) {
+               ErrPrint("Remove client: %d\n", ret);
+       }
+
+       ret = db_remove_provider((char *)pkgid);
+       if (ret < 0) {
+               ErrPrint("Remove provider: %d\n", ret);
+       }
+
+       ret = db_remove_option((char *)pkgid);
+       if (ret < 0) {
+               ErrPrint("Remove option: %d\n", ret);
+       }
+
+       ret = db_remove_groupmap((char *)pkgid);
+       if (ret < 0) {
+               ErrPrint("Remove groupmap: %d\n", ret);
+       }
+
+       ret = db_remove_group((char *)pkgid);
+       if (ret < 0) {
+               ErrPrint("Remove group: %d\n", ret);
+       }
+
+       ret = db_remove_pkgmap((char *)pkgid);
+       if (ret < 0) {
+               ErrPrint("Remove pkgmap: %d\n", ret);
+       }
+}
+
+int PKGMGR_PARSER_PLUGIN_PRE_INSTALL(const char *appid)
+{
+       int cnt;
+
+       if (!s_info.handle) {
+               if (db_init() < 0) {
+                       ErrPrint("Failed to init DB\n");
+                       return -EIO;
+               }
+       }
+
+       begin_transaction();
+       cnt = pkglist_get_via_callback(appid, clear_all_pkg, NULL);
+       commit_transaction();
+
+       DbgPrint("Package[%s] is not deleted: %d\n", appid, cnt);
+       return 0;
+}
+
+int PKGMGR_PARSER_PLUGIN_POST_INSTALL(const char *appid)
+{
+       return 0;
+}
+
+int PKGMGR_PARSER_PLUGIN_INSTALL(xmlDocPtr docPtr, const char *appid)
 {
        xmlNodePtr node;
        int ret;
@@ -2606,8 +2753,8 @@ int PKGMGR_PARSER_PLUGIN_UPGRADE(xmlDocPtr docPtr, const char *appid)
        }
 
        for (node = node->children; node; node = node->next) {
+               DbgPrint("node->name: %s\n", node->name);
                if (!xmlStrcasecmp(node->name, (const xmlChar *)"livebox")) {
-                       ret = do_uninstall(node, appid);
                        ret = do_install(node, appid);
                        DbgPrint("Returns: %d\n", ret);
                }
@@ -2616,7 +2763,31 @@ int PKGMGR_PARSER_PLUGIN_UPGRADE(xmlDocPtr docPtr, const char *appid)
        return 0;
 }
 
-int PKGMGR_PARSER_PLUGIN_UNINSTALL(xmlDocPtr docPtr, const char *appid)
+int PKGMGR_PARSER_PLUGIN_PRE_UPGRADE(const char *appid)
+{
+       int cnt;
+
+       if (!s_info.handle) {
+               if (db_init() < 0) {
+                       ErrPrint("Failed to init DB\n");
+                       return -EIO;
+               }
+       }
+
+       begin_transaction();
+       cnt = pkglist_get_via_callback(appid, clear_all_pkg, NULL);
+       commit_transaction();
+
+       DbgPrint("Package %s is deleted: %d\n", appid, cnt);
+       return 0;
+}
+
+int PKGMGR_PARSER_PLUGIN_POST_UPGRADE(const char *appid)
+{
+       return 0;
+}
+
+int PKGMGR_PARSER_PLUGIN_UPGRADE(xmlDocPtr docPtr, const char *appid)
 {
        xmlNodePtr node;
        int ret;
@@ -2636,7 +2807,7 @@ int PKGMGR_PARSER_PLUGIN_UNINSTALL(xmlDocPtr docPtr, const char *appid)
 
        for (node = node->children; node; node = node->next) {
                if (!xmlStrcasecmp(node->name, (const xmlChar *)"livebox")) {
-                       ret = do_uninstall(node, appid);
+                       ret = do_install(node, appid);
                        DbgPrint("Returns: %d\n", ret);
                }
        }
@@ -2644,4 +2815,34 @@ int PKGMGR_PARSER_PLUGIN_UNINSTALL(xmlDocPtr docPtr, const char *appid)
        return 0;
 }
 
+int PKGMGR_PARSER_PLUGIN_PRE_UNINSTALL(const char *appid)
+{
+       return 0;
+}
+
+int PKGMGR_PARSER_PLUGIN_POST_UNINSTALL(const char *appid)
+{
+       int cnt;
+
+       if (!s_info.handle) {
+               if (db_init() < 0) {
+                       ErrPrint("Failed to init DB\n");
+                       return -EIO;
+               }
+       }
+
+       begin_transaction();
+       cnt = pkglist_get_via_callback(appid, clear_all_pkg, NULL);
+       commit_transaction();
+
+       DbgPrint("Package %s is deleted: %d\n", appid, cnt);
+       return 0;
+}
+
+int PKGMGR_PARSER_PLUGIN_UNINSTALL(xmlDocPtr docPtr, const char *appid)
+{
+       /* Doesn't need to do anything from here, we already dealt it with this */
+       return 0;
+}
+
 /* End of a file */
index ec7f868..9eda604 100644 (file)
@@ -4,6 +4,6 @@
 #      DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/master.edc
 #)
 #ADD_DEPENDENCIES(${PROJECT_NAME} master.edj)
-#INSTALL(FILES master.edj DESTINATION "/opt/apps/org.tizen.${PROJECT_NAME}/res/edje")
+#INSTALL(FILES master.edj DESTINATION "/opt/apps/com.samsung.${PROJECT_NAME}/res/edje")
 
 # End of a file
index 713bfe5..edbfa21 100644 (file)
--- a/src/abi.c
+++ b/src/abi.c
@@ -129,8 +129,9 @@ HAPI const char *abi_find_slave(const char *abi)
        struct item *item;
 
        EINA_LIST_FOREACH(s_abi.list, l, item) {
-               if (!strcasecmp(item->abi, abi))
+               if (!strcasecmp(item->abi, abi)) {
                        return item->pkgname;
+               }
        }
 
        return NULL;
@@ -142,8 +143,9 @@ HAPI const char *abi_find_by_pkgname(const char *pkgname)
        struct item *item;
 
        EINA_LIST_FOREACH(s_abi.list, l, item) {
-               if (!strcmp(item->pkgname, pkgname))
+               if (!strcmp(item->pkgname, pkgname)) {
                        return item->abi;
+               }
        }
 
        return NULL;
index dec460c..ac3f302 100755 (executable)
@@ -89,7 +89,6 @@ static void _handler_insert_badge(struct tcb *tcb, struct packet *packet, void *
 
                if (pkgname != NULL && writable_pkg != NULL && caller != NULL) {
                        ret = badge_db_insert(pkgname, writable_pkg, caller);
-
                } else {
                        ret = BADGE_ERROR_INVALID_DATA;
                }
@@ -136,7 +135,6 @@ static void _handler_delete_badge(struct tcb *tcb, struct packet *packet, void *
 
                if (pkgname != NULL && caller != NULL) {
                        ret = badge_db_delete(pkgname, caller);
-
                } else {
                        ret = BADGE_ERROR_INVALID_DATA;
                }
@@ -184,7 +182,6 @@ static void _handler_set_badge_count(struct tcb *tcb, struct packet *packet, voi
 
                if (pkgname != NULL && caller != NULL) {
                        ret = badge_db_set_count(pkgname, caller, count);
-
                } else {
                        ret = BADGE_ERROR_INVALID_DATA;
                }
@@ -232,7 +229,6 @@ static void _handler_set_display_option(struct tcb *tcb, struct packet *packet,
 
                if (pkgname != NULL && caller != NULL) {
                        ret = badge_db_set_display_option(pkgname, caller, is_display);
-
                } else {
                        ret = BADGE_ERROR_INVALID_DATA;
                }
@@ -379,8 +375,9 @@ static int service_thread_main(struct tcb *tcb, struct packet *packet, void *dat
        case PACKET_REQ:
                /* Need to send reply packet */
                for (i = 0; service_req_table[i].cmd; i++) {
-                       if (strcmp(service_req_table[i].cmd, command))
+                       if (strcmp(service_req_table[i].cmd, command)) {
                                continue;
+                       }
 
 #if ENABLE_BS_ACCESS_CONTROL
                        if (_is_valid_permission(tcb_fd(tcb), &(service_req_table[i])) == 1) {
@@ -454,8 +451,9 @@ HAPI int badge_service_init(void)
 
 HAPI int badge_service_fini(void)
 {
-       if (!s_info.svc_ctx)
+       if (!s_info.svc_ctx) {
                return LB_STATUS_ERROR_INVALID;
+       }
 
        service_common_destroy(s_info.svc_ctx);
        s_info.svc_ctx = NULL;
index 2c5493c..9c46fa5 100644 (file)
@@ -174,8 +174,9 @@ static inline struct buffer *create_pixmap(struct buffer_info *info)
        GC gc;
 
        disp = ecore_x_display_get();
-       if (!disp)
+       if (!disp) {
                return NULL;
+       }
 
        parent = DefaultRootWindow(disp);
 
@@ -272,8 +273,9 @@ static inline int create_gem(struct buffer *buffer)
 
        if (gem->dri2_buffer->pitch != gem->w * gem->depth) {
                gem->compensate_data = calloc(1, gem->w * gem->h * gem->depth);
-               if (!gem->compensate_data)
+               if (!gem->compensate_data) {
                        ErrPrint("Failed to allocate heap\n");
+               }
        }
 
        DbgPrint("dri2_buffer: %p, name: %p, %dx%d, pitch: %d, buf_count: %d, depth: %d, compensate: %p\n",
@@ -287,8 +289,9 @@ static inline void *acquire_gem(struct buffer *buffer)
 {
        struct gem_data *gem;
 
-       if (!buffer)
+       if (!buffer) {
                return NULL;
+       }
 
        gem = (struct gem_data *)buffer->data;
        if (s_info.fd < 0) {
@@ -361,15 +364,17 @@ static inline void release_gem(struct buffer *buffer)
                                gap = gem->dri2_buffer->pitch - (gem->w * gem->depth);
 
                                for (y = 0; y < gem->h; y++) {
-                                       for (x = 0; x < gem->w; x++)
+                                       for (x = 0; x < gem->w; x++) {
                                                *gem_pixel++ = *pixel++;
+                                       }
 
                                        gem_pixel = (int *)(((char *)gem_pixel) + gap);
                                }
                        }
 
-                       if (gem->pixmap_bo)
+                       if (gem->pixmap_bo) {
                                tbm_bo_unmap(gem->pixmap_bo);
+                       }
 
                        gem->data = NULL;
                }
@@ -389,8 +394,9 @@ static inline int destroy_pixmap(struct buffer *buffer)
                Display *disp;
 
                disp = ecore_x_display_get();
-               if (!disp)
+               if (!disp) {
                        return LB_STATUS_ERROR_IO;
+               }
 
                DbgPrint("pixmap %lu\n", gem->pixmap);
                XFreePixmap(disp, gem->pixmap);
@@ -405,15 +411,17 @@ static inline int destroy_gem(struct buffer *buffer)
 {
        struct gem_data *gem;
 
-       if (!buffer)
+       if (!buffer) {
                return LB_STATUS_ERROR_INVALID;
+       }
 
        /*!
         * Forcely release the acquire_buffer.
         */
        gem = (struct gem_data *)buffer->data;
-       if (!gem)
+       if (!gem) {
                return LB_STATUS_ERROR_FAULT;
+       }
 
        if (s_info.fd >= 0) {
                if (gem->compensate_data) {
@@ -508,8 +516,9 @@ static inline int load_shm_buffer(struct buffer_info *info)
        if (buffer == (void *)-1) {
                ErrPrint("%s shmat: %s\n", info->id, strerror(errno));
 
-               if (shmctl(id, IPC_RMID, 0) < 0)
+               if (shmctl(id, IPC_RMID, 0) < 0) {
                        ErrPrint("%s shmctl: %s\n", info->id, strerror(errno));
+               }
 
                return LB_STATUS_ERROR_FAULT;
        }
@@ -524,11 +533,13 @@ static inline int load_shm_buffer(struct buffer_info *info)
        new_id = malloc(len);
        if (!new_id) {
                ErrPrint("Heap: %s\n", strerror(errno));
-               if (shmdt(buffer) < 0)
+               if (shmdt(buffer) < 0) {
                        ErrPrint("shmdt: %s\n", strerror(errno));
+               }
 
-               if (shmctl(id, IPC_RMID, 0) < 0)
+               if (shmctl(id, IPC_RMID, 0) < 0) {
                        ErrPrint("shmctl: %s\n", strerror(errno));
+               }
 
                return LB_STATUS_ERROR_MEMORY;
        }
@@ -557,8 +568,9 @@ static inline int load_pixmap_buffer(struct buffer_info *info)
         */
        info->is_loaded = 1;
 
-       if (info->buffer)
+       if (info->buffer) {
                DbgPrint("Buffer is already exists, but override it with new one\n");
+       }
 
        buffer = buffer_handler_pixmap_ref(info);
        if (!buffer) {
@@ -634,8 +646,9 @@ static inline int unload_file_buffer(struct buffer_info *info)
        info->buffer = NULL;
 
        path = util_uri_to_path(info->id);
-       if (path && unlink(path) < 0)
+       if (path && unlink(path) < 0) {
                ErrPrint("unlink: %s\n", strerror(errno));
+       }
 
        DbgFree(info->id);
        info->id = new_id;
@@ -665,11 +678,13 @@ static inline int unload_shm_buffer(struct buffer_info *info)
                return LB_STATUS_ERROR_INVALID;
        }
 
-       if (shmdt(info->buffer) < 0)
+       if (shmdt(info->buffer) < 0) {
                ErrPrint("Detach shm: %s\n", strerror(errno));
+       }
 
-       if (shmctl(id, IPC_RMID, 0) < 0)
+       if (shmctl(id, IPC_RMID, 0) < 0) {
                ErrPrint("Remove shm: %s\n", strerror(errno));
+       }
 
        info->buffer = NULL;
 
@@ -748,8 +763,9 @@ HAPI int buffer_handler_unload(struct buffer_info *info)
                break;
        }
 
-       if (ret == 0)
+       if (ret == 0) {
                info->is_loaded = 0;
+       }
 
        return ret;
 }
@@ -765,8 +781,9 @@ HAPI int buffer_handler_destroy(struct buffer_info *info)
        }
 
        EINA_LIST_FOREACH(s_info.pixmap_list, l, buffer) {
-               if (buffer->info == info)
+               if (buffer->info == info) {
                        buffer->info = NULL;
+               }
        }
 
        buffer_handler_unload(info);
@@ -789,8 +806,9 @@ HAPI void *buffer_handler_fb(struct buffer_info *info)
 {
        struct buffer *buffer;
 
-       if (!info)
+       if (!info) {
                return NULL;
+       }
 
        buffer = info->buffer;
 
@@ -804,8 +822,9 @@ HAPI void *buffer_handler_fb(struct buffer_info *info)
                 */
                canvas = buffer_handler_pixmap_acquire_buffer(info);
                ret = buffer_handler_pixmap_release_buffer(canvas);
-               if (ret < 0)
+               if (ret < 0) {
                        ErrPrint("Failed to release buffer: %d\n", ret);
+               }
                return canvas;
        }
 
@@ -847,8 +866,9 @@ HAPI void *buffer_handler_pixmap_acquire_buffer(struct buffer_info *info)
        }
 
        buffer = buffer_handler_pixmap_ref(info);
-       if (!buffer)
+       if (!buffer) {
                return NULL;
+       }
 
        return acquire_gem(buffer);
 }
@@ -858,8 +878,9 @@ HAPI void *buffer_handler_pixmap_buffer(struct buffer_info *info)
        struct buffer *buffer;
        struct gem_data *gem;
 
-       if (!info)
+       if (!info) {
                return NULL;
+       }
 
        if (!info->is_loaded) {
                ErrPrint("Buffer is not loaded\n");
@@ -867,8 +888,9 @@ HAPI void *buffer_handler_pixmap_buffer(struct buffer_info *info)
        }
 
        buffer = info->buffer;
-       if (!buffer)
+       if (!buffer) {
                return NULL;
+       }
 
        gem = (struct gem_data *)buffer->data;
        return gem->compensate_data ? gem->compensate_data : gem->data;
@@ -908,17 +930,20 @@ HAPI void *buffer_handler_pixmap_ref(struct buffer_info *info)
 
                        if (instance_lb_buffer(info->inst) == info) {
                                pkg = instance_package(info->inst);
-                               if (package_lb_type(pkg) == LB_TYPE_BUFFER)
+                               if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
                                        need_gem = 0;
+                               }
                        } else if (instance_pd_buffer(info->inst) == info) {
                                pkg = instance_package(info->inst);
-                               if (package_pd_type(pkg) == PD_TYPE_BUFFER)
+                               if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
                                        need_gem = 0;
+                               }
                        }
                }
 
-               if (need_gem)
+               if (need_gem) {
                        create_gem(buffer);
+               }
 
        } else if (buffer->state != CREATED || buffer->type != BUFFER_TYPE_PIXMAP) {
                ErrPrint("Invalid buffer\n");
@@ -942,8 +967,9 @@ HAPI void *buffer_handler_pixmap_find(int pixmap)
        Eina_List *l;
        Eina_List *n;
 
-       if (pixmap == 0)
+       if (pixmap == 0) {
                return NULL;
+       }
 
        EINA_LIST_FOREACH_SAFE(s_info.pixmap_list, l, n, buffer) {
                if (!buffer || buffer->state != CREATED || buffer->type != BUFFER_TYPE_PIXMAP) {
@@ -953,8 +979,9 @@ HAPI void *buffer_handler_pixmap_find(int pixmap)
                }
 
                gem = (struct gem_data *)buffer->data;
-               if (gem->pixmap == pixmap)
+               if (gem->pixmap == pixmap) {
                        return buffer;
+               }
        }
 
        return NULL;
@@ -968,8 +995,9 @@ HAPI int buffer_handler_pixmap_release_buffer(void *canvas)
        Eina_List *n;
        void *_ptr;
 
-       if (!canvas)
+       if (!canvas) {
                return LB_STATUS_ERROR_INVALID;
+       }
 
        EINA_LIST_FOREACH_SAFE(s_info.pixmap_list, l, n, buffer) {
                if (!buffer || buffer->state != CREATED || buffer->type != BUFFER_TYPE_PIXMAP) {
@@ -980,8 +1008,9 @@ HAPI int buffer_handler_pixmap_release_buffer(void *canvas)
                gem = (struct gem_data *)buffer->data;
                _ptr = gem->compensate_data ? gem->compensate_data : gem->data;
 
-               if (!_ptr)
+               if (!_ptr) {
                        continue;
+               }
 
                if (_ptr == canvas) {
                        release_gem(buffer);
@@ -1005,21 +1034,25 @@ HAPI int buffer_handler_pixmap_unref(void *buffer_ptr)
        struct buffer_info *info;
 
        buffer->refcnt--;
-       if (buffer->refcnt > 0)
+       if (buffer->refcnt > 0) {
                return LB_STATUS_SUCCESS; /* Return NULL means, gem buffer still in use */
+       }
 
        s_info.pixmap_list = eina_list_remove(s_info.pixmap_list, buffer);
 
        info = buffer->info;
 
-       if (destroy_gem(buffer) < 0)
+       if (destroy_gem(buffer) < 0) {
                ErrPrint("Failed to destroy gem buffer\n");
+       }
 
-       if (destroy_pixmap(buffer) < 0)
+       if (destroy_pixmap(buffer) < 0) {
                ErrPrint("Failed to destroy pixmap\n");
+       }
 
-       if (info && info->buffer == buffer)
+       if (info && info->buffer == buffer) {
                info->buffer = NULL;
+       }
 
        return LB_STATUS_SUCCESS;
 }
@@ -1031,8 +1064,9 @@ HAPI int buffer_handler_is_loaded(const struct buffer_info *info)
 
 HAPI void buffer_handler_update_size(struct buffer_info *info, int w, int h)
 {
-       if (!info)
+       if (!info) {
                return;
+       }
 
        info->w = w;
        info->h = h;
@@ -1060,25 +1094,30 @@ HAPI int buffer_handler_resize(struct buffer_info *info, int w, int h)
        }
 
        ret = buffer_handler_unload(info);
-       if (ret < 0)
+       if (ret < 0) {
                ErrPrint("Unload: %d\n", ret);
+       }
 
        ret = buffer_handler_load(info);
-       if (ret < 0)
+       if (ret < 0) {
                ErrPrint("Load: %d\n", ret);
+       }
 
        return LB_STATUS_SUCCESS;
 }
 
 HAPI int buffer_handler_get_size(struct buffer_info *info, int *w, int *h)
 {
-       if (!info)
+       if (!info) {
                return LB_STATUS_ERROR_INVALID;
+       }
 
-       if (w)
+       if (w) {
                *w = info->w;
-       if (h)
+       }
+       if (h) {
                *h = info->h;
+       }
 
        return LB_STATUS_SUCCESS;
 }
@@ -1133,8 +1172,9 @@ static inline int sync_for_pixmap(struct buffer *buffer)
        si.readOnly = False;
        si.shmaddr = shmat(si.shmid, NULL, 0);
        if (si.shmaddr == (void *)-1) {
-               if (shmctl(si.shmid, IPC_RMID, 0) < 0)
+               if (shmctl(si.shmid, IPC_RMID, 0) < 0) {
                        ErrPrint("shmctl: %s\n", strerror(errno));
+               }
                return LB_STATUS_ERROR_FAULT;
        }
 
@@ -1146,11 +1186,13 @@ static inline int sync_for_pixmap(struct buffer *buffer)
         */
        xim = XShmCreateImage(disp, visual, (gem->depth << 3), ZPixmap, NULL, &si, gem->w, gem->h);
        if (xim == NULL) {
-               if (shmdt(si.shmaddr) < 0)
+               if (shmdt(si.shmaddr) < 0) {
                        ErrPrint("shmdt: %s\n", strerror(errno));
+               }
 
-               if (shmctl(si.shmid, IPC_RMID, 0) < 0)
+               if (shmctl(si.shmid, IPC_RMID, 0) < 0) {
                        ErrPrint("shmctl: %s\n", strerror(errno));
+               }
                return LB_STATUS_ERROR_FAULT;
        }
 
@@ -1163,11 +1205,13 @@ static inline int sync_for_pixmap(struct buffer *buffer)
                XShmDetach(disp, &si);
                XDestroyImage(xim);
 
-               if (shmdt(si.shmaddr) < 0)
+               if (shmdt(si.shmaddr) < 0) {
                        ErrPrint("shmdt: %s\n", strerror(errno));
+               }
 
-               if (shmctl(si.shmid, IPC_RMID, 0) < 0)
+               if (shmctl(si.shmid, IPC_RMID, 0) < 0) {
                        ErrPrint("shmctl: %s\n", strerror(errno));
+               }
 
                return LB_STATUS_ERROR_FAULT;
        }
@@ -1185,11 +1229,13 @@ static inline int sync_for_pixmap(struct buffer *buffer)
        XShmDetach(disp, &si);
        XDestroyImage(xim);
 
-       if (shmdt(si.shmaddr) < 0)
+       if (shmdt(si.shmaddr) < 0) {
                ErrPrint("shmdt: %s\n", strerror(errno));
+       }
 
-       if (shmctl(si.shmid, IPC_RMID, 0) < 0)
+       if (shmctl(si.shmid, IPC_RMID, 0) < 0) {
                ErrPrint("shmctl: %s\n", strerror(errno));
+       }
 
        return LB_STATUS_SUCCESS;
 }
@@ -1200,8 +1246,9 @@ HAPI void buffer_handler_flush(struct buffer_info *info)
        int size;
        struct buffer *buffer;
 
-       if (!info || !info->buffer)
+       if (!info || !info->buffer) {
                return;
+       }
 
        buffer = info->buffer;
 
@@ -1220,8 +1267,9 @@ HAPI void buffer_handler_flush(struct buffer_info *info)
                        XFixesDestroyRegion(ecore_x_display_get(), region);
                        XFlush(ecore_x_display_get());
                } else {
-                       if (sync_for_pixmap(buffer) < 0)
+                       if (sync_for_pixmap(buffer) < 0) {
                                ErrPrint("Failed to sync via S/W Backend\n");
+                       }
                }
        } else if (buffer->type == BUFFER_TYPE_FILE) {
                fd = open(util_uri_to_path(info->id), O_WRONLY | O_CREAT, 0644);
@@ -1231,11 +1279,13 @@ HAPI void buffer_handler_flush(struct buffer_info *info)
                }
 
                size = info->w * info->h * info->pixel_size;
-               if (write(fd, info->buffer, size) != size)
+               if (write(fd, info->buffer, size) != size) {
                        ErrPrint("Write is not completed: %s\n", strerror(errno));
+               }
 
-               if (close(fd) < 0)
+               if (close(fd) < 0) {
                        ErrPrint("close: %s\n", strerror(errno));
+               }
        } else {
                DbgPrint("Flush nothing\n");
        }
@@ -1289,8 +1339,9 @@ HAPI int buffer_handler_init(void)
        DbgPrint("DRM Magic: 0x%X\n", magic);
        if (!DRI2Authenticate(ecore_x_display_get(), DefaultRootWindow(ecore_x_display_get()), (unsigned int)magic)) {
                ErrPrint("Failed to do authenticate for DRI2\n");
-               if (close(s_info.fd) < 0)
+               if (close(s_info.fd) < 0) {
                        ErrPrint("close: %s\n", strerror(errno));
+               }
                s_info.fd = -1;
                s_info.evt_base = 0;
                s_info.err_base = 0;
@@ -1300,8 +1351,9 @@ HAPI int buffer_handler_init(void)
        s_info.slp_bufmgr = tbm_bufmgr_init(s_info.fd);
        if (!s_info.slp_bufmgr) {
                ErrPrint("Failed to init bufmgr\n");
-               if (close(s_info.fd) < 0)
+               if (close(s_info.fd) < 0) {
                        ErrPrint("close: %s\n", strerror(errno));
+               }
                s_info.fd = -1;
                s_info.evt_base = 0;
                s_info.err_base = 0;
@@ -1314,8 +1366,9 @@ HAPI int buffer_handler_init(void)
 HAPI int buffer_handler_fini(void)
 {
        if (s_info.fd >= 0) {
-               if (close(s_info.fd) < 0)
+               if (close(s_info.fd) < 0) {
                        ErrPrint("close: %s\n", strerror(errno));
+               }
                s_info.fd = -1;
        }
 
@@ -1344,8 +1397,9 @@ static inline struct buffer *raw_open_file(const char *filename)
        if (off == (off_t)-1) {
                ErrPrint("lseek: %s\n", strerror(errno));
 
-               if (close(fd) < 0)
+               if (close(fd) < 0) {
                        ErrPrint("close: %s\n", strerror(errno));
+               }
 
                return NULL;
        }
@@ -1353,8 +1407,9 @@ static inline struct buffer *raw_open_file(const char *filename)
        if (lseek(fd, 0L, SEEK_SET) == (off_t)-1) {
                ErrPrint("lseek: %s\n", strerror(errno));
 
-               if (close(fd) < 0)
+               if (close(fd) < 0) {
                        ErrPrint("close: %s\n", strerror(errno));
+               }
 
                return NULL;
        }
@@ -1363,8 +1418,9 @@ static inline struct buffer *raw_open_file(const char *filename)
        if (!buffer) {
                ErrPrint("Heap: %s\n", strerror(errno));
 
-               if (close(fd) < 0)
+               if (close(fd) < 0) {
                        ErrPrint("close: %s\n", strerror(errno));
+               }
 
                return NULL;
        }
@@ -1379,14 +1435,16 @@ static inline struct buffer *raw_open_file(const char *filename)
                ErrPrint("read: %s\n", strerror(errno));
                free(buffer);
 
-               if (close(fd) < 0)
+               if (close(fd) < 0) {
                        ErrPrint("close: %s\n", strerror(errno));
+               }
 
                return NULL;
        }
 
-       if (close(fd) < 0)
+       if (close(fd) < 0) {
                ErrPrint("close: %s\n", strerror(errno));
+       }
 
        return buffer;
 }
@@ -1415,8 +1473,9 @@ static inline int raw_close_shm(struct buffer *buffer)
        int ret;
 
        ret = shmdt(buffer);
-       if (ret < 0)
+       if (ret < 0) {
                ErrPrint("shmdt: %s\n", strerror(errno));
+       }
 
        return ret;
 }
@@ -1445,16 +1504,18 @@ static inline int raw_close_pixmap(struct buffer *buffer)
 
 HAPI void *buffer_handler_raw_data(struct buffer *buffer)
 {
-       if (!buffer || buffer->state != CREATED)
+       if (!buffer || buffer->state != CREATED) {
                return NULL;
+       }
 
        return buffer->data;
 }
 
 HAPI int buffer_handler_raw_size(struct buffer *buffer)
 {
-       if (!buffer || buffer->state != CREATED)
+       if (!buffer || buffer->state != CREATED) {
                return -EINVAL;
+       }
 
        return (int)buffer->info;
 }
index 32caae2..36ef853 100644 (file)
@@ -189,8 +189,9 @@ static inline void destroy_client_data(struct client_node *client)
                DbgFree(item);
        }
 
-       if (client->paused)
+       if (client->paused) {
                s_info.nr_of_paused_clients--;
+       }
 
        s_info.client_list = eina_list_remove(s_info.client_list, client);
        DbgFree(client);
@@ -285,8 +286,9 @@ HAPI struct client_node *client_create(pid_t pid, int handle)
 
 HAPI struct client_node *client_ref(struct client_node *client)
 {
-       if (!client)
+       if (!client) {
                return NULL;
+       }
 
        client->refcnt++;
        return client;
@@ -294,8 +296,9 @@ HAPI struct client_node *client_ref(struct client_node *client)
 
 HAPI struct client_node *client_unref(struct client_node *client)
 {
-       if (!client)
+       if (!client) {
                return NULL;
+       }
 
        if (client->refcnt == 0) {
                ErrPrint("Client refcnt is not managed correctly\n");
@@ -327,8 +330,9 @@ HAPI struct client_node *client_find_by_pid(pid_t pid)
        struct client_node *client;
 
        EINA_LIST_FOREACH(s_info.client_list, l, client) {
-               if (client->pid == pid)
+               if (client->pid == pid) {
                        return client;
+               }
        }
 
        return NULL;
@@ -345,8 +349,9 @@ HAPI struct client_node *client_find_by_rpc_handle(int handle)
        }
 
        EINA_LIST_FOREACH(s_info.client_list, l, client) {
-               if (client_rpc_handle(client) == handle)
+               if (client_rpc_handle(client) == handle) {
                        return client;
+               }
        }
 
        return NULL;
@@ -370,8 +375,9 @@ HAPI int client_count(void)
 
 HAPI struct client_node *client_deactivated_by_fault(struct client_node *client)
 {
-       if (!client || client->faulted)
+       if (!client || client->faulted) {
                return client;
+       }
 
        ErrPrint("Client[%p] is faulted(%d), pid(%d)\n", client, client->refcnt, client->pid);
        client->faulted = 1;
@@ -400,8 +406,9 @@ HAPI const int const client_is_faulted(const struct client_node *client)
 
 HAPI void client_reset_fault(struct client_node *client)
 {
-       if (client)
+       if (client) {
                client->faulted = 0;
+       }
 }
 
 HAPI int client_event_callback_add(struct client_node *client, enum client_event event, int (*cb)(struct client_node *, void *), void *data)
@@ -524,8 +531,9 @@ HAPI void *client_data(struct client_node *client, const char *tag)
        struct data_item *item;
 
        EINA_LIST_FOREACH(client->data_list, l, item) {
-               if (!strcmp(item->tag, tag))
+               if (!strcmp(item->tag, tag)) {
                        return item->data;
+               }
        }
 
        return NULL;
@@ -553,8 +561,9 @@ HAPI void *client_del_data(struct client_node *client, const char *tag)
 
 HAPI void client_paused(struct client_node *client)
 {
-       if (client->paused)
+       if (client->paused) {
                return;
+       }
 
        client->paused = 1;
        s_info.nr_of_paused_clients++;
@@ -562,8 +571,9 @@ HAPI void client_paused(struct client_node *client)
 
 HAPI void client_resumed(struct client_node *client)
 {
-       if (client->paused == 0)
+       if (client->paused == 0) {
                return;
+       }
 
        client->paused = 0;
        s_info.nr_of_paused_clients--;
@@ -708,17 +718,21 @@ HAPI int client_is_subscribed(struct client_node *client, const char *cluster, c
        Eina_List *l;
 
        EINA_LIST_FOREACH(client->subscribe_list, l, item) {
-               if (!strcmp(item->cluster, "*"))
+               if (!strcmp(item->cluster, "*")) {
                        return 1;
+               }
 
-               if (strcasecmp(item->cluster, cluster))
+               if (strcasecmp(item->cluster, cluster)) {
                        continue;
+               }
 
-               if (!strcmp(item->category, "*"))
+               if (!strcmp(item->category, "*")) {
                        return 1;
+               }
 
-               if (!strcasecmp(item->category, category))
+               if (!strcasecmp(item->category, category)) {
                        return 1;
+               }
        }
 
        return 0;
@@ -730,16 +744,19 @@ HAPI int client_browse_list(const char *cluster, const char *category, int (*cb)
        struct client_node *client;
        int cnt;
 
-       if (!cb || !cluster || !category)
+       if (!cb || !cluster || !category) {
                return LB_STATUS_ERROR_INVALID;
+       }
 
        cnt = 0;
        EINA_LIST_FOREACH(s_info.client_list, l, client) {
-               if (!client_is_subscribed(client, cluster, category))
+               if (!client_is_subscribed(client, cluster, category)) {
                        continue;
+               }
 
-               if (cb(client, data) < 0)
+               if (cb(client, data) < 0) {
                        return LB_STATUS_ERROR_CANCEL;
+               }
 
                cnt++;
        }
index 6276b99..78ebd9b 100644 (file)
@@ -92,8 +92,9 @@ static inline struct command *pop_command(void)
        struct command *command;
 
        command = eina_list_nth(s_info.command_list, 0);
-       if (!command)
+       if (!command) {
                return NULL;
+       }
 
        s_info.command_list = eina_list_remove(s_info.command_list, command);
        return command;
@@ -133,8 +134,9 @@ static Eina_Bool command_consumer_cb(void *data)
        }
 
        ret = com_core_packet_send_only(rpc->handle, command->packet);
-       if (ret < 0)
+       if (ret < 0) {
                ErrPrint("Failed to send packet %d\n", ret);
+       }
 
 out:
        destroy_command(command);
@@ -145,8 +147,9 @@ static inline void push_command(struct command *command)
 {
        s_info.command_list = eina_list_append(s_info.command_list, command);
 
-       if (s_info.command_consumer)
+       if (s_info.command_consumer) {
                return;
+       }
 
        s_info.command_consumer = ecore_timer_add(PACKET_TIME, command_consumer_cb, NULL);
        if (!s_info.command_consumer) {
@@ -161,8 +164,9 @@ HAPI int client_rpc_async_request(struct client_node *client, struct packet *pac
        struct command *command;
        struct client_rpc *rpc;
 
-       if (!client || !packet)
+       if (!client || !packet) {
                return LB_STATUS_ERROR_INVALID;
+       }
 
        if (client_is_faulted(client)) {
                ErrPrint("Client[%p] is faulted\n", client);
@@ -171,8 +175,9 @@ HAPI int client_rpc_async_request(struct client_node *client, struct packet *pac
        }
 
        rpc = client_data(client, RPC_TAG);
-       if (!rpc)
+       if (!rpc) {
                ErrPrint("Client[%p] is not ready for communication (%s)\n", client, packet_command(packet));
+       }
 
        command = create_command(client, packet);
        if (!command) {
@@ -243,8 +248,9 @@ HAPI int client_rpc_fini(struct client_node *client)
        struct client_rpc *rpc;
 
        rpc = client_del_data(client, RPC_TAG);
-       if (!rpc)
+       if (!rpc) {
                return LB_STATUS_ERROR_INVALID;
+       }
 
        client_event_callback_del(client, CLIENT_EVENT_DEACTIVATE, deactivated_cb, NULL);
        DbgFree(rpc);
index e86b3f9..d01eda6 100644 (file)
@@ -112,8 +112,9 @@ static void use_sw_backend_handler(char *buffer)
 static void provider_method_handler(char *buffer)
 {
        g_conf.provider_method = strdup(buffer);
-       if (!g_conf.provider_method)
+       if (!g_conf.provider_method) {
                ErrPrint("Heap: %s\n", strerror(errno));
+       }
 }
 
 static void debug_mode_handler(char *buffer)
@@ -133,196 +134,225 @@ static void com_core_thread_handler(char *buffer)
 
 static void base_width_handler(char *buffer)
 {
-       if (sscanf(buffer, "%d", &g_conf.base_width) != 1)
+       if (sscanf(buffer, "%d", &g_conf.base_width) != 1) {
                ErrPrint("Failed to parse the base_width\n");
+       }
 }
 
 static void base_height_handler(char *buffer)
 {
-       if (sscanf(buffer, "%d", &g_conf.base_height) != 1)
+       if (sscanf(buffer, "%d", &g_conf.base_height) != 1) {
                ErrPrint("Failed to parse the base_height\n");
+       }
 }
 
 static void minimum_period_handler(char *buffer)
 {
-       if (sscanf(buffer, "%lf", &g_conf.minimum_period) != 1)
+       if (sscanf(buffer, "%lf", &g_conf.minimum_period) != 1) {
                ErrPrint("Failed to parse the minimum_period\n");
+       }
        DbgPrint("Minimum period: %lf\n", g_conf.minimum_period);
 }
 
 static void script_handler(char *buffer)
 {
        g_conf.default_conf.script = strdup(buffer);
-       if (!g_conf.default_conf.script)
+       if (!g_conf.default_conf.script) {
                ErrPrint("Heap: %s\n", strerror(errno));
+       }
 }
 
 static void default_abi_handler(char *buffer)
 {
        g_conf.default_conf.abi = strdup(buffer);
-       if (!g_conf.default_conf.abi)
+       if (!g_conf.default_conf.abi) {
                ErrPrint("Heap: %s\n", strerror(errno));
+       }
 }
 
 static void default_group_handler(char *buffer)
 {
        g_conf.default_conf.pd_group = strdup(buffer);
-       if (!g_conf.default_conf.pd_group)
+       if (!g_conf.default_conf.pd_group) {
                ErrPrint("Heap: %s\n", strerror(errno));
+       }
 }
 
 static void default_period_handler(char *buffer)
 {
-       if (sscanf(buffer, "%lf", &g_conf.default_conf.period) != 1)
+       if (sscanf(buffer, "%lf", &g_conf.default_conf.period) != 1) {
                ErrPrint("Failed to parse the default_period\n");
+       }
        DbgPrint("Default Period: %lf\n", g_conf.default_conf.period);
 }
 
 static void default_packet_time_handler(char *buffer)
 {
-       if (sscanf(buffer, "%lf", &g_conf.default_packet_time) != 1)
+       if (sscanf(buffer, "%lf", &g_conf.default_packet_time) != 1) {
                ErrPrint("Failed to parse the default_packet_time\n");
+       }
        DbgPrint("Default packet time: %lf\n", g_conf.default_packet_time);
 }
 
 static void default_content_handler(char *buffer)
 {
        g_conf.default_content = strdup(buffer);
-       if (!g_conf.default_content)
+       if (!g_conf.default_content) {
                ErrPrint("Heap: %s\n", strerror(errno));
+       }
 }
 
 static void default_title_handler(char *buffer)
 {
        g_conf.default_title = strdup(buffer);
-       if (!g_conf.default_title)
+       if (!g_conf.default_title) {
                ErrPrint("Heap: %s\n", strerror(errno));
+       }
 }
 
 static void minimum_space_handler(char *buffer)
 {
-       if (sscanf(buffer, "%lu", &g_conf.minimum_space) != 1)
+       if (sscanf(buffer, "%lu", &g_conf.minimum_space) != 1) {
                ErrPrint("Failed to parse the minimum_space\n");
+       }
 }
 
 static void replace_tag_handler(char *buffer)
 {
        g_conf.replace_tag = strdup(buffer);
-       if (!g_conf.replace_tag)
+       if (!g_conf.replace_tag) {
                ErrPrint("Heap: %s\n", strerror(errno));
+       }
 }
 
 static void slave_ttl_handler(char *buffer)
 {
-       if (sscanf(buffer, "%lf", &g_conf.slave_ttl) != 1)
+       if (sscanf(buffer, "%lf", &g_conf.slave_ttl) != 1) {
                ErrPrint("Failed to parse the slave_ttl\n");
+       }
        DbgPrint("Slave TTL: %lf\n", g_conf.slave_ttl);
 }
 
 static void slave_activate_time_handler(char *buffer)
 {
-       if (sscanf(buffer, "%lf", &g_conf.slave_activate_time) != 1)
+       if (sscanf(buffer, "%lf", &g_conf.slave_activate_time) != 1) {
                ErrPrint("Failed to parse the slave_activate_time\n");
+       }
        DbgPrint("Slave activate time: %lf\n", g_conf.slave_activate_time);
 }
 
 static void slave_relaunch_time_handler(char *buffer)
 {
-       if (sscanf(buffer, "%lf", &g_conf.slave_relaunch_time) != 1)
+       if (sscanf(buffer, "%lf", &g_conf.slave_relaunch_time) != 1) {
                ErrPrint("Failed to parse the slave_activate_time\n");
+       }
        DbgPrint("Slave relaunch time: %lf\n", g_conf.slave_relaunch_time);
 }
 
 static void slave_relaunch_count_handler(char *buffer)
 {
-       if (sscanf(buffer, "%d", &g_conf.slave_relaunch_count) != 1)
+       if (sscanf(buffer, "%d", &g_conf.slave_relaunch_count) != 1) {
                ErrPrint("Failed to parse the max_log_line\n");
+       }
 }
 
 static void max_log_line_handler(char *buffer)
 {
-       if (sscanf(buffer, "%d", &g_conf.max_log_line) != 1)
+       if (sscanf(buffer, "%d", &g_conf.max_log_line) != 1) {
                ErrPrint("Failed to parse the max_log_line\n");
+       }
 }
 
 static void max_log_file_handler(char *buffer)
 {
-       if (sscanf(buffer, "%d", &g_conf.max_log_file) != 1)
+       if (sscanf(buffer, "%d", &g_conf.max_log_file) != 1) {
                ErrPrint("Failed to parse the max_log_file\n");
+       }
 }
 
 static void sqlite_flush_max_handler(char *buffer)
 {
-       if (sscanf(buffer, "%lu", &g_conf.sqlite_flush_max) != 1)
+       if (sscanf(buffer, "%lu", &g_conf.sqlite_flush_max) != 1) {
                ErrPrint("Failed to parse the sqlite_flush_max\n");
+       }
 }
 
 static void db_path_handler(char *buffer)
 {
        g_conf.path.db = strdup(buffer);
-       if (!g_conf.path.db)
+       if (!g_conf.path.db) {
                ErrPrint("Heap: %s\n", strerror(errno));
+       }
 }
 
 static void reader_path_handler(char *buffer)
 {
        g_conf.path.reader = strdup(buffer);
-       if (!g_conf.path.reader)
+       if (!g_conf.path.reader) {
                ErrPrint("Heap: %s\n", strerror(errno));
+       }
 }
 
 static void always_path_handler(char *buffer)
 {
        g_conf.path.always = strdup(buffer);
-       if (!g_conf.path.always)
+       if (!g_conf.path.always) {
                ErrPrint("Heap: %s\n", strerror(errno));
+       }
 }
 
 static void log_path_handler(char *buffer)
 {
        g_conf.path.slave_log = strdup(buffer);
-       if (!g_conf.path.slave_log)
+       if (!g_conf.path.slave_log) {
                ErrPrint("Heap: %s\n", strerror(errno));
+       }
 }
 
 static void script_port_path_handler(char *buffer)
 {
        g_conf.path.script_port = strdup(buffer);
-       if (!g_conf.path.script_port)
+       if (!g_conf.path.script_port) {
                ErrPrint("Heap: %s\n", strerror(errno));
+       }
 }
 
 static void share_path_handler(char *buffer)
 {
        g_conf.path.image = strdup(buffer);
-       if (!g_conf.path.image)
+       if (!g_conf.path.image) {
                ErrPrint("Heap: %s\n", strerror(errno));
+       }
 }
 
 static void input_path_handler(char *buffer)
 {
        g_conf.path.input = strdup(buffer);
-       if (!g_conf.path.input)
+       if (!g_conf.path.input) {
                ErrPrint("Heap: %s\n", strerror(errno));
+       }
 }
 
 static void ping_time_handler(char *buffer)
 {
-       if (sscanf(buffer, "%lf", &g_conf.ping_time) != 1)
+       if (sscanf(buffer, "%lf", &g_conf.ping_time) != 1) {
                ErrPrint("Failed to parse the ping_time\n");
+       }
        DbgPrint("Default ping time: %lf\n", g_conf.ping_time);
 }
 
 static void slave_max_loader(char *buffer)
 {
-       if (sscanf(buffer, "%d", &g_conf.slave_max_load) != 1)
+       if (sscanf(buffer, "%d", &g_conf.slave_max_load) != 1) {
                ErrPrint("Failed to parse the slave_max_load\n");
+       }
 }
 
 static void pd_request_timeout_handler(char *buffer)
 {
-       if (sscanf(buffer, "%lf", &g_conf.pd_request_timeout) != 1)
+       if (sscanf(buffer, "%lf", &g_conf.pd_request_timeout) != 1) {
                ErrPrint("Failed to parse the request_timeout\n");
+       }
        DbgPrint("Default PD request timeout: %lf\n", g_conf.pd_request_timeout);
 }
 
@@ -546,10 +576,11 @@ HAPI int conf_loader(void)
                        }
                        break;
                case SPACE:
-                       if (c == '=')
+                       if (c == '=') {
                                state = VALUE;
-                       else if (!isspace(c))
+                       } else if (!isspace(c)) {
                                state = ERROR;
+                       }
                        break;
                case VALUE:
                        if (c == '"') {
@@ -558,8 +589,9 @@ HAPI int conf_loader(void)
                                        state = END;
                                } else if (buffer_idx != 0) {
                                        buffer[buffer_idx++] = c;
-                                       if (buffer_idx >= sizeof(buffer))
+                                       if (buffer_idx >= sizeof(buffer)) {
                                                state = ERROR;
+                                       }
                                } else {
                                        quote = 1;
                                }
@@ -568,8 +600,9 @@ HAPI int conf_loader(void)
                                        /* Ignore */
                                } else if (quote == 1) {
                                        buffer[buffer_idx++] = c;
-                                       if (buffer_idx >= sizeof(buffer))
+                                       if (buffer_idx >= sizeof(buffer)) {
                                                state = ERROR;
+                                       }
                                } else {
                                        buffer[buffer_idx] = '\0';
                                        ungetc(c, fp);
@@ -577,24 +610,28 @@ HAPI int conf_loader(void)
                                }
                        } else {
                                buffer[buffer_idx++] = c;
-                               if (buffer_idx >= sizeof(buffer))
+                               if (buffer_idx >= sizeof(buffer)) {
                                        state = ERROR;
+                               }
                        }
                        break;
                case TOKEN:
                        if (c == '=') {
-                               if (token_idx < 0)
+                               if (token_idx < 0) {
                                        state = ERROR;
-                               else
+                               } else {
                                        state = VALUE;
+                               }
                        } else if (isspace(c)) {
-                               if (token_idx < 0)
+                               if (token_idx < 0) {
                                        break;
+                               }
 
-                               if (token_handler[token_idx].name[ch_idx] != '\0')
+                               if (token_handler[token_idx].name[ch_idx] != '\0') {
                                        state = ERROR;
-                               else
+                               } else {
                                        state = SPACE;
+                               }
                        } else  {
                                if (token_idx < 0) {
                                        /* Now start to find a token! */
@@ -610,10 +647,11 @@ HAPI int conf_loader(void)
 
                                        token_idx++;
 
-                                       if (token_handler[token_idx].name == NULL)
+                                       if (token_handler[token_idx].name == NULL) {
                                                state = ERROR;
-                                       else
+                                       } else {
                                                ch_idx = 0;
+                                       }
                                }
                        }
                        break;
@@ -656,8 +694,9 @@ HAPI int conf_loader(void)
                linelen++;
         } while (c != EOF);
 
-       if (fclose(fp) != 0)
+       if (fclose(fp) != 0) {
                ErrPrint("fclose: %s\n", strerror(errno));
+       }
        return LB_STATUS_SUCCESS;
 }
 
index 9d3eb39..3c880e3 100644 (file)
@@ -55,8 +55,9 @@ static inline void rotate_log(void)
        char *filename;
        int namelen;
 
-       if (s_info.nr_of_lines < MAX_LOG_LINE)
+       if (s_info.nr_of_lines < MAX_LOG_LINE) {
                return;
+       }
 
        s_info.file_id = (s_info.file_id + 1) % MAX_LOG_FILE;
 
@@ -66,13 +67,15 @@ static inline void rotate_log(void)
                snprintf(filename, namelen, "%s/%d_%s.%d", SLAVE_LOG_PATH, s_info.file_id, s_info.filename, getpid());
 
                if (s_info.fp) {
-                       if (fclose(s_info.fp) != 0)
+                       if (fclose(s_info.fp) != 0) {
                                ErrPrint("fclose: %s\n", strerror(errno));
+                       }
                }
 
                s_info.fp = fopen(filename, "w+");
-               if (!s_info.fp)
+               if (!s_info.fp) {
                        ErrPrint("Failed to open a file: %s\n", filename);
+               }
 
                DbgFree(filename);
        }
@@ -87,8 +90,9 @@ HAPI int critical_log(const char *func, int line, const char *fmt, ...)
        va_list ap;
        int ret;
 
-       if (!s_info.fp)
+       if (!s_info.fp) {
                return LB_STATUS_ERROR_IO;
+       }
 
        CRITICAL_SECTION_BEGIN(&s_info.cri_lock);
 
@@ -114,8 +118,9 @@ HAPI int critical_log_init(const char *name)
        int namelen;
        char *filename;
 
-       if (s_info.fp)
+       if (s_info.fp) {
                return LB_STATUS_SUCCESS;
+       }
 
        s_info.filename = strdup(name);
        if (!s_info.filename) {
@@ -158,8 +163,9 @@ HAPI void critical_log_fini(void)
        }
 
        if (s_info.fp) {
-               if (fclose(s_info.fp) != 0)
+               if (fclose(s_info.fp) != 0) {
                        ErrPrint("fclose: %s\n", strerror(errno));
+               }
                s_info.fp = NULL;
        }
 }
index adea7d3..9769996 100644 (file)
@@ -42,22 +42,30 @@ static int evt_cb(int handle, void *data)
        slave = slave_find_by_rpc_handle(handle);
        if (slave) {
                if (slave_pid(slave) != (pid_t)-1) {
-                       if (slave_state(slave) == SLAVE_REQUEST_TO_TERMINATE)
+                       if (slave_state(slave) == SLAVE_REQUEST_TO_TERMINATE) {
                                slave = slave_deactivated(slave);
-                       else if (slave_state(slave) != SLAVE_TERMINATED)
+                       } else if (slave_state(slave) != SLAVE_TERMINATED) {
                                slave = slave_deactivated_by_fault(slave);
+                       }
+               }
+
+               if (!slave) {
+                       DbgPrint("Slave is deleted\n");
                }
 
-               DbgPrint("Slave pointer: %p (0 means deleted)\n", slave);
                return 0;
        }
 
        client = client_find_by_rpc_handle(handle);
        if (client) {
-               if (client_pid(client) != (pid_t)-1)
+               if (client_pid(client) != (pid_t)-1) {
                        client = client_deactivated_by_fault(client);
+               }
+
+               if (!client) {
+                       DbgPrint("Client is deleted\n");
+               }
 
-               DbgPrint("Client pointer: %p (0 means deleted)\n", client);
                return 0;
        }
 
index fee98b4..19d19a7 100644 (file)
@@ -89,8 +89,9 @@ HAPI int event_fini(void)
 {
        int ret;
        ret = pthread_mutex_destroy(&s_info.event_list_lock);
-       if (ret != 0)
+       if (ret != 0) {
                ErrPrint("Mutex destroy failed: %s\n", strerror(ret));
+       }
        return LB_STATUS_SUCCESS;
 }
 
@@ -251,8 +252,9 @@ static void *event_thread_main(void *data)
                if (FD_ISSET(s_info.tcb_pipe[PIPE_READ], &set)) {
                        char event_ch;
 
-                       if (read(s_info.tcb_pipe[PIPE_READ], &event_ch, sizeof(event_ch)) != sizeof(event_ch))
+                       if (read(s_info.tcb_pipe[PIPE_READ], &event_ch, sizeof(event_ch)) != sizeof(event_ch)) {
                                ErrPrint("Unable to read TCB_PIPE: %s\n", strerror(errno));
+                       }
 
                        ret = LB_STATUS_ERROR_CANCEL;
                        break;
@@ -281,10 +283,11 @@ static Eina_Bool event_read_cb(void *data, Ecore_Fd_Handler *handler)
 
        CRITICAL_SECTION_BEGIN(&s_info.event_list_lock);
        item = eina_list_nth(s_info.event_list, 0);
-       if (item)
+       if (item) {
                s_info.event_list = eina_list_remove(s_info.event_list, item);
-       else
+       } else {
                ErrPrint("Unable to get event\n");
+       }
        CRITICAL_SECTION_END(&s_info.event_list_lock);
 
        if (item && s_info.event_cb) {
@@ -324,17 +327,20 @@ HAPI int event_activate(int x, int y, int (*event_cb)(enum event_state state, st
                return LB_STATUS_ERROR_IO;
        }
 
-       if (fcntl(s_info.handle, F_SETFD, FD_CLOEXEC) < 0)
+       if (fcntl(s_info.handle, F_SETFD, FD_CLOEXEC) < 0) {
                ErrPrint("Error: %s\n", strerror(errno));
+       }
 
-       if (fcntl(s_info.handle, F_SETFL, O_NONBLOCK) < 0)
+       if (fcntl(s_info.handle, F_SETFL, O_NONBLOCK) < 0) {
                ErrPrint("Error: %s\n", strerror(errno));
+       }
 
        status = pipe2(s_info.evt_pipe, O_NONBLOCK | O_CLOEXEC);
        if (status < 0) {
                ErrPrint("Unable to prepare evt pipe: %s\n", strerror(errno));
-               if (close(s_info.handle) < 0)
+               if (close(s_info.handle) < 0) {
                        ErrPrint("Failed to close handle: %s\n", strerror(errno));
+               }
                s_info.handle = -1;
                return LB_STATUS_ERROR_FAULT;
        }
@@ -342,8 +348,9 @@ HAPI int event_activate(int x, int y, int (*event_cb)(enum event_state state, st
        status = pipe2(s_info.tcb_pipe, O_NONBLOCK | O_CLOEXEC);
        if (status < 0) {
                ErrPrint("Unable to prepare tcb pipe: %s\n", strerror(errno));
-               if (close(s_info.handle) < 0)
+               if (close(s_info.handle) < 0) {
                        ErrPrint("Failed to close handle: %s\n", strerror(errno));
+               }
                s_info.handle = -1;
                CLOSE_PIPE(s_info.evt_pipe);
                return LB_STATUS_ERROR_FAULT;
@@ -351,8 +358,9 @@ HAPI int event_activate(int x, int y, int (*event_cb)(enum event_state state, st
 
        s_info.event_handler = ecore_main_fd_handler_add(s_info.evt_pipe[PIPE_READ], ECORE_FD_READ, event_read_cb, NULL, NULL, NULL);
        if (!s_info.event_handler) {
-               if (close(s_info.handle) < 0)
+               if (close(s_info.handle) < 0) {
                        ErrPrint("Failed to close handle: %s\n", strerror(errno));
+               }
                s_info.handle = -1;
 
                CLOSE_PIPE(s_info.tcb_pipe);
@@ -366,8 +374,9 @@ HAPI int event_activate(int x, int y, int (*event_cb)(enum event_state state, st
                ecore_main_fd_handler_del(s_info.event_handler);
                s_info.event_handler = NULL;
 
-               if (close(s_info.handle) < 0)
+               if (close(s_info.handle) < 0) {
                        ErrPrint("close: %s\n", strerror(errno));
+               }
                s_info.handle = -1;
 
                CLOSE_PIPE(s_info.tcb_pipe);
@@ -396,20 +405,23 @@ HAPI int event_deactivate(void)
                return LB_STATUS_SUCCESS;
        }
 
-       if (write(s_info.tcb_pipe[PIPE_WRITE], &event_ch, sizeof(event_ch)) != sizeof(event_ch))
+       if (write(s_info.tcb_pipe[PIPE_WRITE], &event_ch, sizeof(event_ch)) != sizeof(event_ch)) {
                ErrPrint("Unable to write tcb_pipe: %s\n", strerror(errno));
+       }
 
        status = pthread_join(s_info.tid, &ret);
-       if (status != 0)
+       if (status != 0) {
                ErrPrint("Failed to join a thread: %s\n", strerror(errno));
-       else
+       } else {
                DbgPrint("Thread returns: %d\n", (int)ret);
+       }
 
        ecore_main_fd_handler_del(s_info.event_handler);
        s_info.event_handler = NULL;
 
-       if (close(s_info.handle) < 0)
+       if (close(s_info.handle) < 0) {
                ErrPrint("Unable to release the fd: %s\n", strerror(errno));
+       }
 
        s_info.handle = -1;
        DbgPrint("Event handler deactivated\n");
@@ -432,8 +444,9 @@ HAPI int event_deactivate(void)
        if (s_info.event_state != EVENT_STATE_DEACTIVATE) {
                s_info.event_state = EVENT_STATE_DEACTIVATE;
 
-               if (s_info.event_cb)
+               if (s_info.event_cb) {
                        s_info.event_cb(s_info.event_state, &s_info.event_data, s_info.cbdata);
+               }
        }
 
        s_info.event_data.x = -1;
index 7546f95..adf8621 100644 (file)
@@ -60,10 +60,17 @@ HAPI int const fault_is_occured(void)
 static void clear_log_file(struct slave_node *slave)
 {
        char filename[BUFSIZ];
+       int ret;
 
-       snprintf(filename, sizeof(filename), "%s/slave.%d", SLAVE_LOG_PATH, slave_pid(slave));
+       ret = snprintf(filename, sizeof(filename) - 1, "%s/slave.%d", SLAVE_LOG_PATH, slave_pid(slave));
+       if (ret == sizeof(filename) - 1) {
+               filename[sizeof(filename) - 1] = '\0';
+               ErrPrint("filename buffer is overflowed\n");
+       }
 
-       unlink(filename);
+       if (unlink(filename) < 0) {
+               ErrPrint("unlink: %s\n", strerror(errno));
+       }
 }
 
 static char *check_log_file(struct slave_node *slave)
@@ -83,8 +90,10 @@ static char *check_log_file(struct slave_node *slave)
        }
 
        ptr = fgets(pkgname, sizeof(pkgname), fp);
-       if (fclose(fp) != 0)
+       if (fclose(fp) != 0) {
                ErrPrint("fclose: %s\n", strerror(errno));
+       }
+
        if (ptr != pkgname) {
                ErrPrint("Invalid log\n");
                return NULL;
@@ -104,8 +113,9 @@ static char *check_log_file(struct slave_node *slave)
        }
                
        ptr[i] = '\0'; /*!< Truncate tailer ".so" */
-       if (unlink(filename) < 0)
+       if (unlink(filename) < 0) {
                ErrPrint("Failed to unlink %s\n", filename);
+       }
 
        return strdup(ptr);
 }
@@ -114,12 +124,14 @@ HAPI void fault_unicast_info(struct client_node *client, const char *pkgname, co
 {
        struct packet *packet;
 
-       if (!client || !pkgname || !filename || !func)
+       if (!client || !pkgname || !filename || !func) {
                return;
+       }
 
        packet = packet_create_noack("fault_package", "sss", pkgname, filename, func);
-       if (!packet)
+       if (!packet) {
                return;
+       }
 
        client_rpc_async_request(client, packet);
 }
@@ -151,12 +163,14 @@ HAPI int fault_info_set(struct slave_node *slave, const char *pkgname, const cha
        int ret;
 
        pkg = package_find(pkgname);
-       if (!pkg)
+       if (!pkg) {
                return LB_STATUS_ERROR_NOT_EXIST;
+       }
 
        ret = package_set_fault_info(pkg, util_timestamp(), id, func);
-       if (ret < 0)
+       if (ret < 0) {
                return LB_STATUS_ERROR_FAULT;
+       }
 
        dump_fault_info(slave_name(slave), slave_pid(slave), pkgname, id, func);
        ErrPrint("Set fault %s(%d)\n", !ret ? "Success" : "Failed", ret);
@@ -198,8 +212,9 @@ HAPI int fault_check_pkgs(struct slave_node *slave)
                        s_info.fault_mark_count = 0;
                        clear_log_file(slave);
                        EINA_LIST_REVERSE_FOREACH_SAFE(s_info.call_list, l, n, info) {
-                               if (info->slave != slave)
+                               if (info->slave != slave) {
                                        continue;
+                               }
 
                                s_info.call_list = eina_list_remove_list(s_info.call_list, l);
 
@@ -231,8 +246,9 @@ HAPI int fault_check_pkgs(struct slave_node *slave)
                        s_info.fault_mark_count = 0;
                        clear_log_file(slave);
                        EINA_LIST_REVERSE_FOREACH_SAFE(s_info.call_list, l, n, info) {
-                               if (info->slave != slave)
+                               if (info->slave != slave) {
                                        continue;
+                               }
 
                                s_info.call_list = eina_list_remove_list(s_info.call_list, l);
 
@@ -295,8 +311,9 @@ HAPI int fault_func_call(struct slave_node *slave, const char *pkgname, const ch
        struct fault_info *info;
 
        info = malloc(sizeof(*info));
-       if (!info)
+       if (!info) {
                return LB_STATUS_ERROR_MEMORY;
+       }
 
        info->slave = slave;
 
@@ -335,17 +352,21 @@ HAPI int fault_func_ret(struct slave_node *slave, const char *pkgname, const cha
        Eina_List *l;
 
        EINA_LIST_FOREACH(s_info.call_list, l, info) {
-               if (info->slave != slave)
+               if (info->slave != slave) {
                        continue;
+               }
 
-               if (strcmp(info->pkgname, pkgname))
+               if (strcmp(info->pkgname, pkgname)) {
                        continue;
+               }
 
-               if (strcmp(info->filename, filename))
+               if (strcmp(info->filename, filename)) {
                        continue;
+               }
 
-               if (strcmp(info->func, func))
+               if (strcmp(info->func, func)) {
                        continue;
+               }
 
                s_info.call_list = eina_list_remove_list(s_info.call_list, l);
                DbgFree(info->filename);
index d4db09f..65a4048 100644 (file)
--- a/src/fb.c
+++ b/src/fb.c
@@ -68,8 +68,9 @@ static void free_fb(void *data, void *ptr)
                return;
        }
 
-       if (buffer_handler_fb(info->buffer) != ptr)
+       if (buffer_handler_fb(info->buffer) != ptr) {
                ErrPrint("Buffer pointer is not matched\n");
+       }
 
        (void)buffer_handler_unload(info->buffer);
 }
index eabf755..69ea1c4 100644 (file)
@@ -257,8 +257,9 @@ static int service_thread_main(struct tcb *tcb, struct packet *packet, void *dat
                         *
                         * Client & Server must has to keep this communication sequence.
                         */
-                       if (strcmp(cmd, cmd_table[i].cmd))
+                       if (strcmp(cmd, cmd_table[i].cmd)) {
                                continue;
+                       }
 
                        item = NULL;
                        ret = cmd_table[i].request_handler(tcb, packet, &item);
@@ -269,8 +270,9 @@ static int service_thread_main(struct tcb *tcb, struct packet *packet, void *dat
                                break;
                        }
 
-                       if (service_common_unicast_packet(tcb, reply) < 0)
+                       if (service_common_unicast_packet(tcb, reply) < 0) {
                                ErrPrint("Unable to send reply packet\n");
+                       }
 
                        packet_destroy(reply);
 
@@ -278,8 +280,9 @@ static int service_thread_main(struct tcb *tcb, struct packet *packet, void *dat
                         * \note
                         * After send the reply packet, file push thread can sending a file
                         */
-                       if (ret != LB_STATUS_SUCCESS || !item)
+                       if (ret != LB_STATUS_SUCCESS || !item) {
                                break;
+                       }
 
                        CRITICAL_SECTION_BEGIN(&s_info.request_list_lock);
                        s_info.request_list = eina_list_append(s_info.request_list, item);
@@ -382,10 +385,11 @@ static int send_file(int handle, const struct request_item *item)
                ret = com_core_send(handle, (void *)body, sizeof(*body), 2.0f);
                free(body);
 
-               if (ret < 0)
+               if (ret < 0) {
                        ret = -EFAULT;
-               else
+               } else {
                        ret = -EIO;
+               }
 
                goto errout;
        }
@@ -426,14 +430,16 @@ static int send_file(int handle, const struct request_item *item)
        /* Send EOF */
        body->size = -1;
        ret = com_core_send(handle, (void *)body, sizeof(*body), 2.0f);
-       if (ret < 0)
+       if (ret < 0) {
                ret = -EFAULT;
+       }
 
        free(body);
 
 errout:
-       if (close(fd) < 0)
+       if (close(fd) < 0) {
                ErrPrint("close: %s\n", strerror(errno));
+       }
 
        return ret;
 }
@@ -450,14 +456,16 @@ static int send_buffer(int handle, const struct request_item *item)
        int offset;
        int type;
 
-       if (item->type == REQUEST_TYPE_SHM)
+       if (item->type == REQUEST_TYPE_SHM) {
                type = BUFFER_TYPE_SHM;
-       else
+       } else {
                type = BUFFER_TYPE_PIXMAP;
+       }
 
        buffer = buffer_handler_raw_open(type, (void *)item->data.shm);
-       if (!buffer)
+       if (!buffer) {
                return -EINVAL;
+       }
 
        pktsz = sizeof(*head);
 
@@ -490,8 +498,9 @@ static int send_buffer(int handle, const struct request_item *item)
        while (offset < size) {
                body->size = size - offset;
 
-               if (body->size > PKT_CHUNKSZ)
+               if (body->size > PKT_CHUNKSZ) {
                        body->size = PKT_CHUNKSZ;
+               }
 
                memcpy(body->data, data, body->size);
                pktsz = sizeof(*body) + body->size;
@@ -588,10 +597,11 @@ static void *push_main(void *data)
                 * It can be closed any time.
                 * Even though we using it.
                 */
-               if (item->type < REQUEST_TYPE_MAX && item->type >= 0)
+               if (item->type < REQUEST_TYPE_MAX && item->type >= 0) {
                        (void)send_data[item->type](conn_fd, item);
-               else
+               } else {
                        ErrPrint("Invalid type\n");
+               }
 
                destroy_request_item(item);
        }
@@ -626,8 +636,9 @@ int file_service_init(void)
                ErrPrint("Unable to activate service thread\n");
 
                status = pthread_mutex_destroy(&s_info.request_list_lock);
-               if (status != 0)
+               if (status != 0) {
                        ErrPrint("Destroy lock: %s\n", strerror(status));
+               }
 
                CLOSE_PIPE(s_info.request_pipe);
                return LB_STATUS_ERROR_FAULT;
@@ -641,8 +652,9 @@ int file_service_init(void)
                s_info.svc_ctx = NULL;
 
                status = pthread_mutex_destroy(&s_info.request_list_lock);
-               if (status != 0)
+               if (status != 0) {
                        ErrPrint("Destroy lock: %s\n", strerror(status));
+               }
 
                CLOSE_PIPE(s_info.request_pipe);
                return LB_STATUS_ERROR_FAULT;
@@ -665,8 +677,9 @@ int file_service_fini(void)
        char ch;
        void *retval;
 
-       if (!s_info.svc_ctx)
+       if (!s_info.svc_ctx) {
                return LB_STATUS_ERROR_INVALID;
+       }
 
        ch = PUSH_EXIT;
        status = write(s_info.request_pipe[PIPE_WRITE], &ch, sizeof(ch));
@@ -674,13 +687,15 @@ int file_service_fini(void)
                ErrPrint("write: %s\n", strerror(errno));
                /* Forcely terminate the thread */
                status = pthread_cancel(s_info.push_thid);
-               if (status != 0)
+               if (status != 0) {
                        ErrPrint("cancel: %s\n", strerror(status));
+               }
        }
 
        status = pthread_join(s_info.push_thid, &retval);
-       if (status != 0)
+       if (status != 0) {
                ErrPrint("join: %s\n", strerror(status));
+       }
 
        CRITICAL_SECTION_BEGIN(&s_info.request_list_lock);
        EINA_LIST_FREE(s_info.request_list, item) {
@@ -692,8 +707,9 @@ int file_service_fini(void)
        s_info.svc_ctx = NULL;
 
        status = pthread_mutex_destroy(&s_info.request_list_lock);
-       if (status != 0)
+       if (status != 0) {
                ErrPrint("destroy mutex: %s\n", strerror(status));
+       }
 
        CLOSE_PIPE(s_info.request_pipe);
 
index e8650a8..9ec9e69 100644 (file)
@@ -215,8 +215,9 @@ HAPI struct cluster *group_find_cluster(const char *name)
        struct cluster *cluster;
 
        EINA_LIST_FOREACH(s_info.cluster_list, l, cluster) {
-               if (!strcasecmp(cluster->name, name))
+               if (!strcasecmp(cluster->name, name)) {
                        return cluster;
+               }
        }
 
        return NULL;
@@ -296,8 +297,9 @@ HAPI int group_destroy_category(struct category *category)
        struct cluster *cluster;
 
        cluster = category->cluster;
-       if (cluster)
+       if (cluster) {
                cluster->category_list = eina_list_remove(cluster->category_list, category);
+       }
 
        destroy_category(category);
        return LB_STATUS_SUCCESS;
@@ -309,8 +311,9 @@ HAPI struct category *group_find_category(struct cluster *cluster, const char *n
        Eina_List *l;
 
        EINA_LIST_FOREACH(cluster->category_list, l, category) {
-               if (!strcasecmp(category->name, name))
+               if (!strcasecmp(category->name, name)) {
                        return category;
+               }
        }
 
        return NULL;
@@ -376,8 +379,9 @@ HAPI int group_context_item_add_data(struct context_item *item, const char *tag,
        struct context_item_data *tmp;
 
        tmp = malloc(sizeof(*tmp));
-       if (!tmp)
+       if (!tmp) {
                return LB_STATUS_ERROR_MEMORY;
+       }
 
        tmp->tag = strdup(tag);
        if (!tmp->tag) {
@@ -396,8 +400,9 @@ HAPI void *group_context_item_data(struct context_item *item, const char *tag)
        Eina_List *l;
 
        EINA_LIST_FOREACH(item->data_list, l, tmp) {
-               if (!strcmp(tmp->tag, tag))
+               if (!strcmp(tmp->tag, tag)) {
                        return tmp->data;
+               }
        }
 
        return NULL;
@@ -454,8 +459,9 @@ static inline char *get_token(char *ptr, int *len)
 
        _len = *len;
 
-       while (_len > 0 && isspace(ptr[_len]))
+       while (_len > 0 && isspace(ptr[_len])) {
                _len--;
+       }
 
        if (_len == 0) {
                ErrPrint("Token has no string\n");
@@ -518,8 +524,9 @@ HAPI int group_add_livebox(const char *group, const char *pkgname)
                        switch (state) {
                        case CLUSTER:
                                cluster = group_find_cluster(name);
-                               if (!cluster)
+                               if (!cluster) {
                                        cluster = group_create_cluster(name);
+                               }
 
                                if (!cluster) {
                                        ErrPrint("Failed to get cluster\n");
@@ -532,8 +539,9 @@ HAPI int group_add_livebox(const char *group, const char *pkgname)
 
                        case CATEGORY:
                                category = group_find_category(cluster, name);
-                               if (!category)
+                               if (!category) {
                                        category = group_create_category(cluster, name);
+                               }
 
                                if (!category) {
                                        ErrPrint("Failed to get category\n");
@@ -594,8 +602,9 @@ HAPI int group_add_livebox(const char *group, const char *pkgname)
                                        return LB_STATUS_ERROR_FAULT;
                                }
                                cluster = group_find_cluster(name);
-                               if (!cluster)
+                               if (!cluster) {
                                        cluster = group_create_cluster(name);
+                               }
 
                                if (!cluster) {
                                        ErrPrint("Failed to get cluster\n");
@@ -613,8 +622,9 @@ HAPI int group_add_livebox(const char *group, const char *pkgname)
                                        return LB_STATUS_ERROR_FAULT;
                                }
                                category = group_find_category(cluster, name);
-                               if (!category)
+                               if (!category) {
                                        category = group_create_category(cluster, name);
+                               }
 
                                if (!category) {
                                        ErrPrint("Failed to get category\n");
@@ -634,8 +644,9 @@ HAPI int group_add_livebox(const char *group, const char *pkgname)
                        case CONTEXT_ITEM:
                                if (is_open == 1) {
                                        category = group_find_category(cluster, name);
-                                       if (!category)
+                                       if (!category) {
                                                category = group_create_category(cluster, name);
+                                       }
 
                                        if (!category) {
                                                ErrPrint("Failed to get category\n");
@@ -671,8 +682,9 @@ HAPI int group_add_livebox(const char *group, const char *pkgname)
                                        return LB_STATUS_ERROR_FAULT;
                                }
 
-                               if (group_add_option(item, key, name) < 0)
+                               if (group_add_option(item, key, name) < 0) {
                                        ErrPrint("Failed to add a new option: %s - %s\n", key, name);
+                               }
 
                                DbgFree(key);
                                key = NULL;
@@ -727,8 +739,9 @@ HAPI int group_add_livebox(const char *group, const char *pkgname)
                        switch (state) {
                        case CATEGORY:
                                category = group_find_category(cluster, name);
-                               if (!category)
+                               if (!category) {
                                        category = group_create_category(cluster, name);
+                               }
 
                                if (!category) {
                                        ErrPrint("Failed to get category\n");
@@ -748,8 +761,9 @@ HAPI int group_add_livebox(const char *group, const char *pkgname)
                        case CONTEXT_ITEM:
                                if (is_open == 1) {
                                        category = group_find_category(cluster, name);
-                                       if (!category)
+                                       if (!category) {
                                                category = group_create_category(cluster, name);
+                                       }
 
                                        if (!category) {
                                                ErrPrint("Failed to get category\n");
@@ -780,8 +794,9 @@ HAPI int group_add_livebox(const char *group, const char *pkgname)
                                        return LB_STATUS_ERROR_FAULT;
                                }
 
-                               if (group_add_option(item, key, name) < 0)
+                               if (group_add_option(item, key, name) < 0) {
                                        ErrPrint("Failed to add a new option: %s - %s\n", key, name);
+                               }
 
                                DbgFree(key);
                                key = NULL;
@@ -807,8 +822,12 @@ HAPI int group_add_livebox(const char *group, const char *pkgname)
                ptr++;
        }
 
-       if (state != CLUSTER)
+       /* If some cases, the key is not released, try release it, doesn't need to check NULL */
+       DbgFree(key);
+
+       if (state != CLUSTER) {
                return LB_STATUS_ERROR_INVALID;
+       }
 
        return LB_STATUS_SUCCESS;
 }
@@ -828,16 +847,19 @@ HAPI int group_del_livebox(const char *pkgname)
        EINA_LIST_FOREACH_SAFE(s_info.cluster_list, l, n, cluster) {
                EINA_LIST_FOREACH_SAFE(cluster->category_list, s_l, s_n, category) {
                        EINA_LIST_FOREACH_SAFE(category->info_list, i_l, i_n, info) {
-                               if (!strcmp(pkgname, info->pkgname))
+                               if (!strcmp(pkgname, info->pkgname)) {
                                        group_destroy_context_info(info);
+                               }
                        }
 
-                       if (!category->info_list)
+                       if (!category->info_list) {
                                group_destroy_category(category);
+                       }
                }
 
-               if (!cluster->category_list)
+               if (!cluster->category_list) {
                        group_destroy_cluster(cluster);
+               }
        }
 
        return LB_STATUS_SUCCESS;
index ab63d8e..567b337 100644 (file)
@@ -170,12 +170,14 @@ static inline void timer_thaw(struct inst_info *inst)
        delay = util_time_delay_for_compensation(period) - pending;
        ecore_timer_delay(inst->update_timer, delay);
 
-       if (inst->sleep_at == 0.0f)
+       if (inst->sleep_at == 0.0f) {
                return;
+       }
 
        sleep_time = util_timestamp() - inst->sleep_at;
-       if (sleep_time > pending)
+       if (sleep_time > pending) {
                (void)update_timer_cb(inst);
+       }
 
        inst->sleep_at = 0.0f;
 }
@@ -185,8 +187,9 @@ static inline void timer_freeze(struct inst_info *inst)
        struct timeval tv;
        ecore_timer_freeze(inst->update_timer);
 
-       if (ecore_timer_interval_get(inst->update_timer) <= 1.0f)
+       if (ecore_timer_interval_get(inst->update_timer) <= 1.0f) {
                return;
+       }
 
        if (gettimeofday(&tv, NULL) < 0) {
                ErrPrint("gettimeofday: %s\n", strerror(errno));
@@ -282,10 +285,11 @@ static inline void instance_send_update_mode_event(struct inst_info *inst, int a
        pkgname = package_name(inst->info);
 
        packet = packet_create_noack("update_mode", "ssii", pkgname, inst->id, status, active_mode);
-       if (packet)
+       if (packet) {
                CLIENT_SEND_EVENT(inst, packet);
-       else
+       } else {
                ErrPrint("Failed to send update mode event\n");
+       }
 }
 
 static inline void instance_send_resized_event(struct inst_info *inst, int is_pd, int w, int h, int status)
@@ -303,18 +307,20 @@ static inline void instance_send_resized_event(struct inst_info *inst, int is_pd
        pkgname = package_name(inst->info);
 
        lb_type = package_lb_type(inst->info);
-       if (lb_type == LB_TYPE_SCRIPT)
+       if (lb_type == LB_TYPE_SCRIPT) {
                id = fb_id(script_handler_fb(inst->lb.canvas.script));
-       else if (lb_type == LB_TYPE_BUFFER)
+       } else if (lb_type == LB_TYPE_BUFFER) {
                id = buffer_handler_id(inst->lb.canvas.buffer);
-       else
+       } else {
                id = "";
+       }
 
        packet = packet_create_noack("size_changed", "sssiiii", pkgname, inst->id, id, is_pd, w, h, status);
-       if (packet)
+       if (packet) {
                CLIENT_SEND_EVENT(inst, packet);
-       else
+       } else {
                ErrPrint("Failed to send size changed event\n");
+       }
 }
 
 static void update_mode_cb(struct slave_node *slave, const struct packet *packet, void *data)
@@ -338,8 +344,9 @@ static void update_mode_cb(struct slave_node *slave, const struct packet *packet
                return;
        }
 
-       if (ret == LB_STATUS_SUCCESS)
+       if (ret == LB_STATUS_SUCCESS) {
                cbdata->inst->active_update = cbdata->active_update;
+       }
 
        instance_send_update_mode_event(cbdata->inst, cbdata->active_update, ret);
 
@@ -357,26 +364,29 @@ HAPI int instance_unicast_created_event(struct inst_info *inst, struct client_no
 
        if (!client) {
                client = inst->client;
-               if (!client)
+               if (!client) {
                        return LB_STATUS_SUCCESS;
+               }
        }
 
        lb_type = package_lb_type(inst->info);
        pd_type = package_pd_type(inst->info);
 
-       if (lb_type == LB_TYPE_SCRIPT)
+       if (lb_type == LB_TYPE_SCRIPT) {
                lb_file = fb_id(script_handler_fb(inst->lb.canvas.script));
-       else if (lb_type == LB_TYPE_BUFFER)
+       } else if (lb_type == LB_TYPE_BUFFER) {
                lb_file = buffer_handler_id(inst->lb.canvas.buffer);
-       else
+       } else {
                lb_file = "";
+       }
 
-       if (pd_type == PD_TYPE_SCRIPT)
+       if (pd_type == PD_TYPE_SCRIPT) {
                pd_file = fb_id(script_handler_fb(inst->pd.canvas.script));
-       else if (pd_type == PD_TYPE_BUFFER)
+       } else if (pd_type == PD_TYPE_BUFFER) {
                pd_file = buffer_handler_id(inst->pd.canvas.buffer);
-       else
+       } else {
                pd_file = "";
+       }
 
        packet = packet_create_noack("created", "dsssiiiisssssdiiiiidsi",
                        inst->timestamp,
@@ -405,8 +415,9 @@ static int update_client_list(struct client_node *client, void *data)
 {
        struct inst_info *inst = data;
 
-       if (!instance_has_client(inst, client))
+       if (!instance_has_client(inst, client)) {
                instance_add_client(inst, client);
+       }
 
        return LB_STATUS_SUCCESS;
 }
@@ -422,22 +433,25 @@ static int instance_broadcast_created_event(struct inst_info *inst)
        lb_type = package_lb_type(inst->info);
        pd_type = package_pd_type(inst->info);
 
-       if (lb_type == LB_TYPE_SCRIPT)
+       if (lb_type == LB_TYPE_SCRIPT) {
                lb_file = fb_id(script_handler_fb(inst->lb.canvas.script));
-       else if (lb_type == LB_TYPE_BUFFER)
+       } else if (lb_type == LB_TYPE_BUFFER) {
                lb_file = buffer_handler_id(inst->lb.canvas.buffer);
-       else
+       } else {
                lb_file = "";
+       }
 
-       if (pd_type == PD_TYPE_SCRIPT)
+       if (pd_type == PD_TYPE_SCRIPT) {
                pd_file = fb_id(script_handler_fb(inst->pd.canvas.script));
-       else if (pd_type == PD_TYPE_BUFFER)
+       } else if (pd_type == PD_TYPE_BUFFER) {
                pd_file = buffer_handler_id(inst->pd.canvas.buffer);
-       else
+       } else {
                pd_file = "";
+       }
 
-       if (!inst->client)
+       if (!inst->client) {
                client_browse_list(inst->cluster, inst->category, update_client_list, inst);
+       }
 
        packet = packet_create_noack("created", "dsssiiiisssssdiiiiidsi", 
                        inst->timestamp,
@@ -468,8 +482,9 @@ HAPI int instance_unicast_deleted_event(struct inst_info *inst, struct client_no
 
        if (!client) {
                client = inst->client;
-               if (!client)
+               if (!client) {
                        return LB_STATUS_ERROR_INVALID;
+               }
        }
 
        packet = packet_create_noack("deleted", "ssd", package_name(inst->info), inst->id, inst->timestamp);
@@ -544,8 +559,9 @@ HAPI int instance_event_callback_add(struct inst_info *inst, enum instance_event
 {
        struct event_item *item;
 
-       if (!event_cb)
+       if (!event_cb) {
                return LB_STATUS_ERROR_INVALID;
+       }
 
        switch (type) {
        case INSTANCE_EVENT_DESTROY:
@@ -609,8 +625,9 @@ static inline void destroy_instance(struct inst_info *inst)
 
        DbgPrint("Instance is destroyed (%p), slave(%p)\n", inst, slave);
 
-       if (inst->pd.need_to_send_close_event)
+       if (inst->pd.need_to_send_close_event) {
                send_pd_destroyed_to_client(inst, 0);
+       }
 
        if (lb_type == LB_TYPE_SCRIPT) {
                script_handler_unload(inst->lb.canvas.script, 0);
@@ -633,8 +650,9 @@ static inline void destroy_instance(struct inst_info *inst)
                client_unref(inst->client);
        }
 
-       if (inst->update_timer)
+       if (inst->update_timer) {
                ecore_timer_del(inst->update_timer);
+       }
 
        EINA_LIST_FREE(inst->data_list, tag_item) {
                DbgPrint("Tagged item[%s] %p\n", tag_item->tag, tag_item->data);
@@ -704,10 +722,11 @@ static inline int fork_package(struct inst_info *inst, const char *pkgname)
        if (package_secured(info)) {
                if (inst->lb.period > 0.0f) {
                        inst->update_timer = util_timer_add(inst->lb.period, update_timer_cb, inst);
-                       if (!inst->update_timer)
+                       if (!inst->update_timer) {
                                ErrPrint("Failed to add an update timer for instance %s\n", inst->id);
-                       else
+                       } else {
                                timer_freeze(inst); /* Freeze the update timer as default */
+                       }
                } else {
                        inst->update_timer = NULL;
                }
@@ -803,8 +822,9 @@ HAPI struct inst_info *instance_create(struct client_node *client, double timest
 
 HAPI struct inst_info *instance_ref(struct inst_info *inst)
 {
-       if (!inst)
+       if (!inst) {
                return NULL;
+       }
 
        inst->refcnt++;
        return inst;
@@ -812,8 +832,9 @@ HAPI struct inst_info *instance_ref(struct inst_info *inst)
 
 HAPI struct inst_info *instance_unref(struct inst_info *inst)
 {
-       if (!inst)
+       if (!inst) {
                return NULL;
+       }
 
        if (inst->refcnt == 0) {
                ErrPrint("Instance refcnt is not valid\n");
@@ -1132,8 +1153,9 @@ static void activate_cb(struct slave_node *slave, const struct packet *packet, v
                        new_inst = instance_create(inst->client, util_timestamp(), package_name(inst->info),
                                                        inst->content, inst->cluster, inst->category,
                                                        inst->lb.period, 0, 0);
-                       if (!new_inst)
+                       if (!new_inst) {
                                ErrPrint("Failed to create a new instance\n");
+                       }
                } else {
                        ErrPrint("Not enough space\n");
                }
@@ -1163,33 +1185,37 @@ static void activate_cb(struct slave_node *slave, const struct packet *packet, v
                         */
                        inst->is_pinned_up = is_pinned_up;
                        if (package_lb_type(inst->info) == LB_TYPE_SCRIPT) {
-                               if (inst->lb.width == 0 && inst->lb.height == 0)
+                               if (inst->lb.width == 0 && inst->lb.height == 0) {
                                        livebox_service_get_size(LB_SIZE_TYPE_1x1, &inst->lb.width, &inst->lb.height);
+                               }
 
                                inst->lb.canvas.script = script_handler_create(inst,
                                                                package_lb_path(inst->info),
                                                                package_lb_group(inst->info),
                                                                inst->lb.width, inst->lb.height);
 
-                               if (!inst->lb.canvas.script)
+                               if (!inst->lb.canvas.script) {
                                        ErrPrint("Failed to create LB\n");
-                               else
+                               } else {
                                        script_handler_load(inst->lb.canvas.script, 0);
+                               }
                        } else if (package_lb_type(inst->info) == LB_TYPE_BUFFER) {
                                instance_create_lb_buffer(inst);
                        }
 
                        if (package_pd_type(inst->info) == PD_TYPE_SCRIPT) {
-                               if (inst->pd.width == 0 && inst->pd.height == 0)
+                               if (inst->pd.width == 0 && inst->pd.height == 0) {
                                        instance_set_pd_size(inst, package_pd_width(inst->info), package_pd_height(inst->info));
+                               }
 
                                inst->pd.canvas.script = script_handler_create(inst,
                                                                package_pd_path(inst->info),
                                                                package_pd_group(inst->info),
                                                                inst->pd.width, inst->pd.height);
 
-                               if (!inst->pd.canvas.script)
+                               if (!inst->pd.canvas.script) {
                                        ErrPrint("Failed to create PD\n");
+                               }
                        } else if (package_pd_type(inst->info) == PD_TYPE_BUFFER) {
                                instance_create_pd_buffer(inst);
                        }
@@ -1214,13 +1240,15 @@ out:
 
 HAPI int instance_create_pd_buffer(struct inst_info *inst)
 {
-       if (inst->pd.width == 0 && inst->pd.height == 0)
+       if (inst->pd.width == 0 && inst->pd.height == 0) {
                instance_set_pd_size(inst, package_pd_width(inst->info), package_pd_height(inst->info));
+       }
 
        if (!inst->pd.canvas.buffer) {
                inst->pd.canvas.buffer = buffer_handler_create(inst, s_info.env_buf_type, inst->pd.width, inst->pd.height, sizeof(int));
-               if (!inst->pd.canvas.buffer)
+               if (!inst->pd.canvas.buffer) {
                        ErrPrint("Failed to create PD Buffer\n");
+               }
        }
 
        return !!inst->pd.canvas.buffer;
@@ -1228,8 +1256,9 @@ HAPI int instance_create_pd_buffer(struct inst_info *inst)
 
 HAPI int instance_create_lb_buffer(struct inst_info *inst)
 {
-       if (inst->lb.width == 0 && inst->lb.height == 0)
+       if (inst->lb.width == 0 && inst->lb.height == 0) {
                livebox_service_get_size(LB_SIZE_TYPE_1x1, &inst->lb.width, &inst->lb.height);
+       }
 
        if (!inst->lb.canvas.buffer) {
                /*!
@@ -1238,8 +1267,9 @@ HAPI int instance_create_lb_buffer(struct inst_info *inst)
                 * In this case, create the buffer from here.
                 */
                inst->lb.canvas.buffer = buffer_handler_create(inst, s_info.env_buf_type, inst->lb.width, inst->lb.height, sizeof(int));
-               if (!inst->lb.canvas.buffer)
+               if (!inst->lb.canvas.buffer) {
                        ErrPrint("Failed to create LB\n");
+               }
        }
 
        return !!inst->lb.canvas.buffer;
@@ -1317,8 +1347,9 @@ static inline void release_resource_for_closing_pd(struct pkg_info *info, struct
 {
        if (!client) {
                client = inst->pd.owner;
-               if (!client)
+               if (!client) {
                        return;
+               }
        }
 
        /*!
@@ -1359,16 +1390,18 @@ HAPI int instance_state_reset(struct inst_info *inst)
                return LB_STATUS_ERROR_INVALID;
        }
 
-       if (inst->state == INST_DESTROYED)
+       if (inst->state == INST_DESTROYED) {
                goto out;
+       }
 
        lb_type = package_lb_type(inst->info);
        pd_type = package_pd_type(inst->info);
 
-       if (lb_type == LB_TYPE_SCRIPT && inst->lb.canvas.script)
+       if (lb_type == LB_TYPE_SCRIPT && inst->lb.canvas.script) {
                script_handler_unload(inst->lb.canvas.script, 0);
-       else if (lb_type == LB_TYPE_BUFFER && inst->lb.canvas.buffer)
+       } else if (lb_type == LB_TYPE_BUFFER && inst->lb.canvas.buffer) {
                buffer_handler_unload(inst->lb.canvas.buffer);
+       }
 
        if (pd_type == PD_TYPE_SCRIPT && inst->pd.canvas.script) {
                inst->pd.is_opened_for_reactivate = script_handler_is_loaded(inst->pd.canvas.script);
@@ -1677,8 +1710,9 @@ HAPI void instance_lb_updated(const char *pkgname, const char *id)
        struct inst_info *inst;
 
        inst = package_find_instance_by_id(pkgname, id);
-       if (!inst)
+       if (!inst) {
                return;
+       }
 
        instance_lb_updated_by_instance(inst);
 }
@@ -1700,22 +1734,25 @@ HAPI void instance_lb_updated_by_instance(struct inst_info *inst)
        }
 
        lb_type = package_lb_type(inst->info);
-       if (lb_type == LB_TYPE_SCRIPT)
+       if (lb_type == LB_TYPE_SCRIPT) {
                id = fb_id(script_handler_fb(inst->lb.canvas.script));
-       else if (lb_type == LB_TYPE_BUFFER)
+       } else if (lb_type == LB_TYPE_BUFFER) {
                id = buffer_handler_id(inst->lb.canvas.buffer);
-       else
+       } else {
                id = "";
+       }
 
-       if (inst->content)
+       if (inst->content) {
                content = inst->content;
-       else
+       } else {
                content = "";
+       }
 
-       if (inst->title)
+       if (inst->title) {
                title = inst->title;
-       else
+       } else {
                title = "";
+       }
 
        packet = packet_create_noack("lb_updated", "sssiidss",
                        package_name(inst->info), inst->id, id,
@@ -1733,8 +1770,9 @@ HAPI int instance_hold_scroll(struct inst_info *inst, int hold)
        struct packet *packet;
 
        DbgPrint("HOLD: (%s) %d\n", inst->id, hold);
-       if (inst->scroll_locked == hold)
+       if (inst->scroll_locked == hold) {
                return LB_STATUS_ERROR_ALREADY;
+       }
 
        packet = packet_create_noack("scroll", "ssi", package_name(inst->info), inst->id, hold);
        if (!packet) {
@@ -1766,16 +1804,18 @@ HAPI void instance_pd_updated_by_instance(struct inst_info *inst, const char *de
 
                if (descfile) {
                        inst->pd.pended_update_desc = strdup(descfile);
-                       if (!inst->pd.pended_update_desc)
+                       if (!inst->pd.pended_update_desc) {
                                ErrPrint("Heap: %s\n", strerror(errno));
+                       }
                }
 
                inst->pd.pended_update_cnt++;
                return;
        }
 
-       if (!descfile)
+       if (!descfile) {
                descfile = inst->id;
+       }
 
        switch (package_pd_type(inst->info)) {
        case PD_TYPE_SCRIPT:
@@ -1806,8 +1846,9 @@ HAPI void instance_pd_updated(const char *pkgname, const char *id, const char *d
        struct inst_info *inst;
 
        inst = package_find_instance_by_id(pkgname, id);
-       if (!inst)
+       if (!inst) {
                return;
+       }
 
        instance_pd_updated_by_instance(inst, descfile);
 }
@@ -1860,14 +1901,16 @@ HAPI void instance_set_lb_info(struct inst_info *inst, double priority, const ch
 
        if (content && strlen(content)) {
                _content = strdup(content);
-               if (!_content)
+               if (!_content) {
                        ErrPrint("Heap: %s\n", strerror(errno));
+               }
        }
 
        if (title && strlen(title)) {
                _title = strdup(title);
-               if (!_title)
+               if (!_title) {
                        ErrPrint("Heap: %s\n", strerror(errno));
+               }
        }
 
        if (_content) {
@@ -1880,14 +1923,16 @@ HAPI void instance_set_lb_info(struct inst_info *inst, double priority, const ch
                inst->title = _title;
        }
 
-       if (priority >= 0.0f && priority <= 1.0f)
+       if (priority >= 0.0f && priority <= 1.0f) {
                inst->lb.priority = priority;
+       }
 }
 
 HAPI void instance_set_lb_size(struct inst_info *inst, int w, int h)
 {
-       if (inst->lb.width != w || inst->lb.height != h)
+       if (inst->lb.width != w || inst->lb.height != h) {
                instance_send_resized_event(inst, IS_LB, w, h, LB_STATUS_SUCCESS);
+       }
 
        inst->lb.width = w;
        inst->lb.height = h;
@@ -1895,8 +1940,9 @@ HAPI void instance_set_lb_size(struct inst_info *inst, int w, int h)
 
 HAPI void instance_set_pd_size(struct inst_info *inst, int w, int h)
 {
-       if (inst->pd.width != w || inst->pd.height != h)
+       if (inst->pd.width != w || inst->pd.height != h) {
                instance_send_resized_event(inst, IS_PD, w, h, LB_STATUS_SUCCESS);
+       }
 
        inst->pd.width = w;
        inst->pd.height = h;
@@ -1955,10 +2001,11 @@ out:
         */
        result = packet_create_noack("pinup", "iisss", ret, cbdata->inst->is_pinned_up,
                                                        package_name(cbdata->inst->info), cbdata->inst->id, cbdata->inst->content);
-       if (result)
+       if (result) {
                (void)CLIENT_SEND_EVENT(cbdata->inst, result);
-       else
+       } else {
                ErrPrint("Failed to build a packet for %s\n", package_name(cbdata->inst->info));
+       }
 
        instance_unref(cbdata->inst);
        DbgFree(cbdata);
@@ -1979,15 +2026,18 @@ HAPI int instance_set_pinup(struct inst_info *inst, int pinup)
                return LB_STATUS_ERROR_FAULT;
        }
 
-       if (!package_pinup(inst->info))
+       if (!package_pinup(inst->info)) {
                return LB_STATUS_ERROR_INVALID;
+       }
 
-       if (pinup == inst->is_pinned_up)
+       if (pinup == inst->is_pinned_up) {
                return LB_STATUS_ERROR_INVALID;
+       }
 
        cbdata = malloc(sizeof(*cbdata));
-       if (!cbdata)
+       if (!cbdata) {
                return LB_STATUS_ERROR_MEMORY;
+       }
 
        cbdata->inst = instance_ref(inst);
        cbdata->pinup = pinup;
@@ -2005,8 +2055,9 @@ HAPI int instance_set_pinup(struct inst_info *inst, int pinup)
 
 HAPI int instance_freeze_updator(struct inst_info *inst)
 {
-       if (!inst->update_timer)
+       if (!inst->update_timer) {
                return LB_STATUS_ERROR_INVALID;
+       }
 
        timer_freeze(inst);
        return LB_STATUS_SUCCESS;
@@ -2014,14 +2065,17 @@ HAPI int instance_freeze_updator(struct inst_info *inst)
 
 HAPI int instance_thaw_updator(struct inst_info *inst)
 {
-       if (!inst->update_timer)
+       if (!inst->update_timer) {
                return LB_STATUS_ERROR_INVALID;
+       }
 
-       if (client_is_all_paused() || setting_is_lcd_off())
+       if (client_is_all_paused() || setting_is_lcd_off()) {
                return LB_STATUS_ERROR_INVALID;
+       }
 
-       if (inst->visible == LB_HIDE_WITH_PAUSE)
+       if (inst->visible == LB_HIDE_WITH_PAUSE) {
                return LB_STATUS_ERROR_INVALID;
+       }
 
        timer_thaw(inst);
        return LB_STATUS_SUCCESS;
@@ -2034,15 +2088,17 @@ HAPI enum livebox_visible_state instance_visible_state(struct inst_info *inst)
 
 HAPI int instance_set_visible_state(struct inst_info *inst, enum livebox_visible_state state)
 {
-       if (inst->visible == state)
+       if (inst->visible == state) {
                return LB_STATUS_SUCCESS;
+       }
 
        switch (state) {
        case LB_SHOW:
        case LB_HIDE:
                if (inst->visible == LB_HIDE_WITH_PAUSE) {
-                       if (resume_livebox(inst) == 0)
+                       if (resume_livebox(inst) == 0) {
                                inst->visible = state;
+                       }
 
                        instance_thaw_updator(inst);
                } else {
@@ -2051,8 +2107,9 @@ HAPI int instance_set_visible_state(struct inst_info *inst, enum livebox_visible
                break;
 
        case LB_HIDE_WITH_PAUSE:
-               if (pause_livebox(inst) == 0)
+               if (pause_livebox(inst) == 0) {
                        inst->visible = LB_HIDE_WITH_PAUSE;
+               }
 
                instance_freeze_updator(inst);
                break;
@@ -2188,17 +2245,19 @@ static void set_period_cb(struct slave_node *slave, const struct packet *packet,
                goto out;
        }
 
-       if (ret == 0)
+       if (ret == 0) {
                cbdata->inst->lb.period = cbdata->period;
-       else
+       } else {
                ErrPrint("Failed to set period %d\n", ret);
+       }
 
 out:
        result = packet_create_noack("period_changed", "idss", ret, cbdata->inst->lb.period, package_name(cbdata->inst->info), cbdata->inst->id);
-       if (result)
+       if (result) {
                (void)CLIENT_SEND_EVENT(cbdata->inst, result);
-       else
+       } else {
                ErrPrint("Failed to build a packet for %s\n", package_name(cbdata->inst->info));
+       }
 
        instance_unref(cbdata->inst);
        DbgFree(cbdata);
@@ -2226,17 +2285,19 @@ static Eina_Bool timer_updator_cb(void *data)
                }
        } else if (inst->lb.period > 0.0f) {
                inst->update_timer = util_timer_add(inst->lb.period, update_timer_cb, inst);
-               if (!inst->update_timer)
+               if (!inst->update_timer) {
                        ErrPrint("Failed to add an update timer for instance %s\n", inst->id);
-               else
+               } else {
                        timer_freeze(inst); /* Freeze the update timer as default */
+               }
        }
 
        result = packet_create_noack("period_changed", "idss", 0, inst->lb.period, package_name(inst->info), inst->id);
-       if (result)
+       if (result) {
                (void)CLIENT_SEND_EVENT(inst, result);
-       else
+       } else {
                ErrPrint("Failed to build a packet for %s\n", package_name(inst->info));
+       }
 
        instance_unref(inst);
        return ECORE_CALLBACK_CANCEL;
@@ -2280,8 +2341,9 @@ HAPI int instance_set_period(struct inst_info *inst, double period)
                 *
                 * So update its timer at here.
                 */
-               if (!ecore_timer_add(DELAY_TIME, timer_updator_cb, cbdata))
+               if (!ecore_timer_add(DELAY_TIME, timer_updator_cb, cbdata)) {
                        timer_updator_cb(cbdata);
+               }
                return LB_STATUS_SUCCESS;
        }
 
@@ -2331,20 +2393,23 @@ HAPI int instance_signal_emit(struct inst_info *inst, const char *signal, const
        pkg = instance_package(inst);
        pkgname = package_name(pkg);
        id = instance_id(inst);
-       if (!pkgname || !id)
+       if (!pkgname || !id) {
                return LB_STATUS_ERROR_INVALID;
+       }
 
        slave = package_slave(pkg);
-       if (!slave)
+       if (!slave) {
                return LB_STATUS_ERROR_INVALID;
+       }
 
        packet = packet_create_noack("script", "ssssddddddi",
                        pkgname, id,
                        signal, part,
                        sx, sy, ex, ey,
                        x, y, down);
-       if (!packet)
+       if (!packet) {
                return LB_STATUS_ERROR_FAULT;
+       }
 
        return slave_rpc_request_only(slave, pkgname, packet, 0); 
 }
@@ -2408,10 +2473,11 @@ out:
        result = packet_create_noack("group_changed", "ssiss",
                                package_name(cbdata->inst->info), cbdata->inst->id, ret,
                                cbdata->inst->cluster, cbdata->inst->category);
-       if (!result)
+       if (!result) {
                ErrPrint("Failed to build a packet %s\n", package_name(cbdata->inst->info));
-       else
+       } else {
                (void)CLIENT_SEND_EVENT(cbdata->inst, result);
+       }
 
        instance_unref(cbdata->inst);
        DbgFree(cbdata);
@@ -2774,10 +2840,13 @@ HAPI void instance_slave_set_pd_pos(struct inst_info *inst, double x, double y)
 
 HAPI void instance_slave_get_pd_pos(struct inst_info *inst, double *x, double *y)
 {
-       if (x)
+       if (x) {
                *x = inst->pd.x;
-       if (y)
+       }
+
+       if (y) {
                *y = inst->pd.y;
+       }
 }
 
 HAPI int instance_slave_open_pd(struct inst_info *inst, struct client_node *client)
@@ -2856,12 +2925,14 @@ HAPI int instance_slave_open_pd(struct inst_info *inst, struct client_node *clie
         */
        if (package_pd_type(info) == PD_TYPE_BUFFER) {
                instance_ref(inst);
-               if (client_event_callback_add(client, CLIENT_EVENT_DEACTIVATE, pd_buffer_close_cb, inst) < 0)
+               if (client_event_callback_add(client, CLIENT_EVENT_DEACTIVATE, pd_buffer_close_cb, inst) < 0) {
                        instance_unref(inst);
+               }
        } else if (package_pd_type(info) == PD_TYPE_SCRIPT) {
                instance_ref(inst);
-               if (client_event_callback_add(client, CLIENT_EVENT_DEACTIVATE, pd_script_close_cb, inst) < 0)
+               if (client_event_callback_add(client, CLIENT_EVENT_DEACTIVATE, pd_script_close_cb, inst) < 0) {
                        instance_unref(inst);
+               }
        }
 
        inst->pd.owner = client;
@@ -3018,10 +3089,11 @@ HAPI void *instance_client_list(struct inst_info *inst)
 
 HAPI int instance_init(void)
 {
-       if (!strcasecmp(PROVIDER_METHOD, "shm"))
+       if (!strcasecmp(PROVIDER_METHOD, "shm")) {
                s_info.env_buf_type = BUFFER_TYPE_SHM;
-       else if (!strcasecmp(PROVIDER_METHOD, "pixmap"))
+       } else if (!strcasecmp(PROVIDER_METHOD, "pixmap")) {
                s_info.env_buf_type = BUFFER_TYPE_PIXMAP;
+       }
        /* Default method is BUFFER_TYPE_FILE */
 
        return LB_STATUS_SUCCESS;
@@ -3038,8 +3110,9 @@ static inline struct tag_item *find_tag_item(struct inst_info *inst, const char
        Eina_List *l;
 
        EINA_LIST_FOREACH(inst->data_list, l, item) {
-               if (!strcmp(item->tag, tag))
+               if (!strcmp(item->tag, tag)) {
                        return item;
+               }
        }
 
        return NULL;
@@ -3084,8 +3157,9 @@ HAPI void *instance_del_data(struct inst_info *inst, const char *tag)
        void *data;
 
        item = find_tag_item(inst, tag);
-       if (!item)
+       if (!item) {
                return NULL;
+       }
 
        inst->data_list = eina_list_remove(inst->data_list, item);
        data = item->data;
@@ -3100,8 +3174,9 @@ HAPI void *instance_get_data(struct inst_info *inst, const char *tag)
        struct tag_item *item;
 
        item = find_tag_item(inst, tag);
-       if (!item)
+       if (!item) {
                return NULL;
+       }
 
        return item->data;
 }
index 1d6ee69..456316d 100644 (file)
--- a/src/io.c
+++ b/src/io.c
@@ -74,15 +74,17 @@ static inline int load_abi_table(void)
        char pkgname[MAX_PKGNAME + 1];
 
        fp = fopen("/usr/share/"PACKAGE"/abi.ini", "rt");
-       if (!fp)
+       if (!fp) {
                return LB_STATUS_ERROR_IO;
+       }
 
        state = INIT;
        while ((ch = getc(fp)) != EOF && state != ERROR) {
                switch (state) {
                case INIT:
-                       if (isspace(ch))
+                       if (isspace(ch)) {
                                continue;
+                       }
                        if (ch == '[') {
                                state = GROUP;
                                idx = 0;
@@ -110,8 +112,9 @@ static inline int load_abi_table(void)
                case TAG:
                        if (ptr == NULL) {
                                if (idx == 0) {
-                                       if (isspace(ch))
+                                       if (isspace(ch)) {
                                                continue;
+                                       }
 
                                        /* New group started */
                                        if (ch == '[') {
@@ -153,8 +156,9 @@ static inline int load_abi_table(void)
                        switch (tag_id) {
                        case PKGNAME:
                                if (idx == 0) { /* LTRIM */
-                                       if (isspace(ch))
+                                       if (isspace(ch)) {
                                                continue;
+                                       }
 
                                        pkgname[idx] = ch;
                                        idx++;
@@ -163,8 +167,9 @@ static inline int load_abi_table(void)
                                        pkgname[idx] = '\0';
 
                                        ret = abi_add_entry(group, pkgname);
-                                       if (ret != 0)
+                                       if (ret != 0) {
                                                ErrPrint("Failed to add %s for %s\n", pkgname, group);
+                                       }
 
                                        state = TAG;
                                        idx = 0;
@@ -193,8 +198,9 @@ static inline int load_abi_table(void)
                                int ret;
                                pkgname[idx] = '\0';
                                ret = abi_add_entry(group, pkgname);
-                               if (ret != 0)
+                               if (ret != 0) {
                                        ErrPrint("Failed to add %s for %s\n", pkgname, group);
+                               }
                        }
                        break;
                default:
@@ -202,8 +208,9 @@ static inline int load_abi_table(void)
                }
        }
 
-       if (fclose(fp) != 0)
+       if (fclose(fp) != 0) {
                ErrPrint("fclose: %s\n", strerror(errno));
+       }
        return LB_STATUS_SUCCESS;
 }
 
@@ -302,8 +309,9 @@ static inline int build_provider_info(struct pkg_info *info)
        package_set_secured(info, sqlite3_column_int(stmt, 2));
 
        tmp = (const char *)sqlite3_column_text(stmt, 1);
-       if (tmp && strlen(tmp))
+       if (tmp && strlen(tmp)) {
                package_set_abi(info, tmp);
+       }
 
        package_set_lb_type(info, sqlite3_column_int(stmt, 3));
        tmp = (const char *)sqlite3_column_text(stmt, 4);
@@ -311,8 +319,9 @@ static inline int build_provider_info(struct pkg_info *info)
                package_set_lb_path(info, tmp);
 
                tmp = (const char *)sqlite3_column_text(stmt, 5);
-               if (tmp && strlen(tmp))
+               if (tmp && strlen(tmp)) {
                        package_set_lb_group(info, tmp);
+               }
        }
 
        package_set_pd_type(info, sqlite3_column_int(stmt, 6));
@@ -321,23 +330,28 @@ static inline int build_provider_info(struct pkg_info *info)
                package_set_pd_path(info, tmp);
 
                tmp = (const char *)sqlite3_column_text(stmt, 8);
-               if (tmp && strlen(tmp))
+               if (tmp && strlen(tmp)) {
                        package_set_pd_group(info, tmp);
+               }
        }
 
        tmp = (const char *)sqlite3_column_text(stmt, 9);
-       if (tmp && strlen(tmp))
+       if (tmp && strlen(tmp)) {
                package_set_libexec(info, tmp);
+       }
 
        package_set_timeout(info, sqlite3_column_int(stmt, 10));
 
        tmp = (const char *)sqlite3_column_text(stmt, 11);
-       if (tmp && strlen(tmp))
+       if (tmp && strlen(tmp)) {
                package_set_period(info, atof(tmp));
+       }
 
        tmp = (const char *)sqlite3_column_text(stmt, 12);
-       if (tmp && strlen(tmp))
+       if (tmp && strlen(tmp)) {
                package_set_script(info, tmp);
+       }
+
        package_set_pinup(info, sqlite3_column_int(stmt, 13));
 
        sqlite3_reset(stmt);
@@ -416,8 +430,9 @@ static inline int load_context_option(struct context_item *item, int id)
                }
 
                ret = group_add_option(item, key, value);
-               if (ret < 0)
+               if (ret < 0) {
                        break;
+               }
        }
 
 out:
@@ -462,8 +477,9 @@ static inline int load_context_item(struct context_info *info, int id)
                }
 
                ret = load_context_option(item, option_id);
-               if (ret < 0)
+               if (ret < 0) {
                        break;
+               }
        }
 
 out:
@@ -550,8 +566,9 @@ static inline int build_group_info(struct pkg_info *info)
                                }
                        }
 
-                       if (ctx_info)
+                       if (ctx_info) {
                                package_add_ctx_info(info, ctx_info);
+                       }
                }
        }
 
@@ -637,8 +654,9 @@ HAPI char *io_livebox_pkgname(const char *pkgname)
        tmp = (char *)sqlite3_column_text(stmt, 0);
        if (tmp && strlen(tmp)) {
                pkgid = strdup(tmp);
-               if (!pkgid)
+               if (!pkgid) {
                        ErrPrint("Heap: %s\n", strerror(errno));
+               }
        }
 
 out:
@@ -666,8 +684,9 @@ HAPI int io_crawling_liveboxes(int (*cb)(const char *pkgname, int prime, void *d
 
                        while (sqlite3_step(stmt) == SQLITE_ROW) {
                                pkgid = (const char *)sqlite3_column_text(stmt, 0);
-                               if (!pkgid || !strlen(pkgid))
+                               if (!pkgid || !strlen(pkgid)) {
                                        continue;
+                               }
 
                                prime = (int)sqlite3_column_int(stmt, 1);
                                if (cb(pkgid, prime, data) < 0) {
@@ -689,18 +708,21 @@ HAPI int io_crawling_liveboxes(int (*cb)(const char *pkgname, int prime, void *d
                struct dirent *ent;
 
                while ((ent = readdir(dir))) {
-                       if (ent->d_name[0] == '.')
+                       if (ent->d_name[0] == '.') {
                                continue;
+                       }
 
                        if (cb(ent->d_name, -1, data) < 0) {
-                               if (closedir(dir) < 0)
+                               if (closedir(dir) < 0) {
                                        ErrPrint("closedir: %s\n", strerror(errno));
+                               }
                                return LB_STATUS_ERROR_CANCEL;
                        }
                }
 
-               if (closedir(dir) < 0)
+               if (closedir(dir) < 0) {
                        ErrPrint("closedir: %s\n", strerror(errno));
+               }
        }
 
        return LB_STATUS_SUCCESS;
@@ -713,8 +735,9 @@ HAPI int io_update_livebox_package(const char *pkgname, int (*cb)(const char *lb
        int prime;
        int ret;
 
-       if (!cb || !pkgname)
+       if (!cb || !pkgname) {
                return LB_STATUS_ERROR_INVALID;
+       }
 
        if (!s_info.handle) {
                ErrPrint("DB is not ready\n");
@@ -737,8 +760,9 @@ HAPI int io_update_livebox_package(const char *pkgname, int (*cb)(const char *lb
        ret = 0;
        while (sqlite3_step(stmt) == SQLITE_ROW) {
                pkgid = (char *)sqlite3_column_text(stmt, 0);
-               if (!pkgid || !strlen(pkgid))
+               if (!pkgid || !strlen(pkgid)) {
                        continue;
+               }
 
                prime = sqlite3_column_int(stmt, 1);
 
@@ -765,20 +789,24 @@ HAPI int io_load_package_db(struct pkg_info *info)
        }
 
        ret = build_provider_info(info);
-       if (ret < 0)
+       if (ret < 0) {
                return ret;
+       }
 
        ret = build_client_info(info);
-       if (ret < 0)
+       if (ret < 0) {
                return ret;
+       }
 
        ret = build_box_size_info(info);
-       if (ret < 0)
+       if (ret < 0) {
                return ret;
+       }
 
        ret = build_group_info(info);
-       if (ret < 0)
+       if (ret < 0) {
                return ret;
+       }
 
        return LB_STATUS_SUCCESS;
 }
@@ -808,16 +836,18 @@ static inline int db_init(void)
                return LB_STATUS_ERROR_INVALID;
        }
 
-       if (stat.st_size <= 0)
+       if (stat.st_size <= 0) {
                DbgPrint("Size is %d (But use this ;)\n", stat.st_size);
+       }
 
        return LB_STATUS_SUCCESS;
 }
 
 static inline int db_fini(void)
 {
-       if (!s_info.handle)
+       if (!s_info.handle) {
                return LB_STATUS_SUCCESS;
+       }
 
        db_util_close(s_info.handle);
        s_info.handle = NULL;
index c81a3e9..ca86448 100644 (file)
@@ -58,10 +58,12 @@ HAPI void liveinfo_fini(void)
        struct liveinfo *info;
 
        EINA_LIST_FREE(s_info.info_list, info) {
-               if (fclose(info->fp) != 0)
+               if (fclose(info->fp) != 0) {
                        ErrPrint("fclose: %s\n", strerror(errno));
-               if (unlink(info->fifo_name) < 0)
+               }
+               if (unlink(info->fifo_name) < 0) {
                        ErrPrint("unlink: %s\n", strerror(errno));
+               }
                DbgFree(info);
        }
 }
@@ -107,8 +109,9 @@ HAPI struct liveinfo *liveinfo_create(pid_t pid, int handle)
        snprintf(info->fifo_name, sizeof(info->fifo_name), "/tmp/.live_info.%lf", util_timestamp());
        if (mkfifo(info->fifo_name, 0644) < 0) {
                ErrPrint("mkfifo: %s\n", strerror(errno));
-               if (unlink(info->fifo_name) < 0)
+               if (unlink(info->fifo_name) < 0) {
                        ErrPrint("unlink: %s\n", strerror(errno));
+               }
                DbgFree(info);
                return NULL;
        }
@@ -137,8 +140,9 @@ HAPI int liveinfo_open_fifo(struct liveinfo *info)
 HAPI void liveinfo_close_fifo(struct liveinfo *info)
 {
        if (info->fp) {
-               if (fclose(info->fp) != 0)
+               if (fclose(info->fp) != 0) {
                        ErrPrint("fclose: %s\n", strerror(errno));
+               }
                info->fp = NULL;
        }
 }
@@ -147,8 +151,9 @@ HAPI void liveinfo_destroy(struct liveinfo *info)
 {
        s_info.info_list = eina_list_remove(s_info.info_list, info);
        liveinfo_close_fifo(info);
-       if (unlink(info->fifo_name) < 0)
+       if (unlink(info->fifo_name) < 0) {
                ErrPrint("unlink: %s\n", strerror(errno));
+       }
        DbgFree(info);
 }
 
@@ -173,8 +178,9 @@ HAPI struct liveinfo *liveinfo_find_by_pid(pid_t pid)
        struct liveinfo *info;
 
        EINA_LIST_FOREACH(s_info.info_list, l, info) {
-               if (info->pid == pid)
+               if (info->pid == pid) {
                        return info;
+               }
        }
 
        return NULL;
@@ -186,8 +192,9 @@ HAPI struct liveinfo *liveinfo_find_by_handle(int handle)
        struct liveinfo *info;
 
        EINA_LIST_FOREACH(s_info.info_list, l, info) {
-               if (info->handle == handle)
+               if (info->handle == handle) {
                        return info;
+               }
        }
 
        return NULL;
index b806925..4aae8be 100644 (file)
@@ -67,8 +67,9 @@ static inline int app_create(void)
        int ret;
 
        if (access(SLAVE_LOG_PATH, R_OK|W_OK) != 0) {
-               if (mkdir(SLAVE_LOG_PATH, 755) < 0)
+               if (mkdir(SLAVE_LOG_PATH, 755) < 0) {
                        ErrPrint("Failed to create %s (%s)\n", SLAVE_LOG_PATH, strerror(errno));
+               }
        }
 
        /*!
@@ -212,8 +213,9 @@ static Eina_Bool signal_cb(void *data, Ecore_Fd_Handler *handler)
                CRITICAL_LOG("Terminated(SIGTERM)\n");
 
                cfd = creat("/tmp/.stop.provider", 0644);
-               if (cfd < 0 || close(cfd) < 0)
+               if (cfd < 0 || close(cfd) < 0) {
                        ErrPrint("stop.provider: %s\n", strerror(errno));
+               }
 
                vconf_set_bool(VCONFKEY_MASTER_STARTED, 0);
                //exit(0);
@@ -259,13 +261,15 @@ int main(int argc, char *argv[])
         * Is there any way to print something on the screen?
         */
        ret = critical_log_init(util_basename(argv[0]));
-       if (ret < 0)
+       if (ret < 0) {
                ErrPrint("Failed to init the critical log\n");
+       }
 
 #if defined(FLOG)
        __file_log_fp = fopen("/tmp/live.log", "w+t");
-       if (!__file_log_fp)
+       if (!__file_log_fp) {
                __file_log_fp = fdopen(1, "w+t");
+       }
 #endif
        /* appcore_agent_terminate */
        if (ecore_init() <= 0) {
@@ -277,20 +281,24 @@ int main(int argc, char *argv[])
        sigemptyset(&mask);
 
        ret = sigaddset(&mask, SIGTERM);
-       if (ret < 0)
+       if (ret < 0) {
                CRITICAL_LOG("Failed to do sigemptyset: %s\n", strerror(errno));
+       }
 
        ret = sigaddset(&mask, SIGUSR1);
-       if (ret < 0)
+       if (ret < 0) {
                CRITICAL_LOG("Failed to do sigemptyset: %s\n", strerror(errno));
+       }
 
        ret = sigaddset(&mask, SIGUSR2);
-       if (ret < 0)
+       if (ret < 0) {
                CRITICAL_LOG("Failed to do sigemptyset: %s\n", strerror(errno));
+       }
 
        ret = sigprocmask(SIG_BLOCK, &mask, NULL);
-       if (ret < 0)
+       if (ret < 0) {
                CRITICAL_LOG("Failed to mask the SIGTERM: %s\n", strerror(errno));
+       }
 
        ret = signalfd(-1, &mask, 0);
        if (ret < 0) {
@@ -343,15 +351,17 @@ int main(int argc, char *argv[])
 
        ecore_x_shutdown();
 
-       if (signal_handler)
+       if (signal_handler) {
                ecore_main_fd_handler_del(signal_handler);
+       }
 
        ecore_shutdown();
        critical_log_fini();
 
 #if defined(FLOG)
-       if (__file_log_fp)
+       if (__file_log_fp) {
                fclose(__file_log_fp);
+       }
 #endif
        return 0;
 }
index 68c3db4..5396475 100755 (executable)
@@ -473,8 +473,9 @@ static int service_thread_main(struct tcb *tcb, struct packet *packet, void *dat
                DbgPrint("%p REQ: Command: [%s]\n", tcb, command);
 
                for (i = 0; service_req_table[i].cmd; i++) {
-                       if (strcmp(service_req_table[i].cmd, command))
+                       if (strcmp(service_req_table[i].cmd, command)) {
                                continue;
+                       }
 
 #if ENABLE_NS_ACCESS_CONTROL
                        if (_is_valid_permission(tcb_fd(tcb), &(service_req_table[i])) == 1) {
@@ -550,8 +551,9 @@ HAPI int notification_service_init(void)
 
 HAPI int notification_service_fini(void)
 {
-       if (!s_info.svc_ctx)
+       if (!s_info.svc_ctx) {
                return LB_STATUS_ERROR_INVALID;
+       }
 
        service_common_destroy(s_info.svc_ctx);
        s_info.svc_ctx = NULL;
index 588a7db..bcfa278 100644 (file)
@@ -152,8 +152,9 @@ static int slave_activated_cb(struct slave_node *slave, void *data)
        cnt = 0;
        EINA_LIST_FOREACH_SAFE(info->inst_list, l, n, inst) {
                ret = instance_recover_state(inst);
-               if (!ret)
+               if (!ret) {
                        continue;
+               }
 
                instance_thaw_updator(inst);
                cnt++;
@@ -223,8 +224,9 @@ static int xmonitor_paused_cb(void *data)
        struct inst_info *inst;
        Eina_List *l;
 
-       if (slave_state(info->slave) != SLAVE_TERMINATED)
+       if (slave_state(info->slave) != SLAVE_TERMINATED) {
                return 0;
+       }
 
        EINA_LIST_FOREACH(info->inst_list, l, inst) {
                instance_freeze_updator(inst);
@@ -239,8 +241,9 @@ static int xmonitor_resumed_cb(void *data)
        struct inst_info *inst;
        Eina_List *l;
 
-       if (slave_state(info->slave) != SLAVE_TERMINATED)
+       if (slave_state(info->slave) != SLAVE_TERMINATED) {
                return 0;
+       }
 
        EINA_LIST_FOREACH(info->inst_list, l, inst) {
                instance_thaw_updator(inst);
@@ -444,10 +447,11 @@ static inline int load_conf(struct pkg_info *info)
        info->network = parser_network(parser);
 
        info->lb.period = parser_period(parser);
-       if (info->lb.period < 0.0f)
+       if (info->lb.period < 0.0f) {
                info->lb.period = 0.0f;
-       else if (info->lb.period > 0.0f && info->lb.period < MINIMUM_PERIOD)
+       } else if (info->lb.period > 0.0f && info->lb.period < MINIMUM_PERIOD) {
                info->lb.period = MINIMUM_PERIOD;
+       }
 
        info->lb.size_list = parser_size(parser);
 
@@ -477,8 +481,9 @@ static inline int load_conf(struct pkg_info *info)
        parser_get_pdsize(parser, &info->pd.width, &info->pd.height);
 
        group = parser_group_str(parser);
-       if (group && group_add_livebox(group, info->pkgname) < 0)
+       if (group && group_add_livebox(group, info->pkgname) < 0) {
                ErrPrint("Failed to build cluster tree for %s{%s}\n", info->pkgname, group);
+       }
 
        parser_unload(parser);
        return LB_STATUS_SUCCESS;
@@ -555,8 +560,9 @@ HAPI char *package_lb_pkgname(const char *pkgname)
 
        lb_pkgname = io_livebox_pkgname(pkgname);
        if (!lb_pkgname) {
-               if (util_validate_livebox_package(pkgname) < 0)
+               if (util_validate_livebox_package(pkgname) < 0) {
                        return NULL;
+               }
 
                lb_pkgname = strdup(pkgname);
                if (!lb_pkgname) {
@@ -585,12 +591,14 @@ HAPI struct pkg_info *package_find(const char *pkgname)
        Eina_List *l;
        struct pkg_info *info;
 
-       if (!pkgname)
+       if (!pkgname) {
                return NULL;
+       }
 
        EINA_LIST_FOREACH(s_info.pkg_list, l, info) {
-               if (!strcmp(info->pkgname, pkgname))
+               if (!strcmp(info->pkgname, pkgname)) {
                        return info;
+               }
        }
 
        return NULL;
@@ -609,8 +617,9 @@ HAPI struct inst_info *package_find_instance_by_id(const char *pkgname, const ch
        }
 
        EINA_LIST_FOREACH(info->inst_list, l, inst) {
-               if (!strcmp(instance_id(inst), id))
+               if (!strcmp(instance_id(inst), id)) {
                        return inst;
+               }
        }
 
        return NULL;
@@ -629,8 +638,9 @@ HAPI struct inst_info *package_find_instance_by_timestamp(const char *pkgname, d
        }
 
        EINA_LIST_FOREACH(info->inst_list, l, inst) {
-               if (instance_timestamp(inst) == timestamp)
+               if (instance_timestamp(inst) == timestamp) {
                        return inst;
+               }
        }
 
        return NULL;
@@ -638,8 +648,9 @@ HAPI struct inst_info *package_find_instance_by_timestamp(const char *pkgname, d
 
 HAPI int package_dump_fault_info(struct pkg_info *info)
 {
-       if (!info->fault_info)
+       if (!info->fault_info) {
                return LB_STATUS_ERROR_NOT_EXIST;
+       }
 
        CRITICAL_LOG("=============\n");
        CRITICAL_LOG("faulted at %lf\n", info->fault_info->timestamp);
@@ -651,8 +662,9 @@ HAPI int package_dump_fault_info(struct pkg_info *info)
 
 HAPI int package_get_fault_info(struct pkg_info *info, double *timestamp, const char **filename, const char **function)
 {
-       if (!info->fault_info)
+       if (!info->fault_info) {
                return LB_STATUS_ERROR_NOT_EXIST;
+       }
 
        *timestamp = info->fault_info->timestamp;
        *filename = info->fault_info->filename;
@@ -673,10 +685,12 @@ HAPI int package_set_fault_info(struct pkg_info *info, double timestamp, const c
        }
 
        fault->timestamp = timestamp;
-       if (!filename)
+       if (!filename) {
                filename = "unknown";
-       if (!function)
+       }
+       if (!function) {
                function = "unknown";
+       }
 
        fault->filename = strdup(filename);
        if (!fault->filename) {
@@ -700,8 +714,9 @@ HAPI int package_set_fault_info(struct pkg_info *info, double timestamp, const c
 
 HAPI int package_clear_fault(struct pkg_info *info)
 {
-       if (!info->fault_info)
+       if (!info->fault_info) {
                return LB_STATUS_ERROR_INVALID;
+       }
        
        package_dump_fault_info(info);
 
@@ -793,8 +808,9 @@ HAPI int package_set_abi(struct pkg_info *info, const char *abi)
 
 HAPI const char * const package_lb_path(const struct pkg_info *info)
 {
-       if (info->lb.type != LB_TYPE_SCRIPT)
+       if (info->lb.type != LB_TYPE_SCRIPT) {
                return NULL;
+       }
 
        return info->lb.info.script.path;
 }
@@ -803,8 +819,9 @@ HAPI int package_set_lb_path(struct pkg_info *info, const char *path)
 {
        char *tmp;
 
-       if (info->lb.type != LB_TYPE_SCRIPT)
+       if (info->lb.type != LB_TYPE_SCRIPT) {
                return LB_STATUS_ERROR_INVALID;
+       }
 
        tmp = strdup(path);
        if (!tmp) {
@@ -819,8 +836,9 @@ HAPI int package_set_lb_path(struct pkg_info *info, const char *path)
 
 HAPI const char * const package_lb_group(const struct pkg_info *info)
 {
-       if (info->lb.type != LB_TYPE_SCRIPT)
+       if (info->lb.type != LB_TYPE_SCRIPT) {
                return NULL;
+       }
 
        return info->lb.info.script.group;
 }
@@ -829,8 +847,9 @@ HAPI int package_set_lb_group(struct pkg_info *info, const char *group)
 {
        char *tmp;
 
-       if (info->lb.type != LB_TYPE_SCRIPT)
+       if (info->lb.type != LB_TYPE_SCRIPT) {
                return LB_STATUS_ERROR_INVALID;
+       }
 
        tmp = strdup(group);
        if (!tmp) {
@@ -845,8 +864,9 @@ HAPI int package_set_lb_group(struct pkg_info *info, const char *group)
 
 HAPI const char * const package_pd_path(const struct pkg_info *info)
 {
-       if (info->pd.type != PD_TYPE_SCRIPT)
+       if (info->pd.type != PD_TYPE_SCRIPT) {
                return NULL;
+       }
 
        return info->pd.info.script.path;
 }
@@ -855,8 +875,9 @@ HAPI int package_set_pd_path(struct pkg_info *info, const char *path)
 {
        char *tmp;
 
-       if (info->pd.type != PD_TYPE_SCRIPT)
+       if (info->pd.type != PD_TYPE_SCRIPT) {
                return LB_STATUS_ERROR_INVALID;
+       }
 
        tmp = strdup(path);
        if (!tmp) {
@@ -871,8 +892,9 @@ HAPI int package_set_pd_path(struct pkg_info *info, const char *path)
 
 HAPI const char * const package_pd_group(const struct pkg_info *info)
 {
-       if (info->pd.type != PD_TYPE_SCRIPT)
+       if (info->pd.type != PD_TYPE_SCRIPT) {
                return NULL;
+       }
 
        return info->pd.info.script.group;
 }
@@ -881,8 +903,9 @@ HAPI int package_set_pd_group(struct pkg_info *info, const char *group)
 {
        char *tmp;
 
-       if (info->pd.type != PD_TYPE_SCRIPT)
+       if (info->pd.type != PD_TYPE_SCRIPT) {
                return LB_STATUS_ERROR_INVALID;
+       }
 
        tmp = strdup(group);
        if (!tmp) {
@@ -912,8 +935,9 @@ HAPI const char * const package_auto_launch(const struct pkg_info *info)
 
 HAPI void package_set_auto_launch(struct pkg_info *info, const char *auto_launch)
 {
-       if (!auto_launch)
+       if (!auto_launch) {
                auto_launch = "";
+       }
 
        info->lb.auto_launch = strdup(auto_launch);
        if (!info->lb.auto_launch) {
@@ -1096,8 +1120,9 @@ HAPI int package_add_instance(struct pkg_info *info, struct inst_info *inst)
                        int ret;
 
                        ret = assign_new_slave(info);
-                       if (ret < 0)
+                       if (ret < 0) {
                                return ret;
+                       }
                } else {
                        DbgPrint("Slave %s is used for %s\n", slave_name(info->slave), info->pkgname);
                }
@@ -1133,8 +1158,9 @@ HAPI int package_del_instance(struct pkg_info *info, struct inst_info *inst)
 {
        info->inst_list = eina_list_remove(info->inst_list, inst);
 
-       if (info->inst_list)
+       if (info->inst_list) {
                return LB_STATUS_SUCCESS;
+       }
 
        if (info->slave) {
                slave_unload_package(info->slave);
@@ -1155,8 +1181,9 @@ HAPI int package_del_instance(struct pkg_info *info, struct inst_info *inst)
                info->slave = NULL;
        }
 
-       if (info->is_uninstalled)
+       if (info->is_uninstalled) {
                package_destroy(info);
+       }
 
        return LB_STATUS_SUCCESS;
 }
@@ -1281,7 +1308,11 @@ static int io_install_cb(const char *pkgname, int prime, void *data)
                reload_package_info(info);
        } else {
                info = package_create(pkgname);
-               DbgPrint("Package %s is%sbuilt\n", pkgname, info ? " " : " not ");
+               if (!info) {
+                       ErrPrint("Failed to build an info: %s\n", pkgname);
+               } else {
+                       DbgPrint("Package %s is built\n", pkgname);
+               }
        }
 
        return 0;
@@ -1291,8 +1322,9 @@ static int install_cb(const char *pkgname, enum pkgmgr_status status, double val
 {
        int ret;
 
-       if (status != PKGMGR_STATUS_END)
+       if (status != PKGMGR_STATUS_END) {
                return 0;
+       }
 
        ret = io_update_livebox_package(pkgname, io_install_cb, NULL);
        return 0;
@@ -1319,8 +1351,9 @@ static int io_update_cb(const char *pkgname, int prime, void *data)
 
        DbgPrint("Livebox package %s is updated\n", pkgname);
        info = package_find(pkgname);
-       if (!info)
+       if (!info) {
                return 0;
+       }
 
        reload_package_info(info);
        return 0;
@@ -1329,8 +1362,9 @@ static int io_update_cb(const char *pkgname, int prime, void *data)
 static int update_cb(const char *pkgname, enum pkgmgr_status status, double value, void *data)
 {
        int ret;
-       if (status != PKGMGR_STATUS_END)
+       if (status != PKGMGR_STATUS_END) {
                return 0;
+       }
 
        ret = io_update_livebox_package(pkgname, io_update_cb, NULL);
        return 0;
@@ -1343,8 +1377,9 @@ static int crawling_liveboxes(const char *pkgname, int prime, void *data)
        } else {
                struct pkg_info *info;
                info = package_create(pkgname);
-               if (info)
+               if (info) {
                        DbgPrint("[%s] information is built prime(%d)\n", pkgname, prime);
+               }
        }
 
        return 0;
@@ -1395,12 +1430,14 @@ HAPI const char *package_find_by_secured_slave(struct slave_node *slave)
        Eina_List *l;
        struct pkg_info *info;
 
-       if (!slave_is_secured(slave))
+       if (!slave_is_secured(slave)) {
                return NULL;
+       }
 
        EINA_LIST_FOREACH(s_info.pkg_list, l, info) {
-               if (info->slave == slave)
+               if (info->slave == slave) {
                        return info->pkgname;
+               }
        }
 
        return NULL;
@@ -1424,11 +1461,13 @@ HAPI int package_alter_instances_to_client(struct client_node *client, enum alte
 
        EINA_LIST_FOREACH(s_info.pkg_list, l, info) {
                EINA_LIST_FOREACH(info->inst_list, i_l, inst) {
-                       if (instance_client(inst))
+                       if (instance_client(inst)) {
                                continue;
+                       }
 
-                       if (!client_is_subscribed(client, instance_cluster(inst), instance_category(inst)))
+                       if (!client_is_subscribed(client, instance_cluster(inst), instance_category(inst))) {
                                continue;
+                       }
 
                        switch (instance_state(inst)) {
                        case INST_INIT:
@@ -1508,8 +1547,9 @@ HAPI int package_is_enabled(const char *appid)
                return 0;
        }
 
-       if (ail_appinfo_get_bool(ai, AIL_PROP_X_SLP_ENABLED_BOOL, &enabled) != AIL_ERROR_OK)
+       if (ail_appinfo_get_bool(ai, AIL_PROP_X_SLP_ENABLED_BOOL, &enabled) != AIL_ERROR_OK) {
                enabled = false;
+       }
 
        ail_destroy_appinfo(ai);
 
index dab3536..108942b 100644 (file)
@@ -168,8 +168,9 @@ HAPI int parser_find(const char *pkgname)
        len = strlen(pkgname) * 2 + strlen(CONF_PATH);
 
        filename = malloc(len);
-       if (!filename)
+       if (!filename) {
                return LB_STATUS_SUCCESS;
+       }
 
        ret = snprintf(filename, len, CONF_PATH, pkgname, pkgname);
        if (ret < 0) {
@@ -302,10 +303,11 @@ static inline int parse_size(const char *buffer, unsigned int *size)
                                ErrPrint("Invalid size type: %dx%d\n", w, h);
                        }
 
-                       if (buffer[i] == ';')
+                       if (buffer[i] == ';') {
                                state = START;
-                       else if (buffer[i] == '\0')
+                       } else if (buffer[i] == '\0') {
                                state = END;
+                       }
 
                        w = 0;
                        h = 0;
@@ -327,11 +329,13 @@ static inline const char *rtrim(char *buffer)
        int len;
 
        len = strlen(buffer);
-       while (len > 0 && isspace(buffer[len - 1]))
+       while (len > 0 && isspace(buffer[len - 1])) {
                len--;
+       }
 
-       if (len <= 0)
+       if (len <= 0) {
                return NULL;
+       }
 
        buffer[len] = '\0';
 
@@ -346,8 +350,9 @@ static inline char *dup_rtrim(char *buffer)
 {
        char *ret;
 
-       if (!rtrim(buffer))
+       if (!rtrim(buffer)) {
                return NULL;
+       }
 
        ret = strdup(buffer);
        if (!ret) {
@@ -362,32 +367,36 @@ static void period_handler(struct parser *item, char *buffer)
 {
        char *tmp = NULL;
 
-       if (!rtrim(buffer))
+       if (!rtrim(buffer)) {
                return;
+       }
 
        item->period = strtod(buffer, &tmp);
 }
 
 static void timeout_handler(struct parser *item, char *buffer)
 {
-       if (!rtrim(buffer))
+       if (!rtrim(buffer)) {
                return;
+       }
 
        item->timeout = atoi(buffer);
 }
 
 static void network_handler(struct parser *item, char *buffer)
 {
-       if (!rtrim(buffer))
+       if (!rtrim(buffer)) {
                return;
+       }
 
        item->network = !!atoi(buffer);
 }
 
 static void auto_launch_handler(struct parser *item, char *buffer)
 {
-       if (!rtrim(buffer))
+       if (!rtrim(buffer)) {
                return;
+       }
 
        item->auto_launch = strdup(buffer);
        if (!item->auto_launch) {
@@ -406,14 +415,16 @@ static void size_handler(struct parser *item, char *buffer)
 
 static void pd_size_handler(struct parser *item, char *buffer)
 {
-       if (sscanf(buffer, "%ux%u", &item->pd_width, &item->pd_height) != 2)
+       if (sscanf(buffer, "%ux%u", &item->pd_width, &item->pd_height) != 2) {
                ErrPrint("parse pd size\n");
+       }
 }
 
 static void text_lb_handler(struct parser *item, char *buffer)
 {
-       if (!rtrim(buffer))
+       if (!rtrim(buffer)) {
                return;
+       }
 
        item->text_lb = !!atoi(buffer);
 }
@@ -430,91 +441,107 @@ static void script_handler(struct parser *item, char *buffer)
 
 static void buffer_pd_handler(struct parser *item, char *buffer)
 {
-       if (!rtrim(buffer))
+       if (!rtrim(buffer)) {
                return;
+       }
 
        item->buffer_pd = !!atoi(buffer);
 }
 
 static void buffer_lb_handler(struct parser *item, char *buffer)
 {
-       if (!rtrim(buffer))
+       if (!rtrim(buffer)) {
                return;
+       }
+
        item->buffer_lb = !!atoi(buffer);
 }
 
 static void text_pd_handler(struct parser *item, char *buffer)
 {
-       if (!rtrim(buffer))
+       if (!rtrim(buffer)) {
                return;
+       }
 
        item->text_pd = !!atoi(buffer);
 }
 
 static void pinup_handler(struct parser *item, char *buffer)
 {
-       if (!rtrim(buffer))
+       if (!rtrim(buffer)) {
                return;
+       }
 
        item->pinup = !!atoi(buffer);
 }
 
 static void lb_path_handler(struct parser *item, char *buffer)
 {
-       if (item->lb_path)
+       if (item->lb_path) {
                DbgFree(item->lb_path);
+       }
 
        item->lb_path = dup_rtrim(buffer);
-       if (!item->lb_path)
+       if (!item->lb_path) {
                ErrPrint("Error: %s\n", strerror(errno));
+       }
 }
 
 static void group_handler(struct parser *item, char *buffer)
 {
-       if (item->group)
+       if (item->group) {
                DbgFree(item->group);
+       }
 
        item->group = dup_rtrim(buffer);
-       if (!item->group)
+       if (!item->group) {
                ErrPrint("Error: %s\n", strerror(errno));
+       }
 }
 
 static void secured_handler(struct parser *item, char *buffer)
 {
-       if (!rtrim(buffer))
+       if (!rtrim(buffer)) {
                return;
+       }
 
        item->secured = !!atoi(buffer);
 }
 
 static void lb_group_handler(struct parser *item, char *buffer)
 {
-       if (item->lb_group)
+       if (item->lb_group) {
                DbgFree(item->lb_group);
+       }
 
        item->lb_group = dup_rtrim(buffer);
-       if (!item->lb_group)
+       if (!item->lb_group) {
                ErrPrint("Error: %s\n", strerror(errno));
+       }
 }
 
 static void pd_path_handler(struct parser *item, char *buffer)
 {
-       if (item->pd_path)
+       if (item->pd_path) {
                DbgFree(item->pd_path);
+       }
 
        item->pd_path = dup_rtrim(buffer);
-       if (!item->pd_path)
+       if (!item->pd_path) {
                ErrPrint("Error: %s\n", strerror(errno));
+       }
 }
 
 static void pd_group_handler(struct parser *item, char *buffer)
 {
-       if (item->pd_group)
+       if (item->pd_group) {
                DbgFree(item->pd_group);
+       }
 
        item->pd_group = dup_rtrim(buffer);
-       if (!item->pd_group)
+       if (!item->pd_group) {
                ErrPrint("Error: %s\n", strerror(errno));
+       }
 }
 
 HAPI struct parser *parser_load(const char *pkgname)
@@ -626,8 +653,9 @@ HAPI struct parser *parser_load(const char *pkgname)
        int ret;
 
        item = calloc(1, sizeof(*item));
-       if (!item)
+       if (!item) {
                return 0;
+       }
 
        /* live-, .conf */
        len = strlen(CONF_PATH) + strlen(pkgname) * 2;
@@ -671,8 +699,9 @@ HAPI struct parser *parser_load(const char *pkgname)
        linelen = 0;
        do {
                c = getc(fp);
-               if ((c == EOF) && (state == VALUE))
+               if ((c == EOF) && (state == VALUE)) {
                        state = END;
+               }
 
                switch (state) {
                case COMMENT:
@@ -704,10 +733,11 @@ HAPI struct parser *parser_load(const char *pkgname)
                        }
                        break;
                case SPACE:
-                       if (c == '=')
+                       if (c == '=') {
                                state = VALUE;
-                       else if (!isspace(c))
+                       } else if (!isspace(c)) {
                                state = ERROR;
+                       }
                        break;
                case VALUE:
                        if (c == '"') {
@@ -716,8 +746,9 @@ HAPI struct parser *parser_load(const char *pkgname)
                                        state = END;
                                } else if (buffer_idx != 0) {
                                        buffer[buffer_idx++] = c;
-                                       if (buffer_idx >= sizeof(buffer))
+                                       if (buffer_idx >= sizeof(buffer)) {
                                                state = ERROR;
+                                       }
                                } else {
                                        quote = 1;
                                }
@@ -726,8 +757,9 @@ HAPI struct parser *parser_load(const char *pkgname)
                                        /* Ignore */
                                } else if (quote == 1) {
                                        buffer[buffer_idx++] = c;
-                                       if (buffer_idx >= sizeof(buffer))
+                                       if (buffer_idx >= sizeof(buffer)) {
                                                state = ERROR;
+                                       }
                                } else {
                                        buffer[buffer_idx] = '\0';
                                        ungetc(c, fp);
@@ -735,24 +767,28 @@ HAPI struct parser *parser_load(const char *pkgname)
                                }
                        } else {
                                buffer[buffer_idx++] = c;
-                               if (buffer_idx >= sizeof(buffer))
+                               if (buffer_idx >= sizeof(buffer)) {
                                        state = ERROR;
+                               }
                        }
                        break;
                case TOKEN:
                        if (c == '=') {
-                               if (token_idx < 0)
+                               if (token_idx < 0) {
                                        state = ERROR;
-                               else
+                               } else {
                                        state = VALUE;
+                               }
                        } else if (isspace(c)) {
-                               if (token_idx < 0)
+                               if (token_idx < 0) {
                                        break;
+                               }
 
-                               if (token_handler[token_idx].name[ch_idx] != '\0')
+                               if (token_handler[token_idx].name[ch_idx] != '\0') {
                                        state = ERROR;
-                               else
+                               } else {
                                        state = SPACE;
+                               }
                        } else  {
                                if (token_idx < 0) {
                                        /* Now start to find a token! */
@@ -763,15 +799,17 @@ HAPI struct parser *parser_load(const char *pkgname)
                                        ch_idx++;
                                } else {
                                        ungetc(c, fp);
-                                       while (ch_idx-- > 0)
+                                       while (ch_idx-- > 0) {
                                                ungetc(token_handler[token_idx].name[ch_idx], fp);
+                                       }
 
                                        token_idx++;
 
-                                       if (token_handler[token_idx].name == NULL)
+                                       if (token_handler[token_idx].name == NULL) {
                                                state = ERROR;
-                                       else
+                                       } else {
                                                ch_idx = 0;
+                                       }
                                }
                        }
                        break;
@@ -795,8 +833,9 @@ HAPI struct parser *parser_load(const char *pkgname)
                                 */
                                buffer[buffer_idx] = '\0';
 
-                               if (token_idx >= 0 && token_handler[token_idx].handler)
+                               if (token_idx >= 0 && token_handler[token_idx].handler) {
                                        token_handler[token_idx].handler(item, buffer);
+                               }
 
                                token_idx = -1;
                                ch_idx = 0;
@@ -818,8 +857,9 @@ HAPI struct parser *parser_load(const char *pkgname)
                linelen++;
         } while (c != EOF);
 
-       if (fclose(fp) != 0)
+       if (fclose(fp) != 0) {
                ErrPrint("fclose: %s\n", strerror(errno));
+       }
 
        s_list = eina_list_append(s_list, item);
        return item;
index 316148f..56ec320 100644 (file)
@@ -67,8 +67,9 @@ static inline void invoke_install_event_handler(const char *pkgname, enum pkgmgr
        struct event_item *item;
 
        EINA_LIST_FOREACH(s_info.install_event, l, item) {
-               if (item->cb)
+               if (item->cb) {
                        item->cb(pkgname, status, value, item->data);
+               }
        }
 }
 
@@ -78,8 +79,9 @@ static inline void invoke_uninstall_event_handler(const char *pkgname, enum pkgm
        struct event_item *item;
 
        EINA_LIST_FOREACH(s_info.uninstall_event, l, item) {
-               if (item->cb)
+               if (item->cb) {
                        item->cb(pkgname, status, value, item->data);
+               }
        }
 }
 
@@ -89,8 +91,9 @@ static inline void invoke_update_event_handler(const char *pkgname, enum pkgmgr_
        struct event_item *item;
 
        EINA_LIST_FOREACH(s_info.update_event, l, item) {
-               if (item->cb)
+               if (item->cb) {
                        item->cb(pkgname, status, value, item->data);
+               }
        }
 }
 
@@ -100,8 +103,9 @@ static inline void invoke_download_event_handler(const char *pkgname, enum pkgmg
        struct event_item *item;
 
        EINA_LIST_FOREACH(s_info.download_event, l, item) {
-               if (item->cb)
+               if (item->cb) {
                        item->cb(pkgname, status, value, item->data);
+               }
        }
 }
 
@@ -111,8 +115,9 @@ static inline void invoke_recover_event_handler(const char *pkgname, enum pkgmgr
        struct event_item *item;
 
        EINA_LIST_FOREACH(s_info.recover_event, l, item) {
-               if (item->cb)
+               if (item->cb) {
                        item->cb(pkgname, status, value, item->data);
+               }
        }
 }
 
@@ -178,8 +183,9 @@ static struct item *find_item(const char *pkgname)
        }
 
        EINA_LIST_FOREACH(s_info.item_list, l, item) {
-               if (strcmp(item->pkgname, pkgname))
+               if (strcmp(item->pkgname, pkgname)) {
                        continue;
+               }
 
                return item;
        }
@@ -239,11 +245,13 @@ static int icon_path_cb(const char *pkgname, const char *val, void *data)
        DbgPrint("[%s] %s\n", pkgname, val);
 
        item = find_item(pkgname);
-       if (!item)
+       if (!item) {
                return LB_STATUS_ERROR_NOT_EXIST;
+       }
 
-       if (item->icon)
+       if (item->icon) {
                DbgFree(item->icon);
+       }
 
        item->icon = strdup(val);
        if (!item->icon) {
@@ -261,8 +269,9 @@ static int command_cb(const char *pkgname, const char *val, void *data)
        DbgPrint("[%s] %s\n", pkgname, val);
 
        item = find_item(pkgname);
-       if (!item)
+       if (!item) {
                return LB_STATUS_ERROR_NOT_EXIST;
+       }
 
        if (!is_valid_status(item, val)) {
                DbgPrint("Invalid status: %d, %s\n", item->type, val);
@@ -282,8 +291,9 @@ static int error_cb(const char *pkgname, const char *val, void *data)
        DbgPrint("[%s] %s\n", pkgname, val);
 
        item = find_item(pkgname);
-       if (!item)
+       if (!item) {
                return LB_STATUS_ERROR_NOT_EXIST;
+       }
 
        item->status = PKGMGR_STATUS_ERROR;
        invoke_callback(pkgname, item, 0.0f);
@@ -298,8 +308,9 @@ static int change_pkgname_cb(const char *pkgname, const char *val, void *data)
        DbgPrint("[%s] %s\n", pkgname, val);
 
        item = find_item(pkgname);
-       if (!item)
+       if (!item) {
                return LB_STATUS_ERROR_NOT_EXIST;
+       }
 
        new_pkgname = strdup(val);
        if (!new_pkgname) {
@@ -343,8 +354,9 @@ static int download_cb(const char *pkgname, const char *val, void *data)
        }
 
        if (val) {
-               if (sscanf(val, "%lf", &value) != 1)
+               if (sscanf(val, "%lf", &value) != 1) {
                        value = (double)LB_STATUS_ERROR_INVALID;
+               }
        } else {
                value = (double)LB_STATUS_ERROR_INVALID;
        }
@@ -379,8 +391,9 @@ static int progress_cb(const char *pkgname, const char *val, void *data)
        }
 
        if (val) {
-               if (sscanf(val, "%lf", &value) != 1)
+               if (sscanf(val, "%lf", &value) != 1) {
                        value = (double)LB_STATUS_ERROR_INVALID;
+               }
        } else {
                value = (double)LB_STATUS_ERROR_INVALID;
        }
@@ -396,8 +409,9 @@ static int end_cb(const char *pkgname, const char *val, void *data)
        DbgPrint("[%s] %s\n", pkgname, val);
 
        item = find_item(pkgname);
-       if (!item)
+       if (!item) {
                return LB_STATUS_ERROR_NOT_EXIST;
+       }
 
        item->status = !strcasecmp(val, "ok") ? PKGMGR_STATUS_END : PKGMGR_STATUS_ERROR;
 
@@ -431,8 +445,9 @@ static int pkgmgr_cb(int req_id, const char *type, const char *pkgname, const ch
        int ret;
 
        for (i = 0; handler[i].key; i++) {
-               if (strcasecmp(key, handler[i].key))
+               if (strcasecmp(key, handler[i].key)) {
                        continue;
+               }
 
                ret = handler[i].func(pkgname, val, data);
                DbgPrint("REQ[%d] pkgname[%s], type[%s], key[%s], val[%s], ret = %d\n",
@@ -444,15 +459,18 @@ static int pkgmgr_cb(int req_id, const char *type, const char *pkgname, const ch
 
 HAPI int pkgmgr_init(void)
 {
-       if (s_info.listen_pc)
+       if (s_info.listen_pc) {
                return LB_STATUS_ERROR_ALREADY;
+       }
 
        s_info.listen_pc = pkgmgr_client_new(PC_LISTENING);
-       if (!s_info.listen_pc)
+       if (!s_info.listen_pc) {
                return LB_STATUS_ERROR_FAULT;
+       }
 
-       if (pkgmgr_client_listen_status(s_info.listen_pc, pkgmgr_cb, NULL) != PKGMGR_R_OK)
+       if (pkgmgr_client_listen_status(s_info.listen_pc, pkgmgr_cb, NULL) != PKGMGR_R_OK) {
                return LB_STATUS_ERROR_FAULT;
+       }
 
        return LB_STATUS_SUCCESS;
 }
@@ -462,11 +480,13 @@ HAPI int pkgmgr_fini(void)
        struct event_item *item;
        struct item *ctx;
 
-       if (!s_info.listen_pc)
+       if (!s_info.listen_pc) {
                return LB_STATUS_ERROR_INVALID;
+       }
 
-       if (pkgmgr_client_free(s_info.listen_pc) != PKGMGR_R_OK)
+       if (pkgmgr_client_free(s_info.listen_pc) != PKGMGR_R_OK) {
                return LB_STATUS_ERROR_FAULT;
+       }
 
        s_info.listen_pc = NULL;
 
index 91a6285..b3fe0a7 100644 (file)
@@ -141,8 +141,9 @@ static inline struct script_port *find_port(const char *magic_id)
        struct script_port *item;
 
        EINA_LIST_FOREACH(s_info.script_port_list, l, item) {
-               if (!strcmp(item->magic_id(), magic_id))
+               if (!strcmp(item->magic_id(), magic_id)) {
                        return item;
+               }
        }
 
        return NULL;
@@ -235,11 +236,13 @@ int script_signal_emit(Evas *e, const char *part, const char *signal, double sx,
                return LB_STATUS_ERROR_INVALID;
        }
 
-       if (!signal || strlen(signal) == 0)
+       if (!signal || strlen(signal) == 0) {
                signal = "";
+       }
 
-       if (!part || strlen(part) == 0)
+       if (!part || strlen(part) == 0) {
                part = "";
+       }
 
        return instance_signal_emit(info->inst, signal, part, sx, sy, ex, ey, (double)info->x / (double)info->w, (double)info->y / (double)info->h, info->down);
 }
@@ -269,8 +272,9 @@ HAPI int script_handler_load(struct script_info *info, int is_pd)
        }
 
        ret = fb_create_buffer(info->fb);
-       if (ret < 0)
+       if (ret < 0) {
                return ret;
+       }
 
        info->ee = fb_canvas(info->fb);
        if (!info->ee) {
@@ -314,12 +318,14 @@ HAPI int script_handler_unload(struct script_info *info, int is_pd)
        Ecore_Evas *ee;
        Evas *e;
 
-       if (!info || !info->port)
+       if (!info || !info->port) {
                return LB_STATUS_ERROR_INVALID;
+       }
 
        info->loaded--;
-       if (info->loaded > 0)
+       if (info->loaded > 0) {
                return LB_STATUS_SUCCESS;
+       }
 
        if (info->loaded < 0) {
                info->loaded = 0;
@@ -330,8 +336,9 @@ HAPI int script_handler_unload(struct script_info *info, int is_pd)
        if (e) {
                script_signal_emit(e, instance_id(info->inst),
                                is_pd ? "pd,hide" : "lb,hide", 0.0f, 0.0f, 0.0f, 0.0f);
-               if (info->port->unload(info->port_data, e) < 0)
+               if (info->port->unload(info->port_data, e) < 0) {
                        ErrPrint("Failed to unload script object. but go ahead\n");
+               }
                evas_event_callback_del(e, EVAS_CALLBACK_RENDER_POST, render_post_cb);
                evas_event_callback_del(e, EVAS_CALLBACK_RENDER_PRE, render_pre_cb);
        } else {
@@ -339,8 +346,9 @@ HAPI int script_handler_unload(struct script_info *info, int is_pd)
        }
 
        ee = fb_canvas(info->fb);
-       if (ee)
+       if (ee) {
                ecore_evas_data_set(ee, "script,info", NULL);
+       }
 
        fb_destroy_buffer(info->fb);
        return LB_STATUS_SUCCESS;
@@ -352,8 +360,9 @@ HAPI struct script_info *script_handler_create(struct inst_info *inst, const cha
 
        DbgPrint("Create script: %s (%s) %dx%d\n", file, option, w, h);
 
-       if (!file)
+       if (!file) {
                return NULL;
+       }
 
        info = calloc(1, sizeof(*info));
        if (!info) {
@@ -408,8 +417,9 @@ HAPI int script_handler_destroy(struct script_info *info)
        }
 
        ret = info->port->destroy(info->port_data);
-       if (ret < 0)
+       if (ret < 0) {
                ErrPrint("Failed to destroy port, but go ahead: %d\n", ret);
+       }
 
        fb_destroy(info->fb);
 
@@ -432,11 +442,13 @@ HAPI struct fb_info *script_handler_fb(struct script_info *info)
 
 HAPI void *script_handler_evas(struct script_info *info)
 {
-       if (!info)
+       if (!info) {
                return NULL;
+       }
 
-       if (!info->ee)
+       if (!info->ee) {
                return NULL;
+       }
 
        return ecore_evas_get(info->ee);
 }
@@ -463,10 +475,11 @@ static int update_script_color(struct inst_info *inst, struct block *block, int
        }
 
        e = script_handler_evas(info);
-       if (e)
+       if (e) {
                info->port->update_color(info->port_data, e, block->id, block->part, block->data);
-       else
+       } else {
                ErrPrint("Evas(nil) id[%s] part[%s] data[%s]\n", block->id, block->part, block->data);
+       }
 
        return LB_STATUS_SUCCESS;
 }
@@ -493,10 +506,11 @@ static int update_script_text(struct inst_info *inst, struct block *block, int i
        }
 
        e = script_handler_evas(info);
-       if (e)
+       if (e) {
                info->port->update_text(info->port_data, e, block->id, block->part, block->data);
-       else
+       } else {
                ErrPrint("Evas(nil) id[%s] part[%s] data[%s]\n", block->id, block->part, block->data);
+       }
        return LB_STATUS_SUCCESS;
 }
 
@@ -522,10 +536,11 @@ static int update_script_image(struct inst_info *inst, struct block *block, int
        }
 
        e = script_handler_evas(info);
-       if (e)
+       if (e) {
                info->port->update_image(info->port_data, e, block->id, block->part, block->data, block->option);
-       else
+       } else {
                ErrPrint("Evas: (nil) id[%s] part[%s] data[%s]\n", block->id, block->part, block->data);
+       }
        return LB_STATUS_SUCCESS;
 }
 
@@ -551,10 +566,11 @@ static int update_access(struct inst_info *inst, struct block *block, int is_pd)
        }
 
        e = script_handler_evas(info);
-       if (e)
+       if (e) {
                info->port->update_access(info->port_data, e, block->id, block->part, block->data, block->option);
-       else
+       } else {
                ErrPrint("Evas: (nil) id[%s] part[%s] data[%s]\n", block->id, block->part, block->data);
+       }
        return LB_STATUS_SUCCESS;
 }
 
@@ -580,11 +596,12 @@ static int update_script_script(struct inst_info *inst, struct block *block, int
        }
 
        e = script_handler_evas(info);
-       if (e)
+       if (e) {
                info->port->update_script(info->port_data, e, block->id, block->target_id, block->part, block->data, block->option);
-       else
+       } else {
                ErrPrint("Evas: (nil) id[%s] part[%s] data[%s] option[%s]\n",
                                                block->id, block->part, block->data, block->option);
+       }
        return LB_STATUS_SUCCESS;
 }
 
@@ -610,10 +627,11 @@ static int update_script_signal(struct inst_info *inst, struct block *block, int
        }
 
        e = script_handler_evas(info);
-       if (e)
+       if (e) {
                info->port->update_signal(info->port_data, e, block->id, block->part, block->data);
-       else
+       } else {
                ErrPrint("Evas(nil) id[%s] part[%s] data[%s]\n", block->id, block->part, block->data);
+       }
        return LB_STATUS_SUCCESS;
 }
 
@@ -645,10 +663,11 @@ static int update_script_drag(struct inst_info *inst, struct block *block, int i
        }
 
        e = script_handler_evas(info);
-       if (e)
+       if (e) {
                info->port->update_drag(info->port_data, e, block->id, block->part, dx, dy);
-       else
+       } else {
                ErrPrint("Evas(nil) id[%s] part[%s] %lfx%lf\n", block->id, block->part, dx, dy);
+       }
        return LB_STATUS_SUCCESS;
 }
 
@@ -665,10 +684,11 @@ HAPI int script_handler_resize(struct script_info *info, int w, int h)
        if (info->port->update_size) {
                Evas *e;
                e = script_handler_evas(info);
-               if (e)
+               if (e) {
                        info->port->update_size(info->port_data, e, NULL , w, h);
-               else
+               } else {
                        ErrPrint("Evas(nil) resize to %dx%d\n", w, h);
+               }
        }
 
        if (instance_lb_script(info->inst) == info) {
@@ -718,18 +738,20 @@ static int update_info(struct inst_info *inst, struct block *block, int is_pd)
                } else {
                        Evas *e;
                        e = script_handler_evas(info);
-                       if (e)
+                       if (e) {
                                info->port->update_size(info->port_data, e, block->id, w, h);
-                       else
+                       } else {
                                ErrPrint("Evas(nil): id[%s] %dx%d\n", block->id, w, h);
+                       }
                }
        } else if (!strcasecmp(block->part, INFO_CATEGORY)) {
                Evas *e;
                e = script_handler_evas(info);
-               if (e)
+               if (e) {
                        info->port->update_category(info->port_data, e, block->id, block->data);
-               else
+               } else {
                        ErrPrint("Evas(nil): id[%s] data[%s]\n", block->id, block->data);
+               }
        }
 
        return LB_STATUS_SUCCESS;
@@ -801,8 +823,9 @@ static inline void consuming_parsed_block(int lineno, struct inst_info *inst, in
                        i++;
                }
 
-               if (!handlers[i].type)
+               if (!handlers[i].type) {
                        ErrPrint("%d: Unknown block type: %s\n", lineno, block->type);
+               }
 
                goto free_out;
        } else {
@@ -874,8 +897,9 @@ HAPI int script_handler_parse_desc(const char *pkgname, const char *id, const ch
        block = NULL;
        while (!feof(fp)) {
                ch = getc(fp);
-               if (ch == '\n')
+               if (ch == '\n') {
                        lineno++;
+               }
 
                switch (state) {
                case UNKNOWN:
@@ -886,15 +910,17 @@ HAPI int script_handler_parse_desc(const char *pkgname, const char *id, const ch
 
                        if (!isspace(ch) && ch != EOF) {
                                ErrPrint("%d: Syntax error: Desc is not started with '{' or space - (%c = 0x%x)\n", lineno, ch, ch);
-                               if (fclose(fp) != 0)
+                               if (fclose(fp) != 0) {
                                        ErrPrint("fclose: %s\n", strerror(errno));
+                               }
                                return LB_STATUS_ERROR_INVALID;
                        }
                        break;
 
                case BLOCK_OPEN:
-                       if (isblank(ch))
+                       if (isblank(ch)) {
                                break;
+                       }
 
                        if (ch != '\n') {
                                ErrPrint("%d: Syntax error: New line must has to be started right after '{'\n", lineno);
@@ -904,8 +930,9 @@ HAPI int script_handler_parse_desc(const char *pkgname, const char *id, const ch
                        block = calloc(1, sizeof(*block));
                        if (!block) {
                                ErrPrint("Heap: %s\n", strerror(errno));
-                               if (fclose(fp) != 0)
+                               if (fclose(fp) != 0) {
                                        ErrPrint("fclose: %s\n", strerror(errno));
+                               }
                                return LB_STATUS_ERROR_MEMORY;
                        }
 
@@ -915,8 +942,9 @@ HAPI int script_handler_parse_desc(const char *pkgname, const char *id, const ch
                        break;
 
                case FIELD:
-                       if (isspace(ch))
+                       if (isspace(ch)) {
                                break;
+                       }
 
                        if (ch == '}') {
                                state = BLOCK_CLOSE;
@@ -1001,16 +1029,19 @@ HAPI int script_handler_parse_desc(const char *pkgname, const char *id, const ch
                                break;
                        }
 
-                       if (ch == '\n')
+                       if (ch == '\n') {
                                goto errout;
+                       }
 
                        if (field_name[field_idx][idx] != ch) {
                                ungetc(ch, fp);
-                               if (ch == '\n')
+                               if (ch == '\n') {
                                        lineno--;
+                               }
 
-                               while (--idx >= 0)
+                               while (--idx >= 0) {
                                        ungetc(field_name[field_idx][idx], fp);
+                               }
 
                                field_idx++;
                                if (field_name[field_idx] == NULL) {
@@ -1214,16 +1245,19 @@ HAPI int script_handler_parse_desc(const char *pkgname, const char *id, const ch
                goto errout;
        }
 
-       if (fclose(fp) != 0)
+       if (fclose(fp) != 0) {
                ErrPrint("fclose: %s\n", strerror(errno));
+       }
        return LB_STATUS_SUCCESS;
 
 errout:
        ErrPrint("Parse error at %d file %s\n", lineno, util_basename(descfile));
-       if (block)
+       if (block) {
                delete_block(block);
-       if (fclose(fp) != 0)
+       }
+       if (fclose(fp) != 0) {
                ErrPrint("fclose: %s\n", strerror(errno));
+       }
        return LB_STATUS_ERROR_INVALID;
 }
 
@@ -1235,10 +1269,11 @@ HAPI int script_init(void)
        char *path;
        int pathlen;
 
-       if (!strcasecmp(PROVIDER_METHOD, "shm"))
+       if (!strcasecmp(PROVIDER_METHOD, "shm")) {
                s_info.env_buf_type = BUFFER_TYPE_SHM;
-       else if (!strcasecmp(PROVIDER_METHOD, "pixmap"))
+       } else if (!strcasecmp(PROVIDER_METHOD, "pixmap")) {
                s_info.env_buf_type = BUFFER_TYPE_PIXMAP;
+       }
 
        dir = opendir(SCRIPT_PORT_PATH);
        if (!dir) {
@@ -1247,15 +1282,17 @@ HAPI int script_init(void)
        }
 
        while ((ent = readdir(dir))) {
-               if (ent->d_name[0] == '.')
+               if (ent->d_name[0] == '.') {
                        continue;
+               }
 
                pathlen = strlen(ent->d_name) + strlen(SCRIPT_PORT_PATH) + 1;
                path = malloc(pathlen);
                if (!path) {
                        ErrPrint("Heap: %s %d\n", strerror(errno), pathlen);
-                       if (closedir(dir) < 0)
+                       if (closedir(dir) < 0) {
                                ErrPrint("closedir: %s\n", strerror(errno));
+                       }
                        return LB_STATUS_ERROR_MEMORY;
                }
 
@@ -1265,8 +1302,9 @@ HAPI int script_init(void)
                if (!item) {
                        ErrPrint("Heap: %s\n", strerror(errno));
                        DbgFree(path);
-                       if (closedir(dir) < 0)
+                       if (closedir(dir) < 0) {
                                ErrPrint("closedir: %s\n", strerror(errno));
+                       }
                        return LB_STATUS_ERROR_MEMORY;
                }
 
@@ -1276,80 +1314,98 @@ HAPI int script_init(void)
                if (!item->handle) {
                        ErrPrint("Error: %s\n", dlerror());
                        DbgFree(item);
-                       if (closedir(dir) < 0)
+                       if (closedir(dir) < 0) {
                                ErrPrint("closedir: %s\n", strerror(errno));
+                       }
                        return LB_STATUS_ERROR_FAULT;
                }
 
                item->magic_id = dlsym(item->handle, "script_magic_id");
-               if (!item->magic_id)
+               if (!item->magic_id) {
                        goto errout;
+               }
 
                DbgPrint("SCRIPT PORT magic id: %s\n", item->magic_id());
 
                item->update_color = dlsym(item->handle, "script_update_color");
-               if (!item->update_color)
+               if (!item->update_color) {
                        goto errout;
+               }
 
                item->update_text = dlsym(item->handle, "script_update_text");
-               if (!item->update_text)
+               if (!item->update_text) {
                        goto errout;
+               }
 
                item->update_image = dlsym(item->handle, "script_update_image");
-               if (!item->update_image)
+               if (!item->update_image) {
                        goto errout;
+               }
 
                item->update_access = dlsym(item->handle, "script_update_access");
-               if (!item->update_access)
+               if (!item->update_access) {
                        goto errout;
+               }
 
                item->update_script = dlsym(item->handle, "script_update_script");
-               if (!item->update_script)
+               if (!item->update_script) {
                        goto errout;
+               }
 
                item->update_signal = dlsym(item->handle, "script_update_signal");
-               if (!item->update_signal)
+               if (!item->update_signal) {
                        goto errout;
+               }
 
                item->update_drag = dlsym(item->handle, "script_update_drag");
-               if (!item->update_drag)
+               if (!item->update_drag) {
                        goto errout;
+               }
 
                item->update_size = dlsym(item->handle, "script_update_size");
-               if (!item->update_size)
+               if (!item->update_size) {
                        goto errout;
+               }
 
                item->update_category = dlsym(item->handle, "script_update_category");
-               if (!item->update_category)
+               if (!item->update_category) {
                        goto errout;
+               }
 
                item->create = dlsym(item->handle, "script_create");
-               if (!item->create)
+               if (!item->create) {
                        goto errout;
+               }
 
                item->destroy = dlsym(item->handle, "script_destroy");
-               if (!item->destroy)
+               if (!item->destroy) {
                        goto errout;
+               }
 
                item->load = dlsym(item->handle, "script_load");
-               if (!item->load)
+               if (!item->load) {
                        goto errout;
+               }
 
                item->unload = dlsym(item->handle, "script_unload");
-               if (!item->unload)
+               if (!item->unload) {
                        goto errout;
+               }
 
                item->init = dlsym(item->handle, "script_init");
-               if (!item->init)
+               if (!item->init) {
                        goto errout;
+               }
 
                item->fini = dlsym(item->handle, "script_fini");
-               if (!item->fini)
+               if (!item->fini) {
                        goto errout;
+               }
 
                item->feed_event = dlsym(item->handle, "script_feed_event");
-               if (!item->feed_event)
+               if (!item->feed_event) {
                        goto errout;
+               }
 
                if (item->init() < 0) {
                        ErrPrint("Failed to initialize script engine\n");
@@ -1359,18 +1415,21 @@ HAPI int script_init(void)
                s_info.script_port_list = eina_list_append(s_info.script_port_list, item);
        }
 
-       if (closedir(dir) < 0)
+       if (closedir(dir) < 0) {
                ErrPrint("closedir: %s\n", strerror(errno));
+       }
 
        return LB_STATUS_SUCCESS;
 
 errout:
        ErrPrint("Error: %s\n", dlerror());
-       if (dlclose(item->handle) != 0)
+       if (dlclose(item->handle) != 0) {
                ErrPrint("dlclose: %s\n", strerror(errno));
+       }
        DbgFree(item);
-       if (closedir(dir) < 0)
+       if (closedir(dir) < 0) {
                ErrPrint("closedir: %s\n", strerror(errno));
+       }
        return LB_STATUS_ERROR_FAULT;
 }
 
@@ -1382,8 +1441,9 @@ HAPI int script_fini(void)
         */
        EINA_LIST_FREE(s_info.script_port_list, item) {
                item->fini();
-               if (dlclose(item->handle) != 0)
+               if (dlclose(item->handle) != 0) {
                        ErrPrint("dlclose: %s\n", strerror(errno));
+               }
                DbgFree(item);
        }
 
@@ -1392,16 +1452,18 @@ HAPI int script_fini(void)
 
 HAPI int script_handler_update_pointer(struct script_info *info, int x, int y, int down)
 {
-       if (!info)
+       if (!info) {
                return LB_STATUS_SUCCESS;
+       }
 
        info->x = x;
        info->y = y;
 
-       if (down == 0)
+       if (down == 0) {
                info->down = 0;
-       else if (down == 1)
+       } else if (down == 1) {
                info->down = 1;
+       }
 
        return LB_STATUS_SUCCESS;
 }
index 365d06b..8032cb7 100644 (file)
@@ -307,12 +307,14 @@ static int event_lb_route_cb(enum event_state state, struct event_data *event_in
        const char *cmdstr;
 
        pkg = instance_package(inst);
-       if (!pkg)
+       if (!pkg) {
                return LB_STATUS_ERROR_INVALID;
+       }
 
        slave = package_slave(pkg);
-       if (!slave)
+       if (!slave) {
                return LB_STATUS_ERROR_INVALID;
+       }
 
        switch (state) {
        case EVENT_STATE_ACTIVATE:
@@ -329,8 +331,9 @@ static int event_lb_route_cb(enum event_state state, struct event_data *event_in
        }
 
        packet = packet_create_noack(cmdstr, "ssdii", package_name(pkg), instance_id(inst), util_timestamp(), event_info->x, event_info->y);
-       if (!packet)
+       if (!packet) {
                return LB_STATUS_ERROR_FAULT;
+       }
 
        return slave_rpc_request_only(slave, package_name(pkg), packet, 0);
 }
@@ -344,16 +347,19 @@ static int event_lb_consume_cb(enum event_state state, struct event_data *event_
        Evas *e;
 
        pkg = instance_package(inst);
-       if (!pkg)
+       if (!pkg) {
                return 0;
+       }
 
        script = instance_lb_script(inst);
-       if (!script)
+       if (!script) {
                return LB_STATUS_ERROR_FAULT;
+       }
 
        e = script_handler_evas(script);
-       if (!e)
+       if (!e) {
                return LB_STATUS_ERROR_FAULT;
+       }
 
        timestamp = util_timestamp();
 
@@ -386,12 +392,14 @@ static int event_pd_route_cb(enum event_state state, struct event_data *event_in
        const char *cmdstr;
 
        pkg = instance_package(inst);
-       if (!pkg)
+       if (!pkg) {
                return LB_STATUS_ERROR_INVALID;
+       }
 
        slave = package_slave(pkg);
-       if (!slave)
+       if (!slave) {
                return LB_STATUS_ERROR_INVALID;
+       }
 
        switch (state) {
        case EVENT_STATE_ACTIVATE:
@@ -408,8 +416,9 @@ static int event_pd_route_cb(enum event_state state, struct event_data *event_in
        }
 
        packet = packet_create_noack(cmdstr, "ssdii", package_name(pkg), instance_id(inst), util_timestamp(), event_info->x, event_info->y);
-       if (!packet)
+       if (!packet) {
                return LB_STATUS_ERROR_FAULT;
+       }
 
        return slave_rpc_request_only(slave, package_name(pkg), packet, 0);
 }
@@ -423,16 +432,19 @@ static int event_pd_consume_cb(enum event_state state, struct event_data *event_
        Evas *e;
 
        pkg = instance_package(inst);
-       if (!pkg)
+       if (!pkg) {
                return 0;
+       }
 
        script = instance_pd_script(inst);
-       if (!script)
+       if (!script) {
                return LB_STATUS_ERROR_FAULT;
+       }
 
        e = script_handler_evas(script);
-       if (!e)
+       if (!e) {
                return LB_STATUS_ERROR_FAULT;
+       }
 
        timestamp = util_timestamp();
 
@@ -488,8 +500,9 @@ static struct packet *client_acquire(pid_t pid, int handle, const struct packet
 
 out:
        result = packet_create_reply(packet, "i", ret);
-       if (!result)
+       if (!result) {
                ErrPrint("Failed to create a packet\n");
+       }
 
        return result;
 }
@@ -512,8 +525,9 @@ static struct packet *cilent_release(pid_t pid, int handle, const struct packet
 
 out:
        result = packet_create_reply(packet, "i", ret);
-       if (!result)
+       if (!result) {
                ErrPrint("Failed to create a packet\n");
+       }
 
        return result;
 }
@@ -540,11 +554,13 @@ static inline int validate_request(const char *pkgname, const char *id, struct i
                return LB_STATUS_ERROR_FAULT;
        }
 
-       if (out_inst)
+       if (out_inst) {
                *out_inst = inst;
+       }
 
-       if (out_pkg)
+       if (out_pkg) {
                *out_pkg = pkg;
+       }
 
        return LB_STATUS_SUCCESS;
 }
@@ -580,8 +596,9 @@ static struct packet *client_clicked(pid_t pid, int handle, const struct packet
         * The package has to be a livebox package name.
         */
        ret = validate_request(pkgname, id, &inst, NULL);
-       if (ret == LB_STATUS_SUCCESS)
+       if (ret == LB_STATUS_SUCCESS) {
                (void)instance_clicked(inst, event, timestamp, x, y);
+       }
 
 out:
        /*! \note No reply packet */
@@ -623,8 +640,9 @@ static struct packet *client_update_mode(pid_t pid, int handle, const struct pac
 
 out:
        result = packet_create_reply(packet, "i", ret);
-       if (!result)
+       if (!result) {
                ErrPrint("Failed to create a packet\n");
+       }
 
        return result;
 }
@@ -665,13 +683,15 @@ static struct packet *client_text_signal(pid_t pid, int handle, const struct pac
         * The package has to be a livebox package name.
         */
        ret = validate_request(pkgname, id, &inst, NULL);
-       if (ret == LB_STATUS_SUCCESS)
+       if (ret == LB_STATUS_SUCCESS) {
                ret = instance_text_signal_emit(inst, emission, source, sx, sy, ex, ey);
+       }
 
 out:
        result = packet_create_reply(packet, "i", ret);
-       if (!result)
+       if (!result) {
                ErrPrint("Failed to create a packet\n");
+       }
 
        return result;
 }
@@ -724,8 +744,9 @@ static struct packet *client_delete(pid_t pid, int handle, const struct packet *
         * The package has to be a livebox package name.
         */
        ret = validate_request(pkgname, id, &inst, NULL);
-       if (ret != LB_STATUS_SUCCESS)
+       if (ret != LB_STATUS_SUCCESS) {
                goto out;
+       }
 
        if (instance_client(inst) != client) {
                if (instance_has_client(inst, client)) {
@@ -768,8 +789,9 @@ static struct packet *client_delete(pid_t pid, int handle, const struct packet *
 
 out:
        result = packet_create_reply(packet, "i", ret);
-       if (!result)
+       if (!result) {
                ErrPrint("Failed to create a packet\n");
+       }
 
        return result;
 }
@@ -807,18 +829,21 @@ static struct packet *client_resize(pid_t pid, int handle, const struct packet *
         * The package has to be a livebox package name.
         */
        ret = validate_request(pkgname, id, &inst, NULL);
-       if (ret != LB_STATUS_SUCCESS)
+       if (ret != LB_STATUS_SUCCESS) {
                goto out;
+       }
 
-       if (instance_client(inst) != client)
+       if (instance_client(inst) != client) {
                ret = LB_STATUS_ERROR_PERMISSION;
-       else
+       } else {
                ret = instance_resize(inst, w, h);
+       }
 
 out:
        result = packet_create_reply(packet, "i", ret);
-       if (!result)
+       if (!result) {
                ErrPrint("Failed to create a packet\n");
+       }
 
        return result;
 }
@@ -874,8 +899,9 @@ static struct packet *client_new(pid_t pid, int handle, const struct packet *pac
        DbgFree(mainappid);
 
        info = package_find(lb_pkgname);
-       if (!info)
+       if (!info) {
                info = package_create(lb_pkgname);
+       }
 
        if (!info) {
                ret = LB_STATUS_ERROR_FAULT;
@@ -887,8 +913,9 @@ static struct packet *client_new(pid_t pid, int handle, const struct packet *pac
        } else {
                struct inst_info *inst;
 
-               if (period > 0.0f && period < MINIMUM_PERIOD)
+               if (period > 0.0f && period < MINIMUM_PERIOD) {
                        period = MINIMUM_PERIOD;
+               }
 
                inst = instance_create(client, timestamp, lb_pkgname, content, cluster, category, period, width, height);
                /*!
@@ -902,8 +929,9 @@ static struct packet *client_new(pid_t pid, int handle, const struct packet *pac
 
 out:
        result = packet_create_reply(packet, "i", ret);
-       if (!result)
+       if (!result) {
                ErrPrint("Failed to create a packet\n");
+       }
 
        return result;
 }
@@ -937,13 +965,15 @@ static struct packet *client_change_visibility(pid_t pid, int handle, const stru
         * The package has to be a livebox package name.
         */
        ret = validate_request(pkgname, id, &inst, NULL);
-       if (ret != LB_STATUS_SUCCESS)
+       if (ret != LB_STATUS_SUCCESS) {
                goto out;
+       }
 
-       if (instance_client(inst) != client)
+       if (instance_client(inst) != client) {
                ret = LB_STATUS_ERROR_PERMISSION;
-       else
+       } else {
                ret = instance_set_visible_state(inst, state);
+       }
 
 out:
        /*! \note No reply packet */
@@ -982,18 +1012,21 @@ static struct packet *client_set_period(pid_t pid, int handle, const struct pack
         * The package has to be a livebox package name.
         */
        ret = validate_request(pkgname, id, &inst, NULL);
-       if (ret != LB_STATUS_SUCCESS)
+       if (ret != LB_STATUS_SUCCESS) {
                goto out;
+       }
 
-       if (instance_client(inst) != client)
+       if (instance_client(inst) != client) {
                ret = LB_STATUS_ERROR_PERMISSION;
-       else
+       } else {
                ret = instance_set_period(inst, period);
+       }
 
 out:
        result = packet_create_reply(packet, "i", ret);
-       if (!result)
+       if (!result) {
                ErrPrint("Failed to create a packet\n");
+       }
 
        return result;
 }
@@ -1031,18 +1064,21 @@ static struct packet *client_change_group(pid_t pid, int handle, const struct pa
         * The package has to be a livebox package name.
         */
        ret = validate_request(pkgname, id, &inst, NULL);
-       if (ret != LB_STATUS_SUCCESS)
+       if (ret != LB_STATUS_SUCCESS) {
                goto out;
+       }
 
-       if (instance_client(inst) != client)
+       if (instance_client(inst) != client) {
                ret = LB_STATUS_ERROR_PERMISSION;
-       else
+       } else {
                ret = instance_change_group(inst, cluster, category);
+       }
 
 out:
        result = packet_create_reply(packet, "i", ret);
-       if (!result)
+       if (!result) {
                ErrPrint("Failed to create a packet\n");
+       }
 
        return result;
 }
@@ -1074,8 +1110,9 @@ static struct packet *client_pd_mouse_enter(pid_t pid, int handle, const struct
        }
 
        ret = validate_request(pkgname, id, &inst, &pkg);
-       if (ret != LB_STATUS_SUCCESS)
+       if (ret != LB_STATUS_SUCCESS) {
                goto out;
+       }
 
        if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
                ret = forward_pd_event_packet(pkg, inst, packet);
@@ -1135,8 +1172,9 @@ static struct packet *client_pd_mouse_leave(pid_t pid, int handle, const struct
        }
 
        ret = validate_request(pkgname, id, &inst, &pkg);
-       if (ret != LB_STATUS_SUCCESS)
+       if (ret != LB_STATUS_SUCCESS) {
                goto out;
+       }
 
        if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
                ret = forward_pd_event_packet(pkg, inst, packet);
@@ -1196,8 +1234,9 @@ static struct packet *client_pd_mouse_down(pid_t pid, int handle, const struct p
        }
 
        ret = validate_request(pkgname, id, &inst, &pkg);
-       if (ret != LB_STATUS_SUCCESS)
+       if (ret != LB_STATUS_SUCCESS) {
                goto out;
+       }
 
        if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
                ret = forward_pd_event_packet(pkg, inst, packet);
@@ -1257,8 +1296,9 @@ static struct packet *client_pd_mouse_up(pid_t pid, int handle, const struct pac
        }
 
        ret = validate_request(pkgname, id, &inst, &pkg);
-       if (ret != LB_STATUS_SUCCESS)
+       if (ret != LB_STATUS_SUCCESS) {
                goto out;
+       }
 
        if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
                ret = forward_pd_event_packet(pkg, inst, packet);
@@ -1318,8 +1358,9 @@ static struct packet *client_pd_mouse_move(pid_t pid, int handle, const struct p
        }
 
        ret = validate_request(pkgname, id, &inst, &pkg);
-       if (ret != LB_STATUS_SUCCESS)
+       if (ret != LB_STATUS_SUCCESS) {
                goto out;
+       }
 
        if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
                ret = forward_pd_event_packet(pkg, inst, packet);
@@ -1379,8 +1420,9 @@ static struct packet *client_lb_mouse_move(pid_t pid, int handle, const struct p
        }
 
        ret = validate_request(pkgname, id, &inst, &pkg);
-       if (ret != LB_STATUS_SUCCESS)
+       if (ret != LB_STATUS_SUCCESS) {
                goto out;
+       }
 
        if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
                ret = forward_lb_event_packet(pkg, inst, packet);
@@ -1446,27 +1488,32 @@ static struct packet *client_lb_mouse_set(pid_t pid, int handle, const struct pa
        }
 
        ret = validate_request(pkgname, id, &inst, &pkg);
-       if (ret != LB_STATUS_SUCCESS)
+       if (ret != LB_STATUS_SUCCESS) {
                goto out;
+       }
 
        if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
                if (event_is_activated()) {
-                       if (event_deactivate() == 0)
+                       if (event_deactivate() == 0) {
                                instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
+                       }
                }
 
                ret = event_activate(x, y, event_lb_route_cb, inst);
-               if (ret == 0)
+               if (ret == 0) {
                        instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, NULL);
+               }
        } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
                if (event_is_activated()) {
-                       if (event_deactivate() == 0)
+                       if (event_deactivate() == 0) {
                                instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
+                       }
                }
 
                ret = event_activate(x, y, event_lb_consume_cb, inst);
-               if (ret == 0)
+               if (ret == 0) {
                        instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, NULL);
+               }
        } else {
                ErrPrint("Unsupported package\n");
                ret = LB_STATUS_ERROR_INVALID;
@@ -1502,17 +1549,20 @@ static struct packet *client_lb_mouse_unset(pid_t pid, int handle, const struct
        }
 
        ret = validate_request(pkgname, id, &inst, &pkg);
-       if (ret != LB_STATUS_SUCCESS)
+       if (ret != LB_STATUS_SUCCESS) {
                goto out;
+       }
 
        if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
                ret = event_deactivate();
-               if (ret == 0)
+               if (ret == 0) {
                        instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
+               }
        } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
                ret = event_deactivate();
-               if (ret == 0)
+               if (ret == 0) {
                        instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
+               }
        } else {
                ErrPrint("Unsupported package\n");
                ret = LB_STATUS_ERROR_INVALID;
@@ -1548,27 +1598,32 @@ static struct packet *client_pd_mouse_set(pid_t pid, int handle, const struct pa
        }
 
        ret = validate_request(pkgname, id, &inst, &pkg);
-       if (ret != LB_STATUS_SUCCESS)
+       if (ret != LB_STATUS_SUCCESS) {
                goto out;
+       }
 
        if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
                if (event_is_activated()) {
-                       if (event_deactivate() == 0)
+                       if (event_deactivate() == 0) {
                                instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
+                       }
                }
 
                ret = event_activate(x, y, event_pd_route_cb, inst);
-               if (ret == 0)
+               if (ret == 0) {
                        instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, NULL);
+               }
        } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
                if (event_is_activated()) {
-                       if (event_deactivate() == 0)
+                       if (event_deactivate() == 0) {
                                instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
+                       }
                }
 
                ret = event_activate(x, y, event_pd_consume_cb, inst);
-               if (ret == 0)
+               if (ret == 0) {
                        instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, NULL);
+               }
        } else {
                ErrPrint("Unsupported package\n");
                ret = LB_STATUS_ERROR_INVALID;
@@ -1605,17 +1660,20 @@ static struct packet *client_pd_mouse_unset(pid_t pid, int handle, const struct
        }
 
        ret = validate_request(pkgname, id, &inst, &pkg);
-       if (ret != LB_STATUS_SUCCESS)
+       if (ret != LB_STATUS_SUCCESS) {
                goto out;
+       }
 
        if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
                ret = event_deactivate();
-               if (ret == 0)
+               if (ret == 0) {
                        instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
+               }
        } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
                ret = event_deactivate();
-               if (ret == 0)
+               if (ret == 0) {
                        instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
+               }
        } else {
                ErrPrint("Unsupported package\n");
                ret = LB_STATUS_ERROR_INVALID;
@@ -1651,8 +1709,9 @@ static struct packet *client_lb_mouse_enter(pid_t pid, int handle, const struct
        }
 
        ret = validate_request(pkgname, id, &inst, &pkg);
-       if (ret != LB_STATUS_SUCCESS)
+       if (ret != LB_STATUS_SUCCESS) {
                goto out;
+       }
 
        if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
                ret = forward_lb_event_packet(pkg, inst, packet);
@@ -1712,8 +1771,9 @@ static struct packet *client_lb_mouse_leave(pid_t pid, int handle, const struct
        }
 
        ret = validate_request(pkgname, id, &inst, &pkg);
-       if (ret != LB_STATUS_SUCCESS)
+       if (ret != LB_STATUS_SUCCESS) {
                goto out;
+       }
 
        if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
                ret = forward_lb_event_packet(pkg, inst, packet);
@@ -1773,8 +1833,9 @@ static struct packet *client_lb_mouse_down(pid_t pid, int handle, const struct p
        }
 
        ret = validate_request(pkgname, id, &inst, &pkg);
-       if (ret != LB_STATUS_SUCCESS)
+       if (ret != LB_STATUS_SUCCESS) {
                goto out;
+       }
 
        if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
                ret = forward_lb_event_packet(pkg, inst, packet);
@@ -1834,8 +1895,9 @@ static struct packet *client_lb_mouse_up(pid_t pid, int handle, const struct pac
        }
 
        ret = validate_request(pkgname, id, &inst, &pkg);
-       if (ret != LB_STATUS_SUCCESS)
+       if (ret != LB_STATUS_SUCCESS) {
                goto out;
+       }
 
        if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
                ret = forward_lb_event_packet(pkg, inst, packet);
@@ -1896,8 +1958,9 @@ static struct packet *client_pd_access_action_up(pid_t pid, int handle, const st
        }
 
        ret = validate_request(pkgname, id, &inst, &pkg);
-       if (ret != LB_STATUS_SUCCESS)
+       if (ret != LB_STATUS_SUCCESS) {
                goto out;
+       }
 
        if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
                ret = forward_pd_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
@@ -1945,8 +2008,9 @@ static struct packet *client_pd_access_action_up(pid_t pid, int handle, const st
 
 out:
        result = packet_create_reply(packet, "i", ret);
-       if (!result)
+       if (!result) {
                ErrPrint("Failed to create a reply packet\n");
+       }
 
        return result;
 }
@@ -1979,8 +2043,9 @@ static struct packet *client_pd_access_action_down(pid_t pid, int handle, const
        }
 
        ret = validate_request(pkgname, id, &inst, &pkg);
-       if (ret != LB_STATUS_SUCCESS)
+       if (ret != LB_STATUS_SUCCESS) {
                goto out;
+       }
 
        if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
                ret = forward_pd_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
@@ -2028,8 +2093,9 @@ static struct packet *client_pd_access_action_down(pid_t pid, int handle, const
 
 out:
        result = packet_create_reply(packet, "i", ret);
-       if (!result)
+       if (!result) {
                ErrPrint("Failed to create a reply packet\n");
+       }
 
        return result;
 }
@@ -2062,8 +2128,9 @@ static struct packet *client_pd_access_scroll_down(pid_t pid, int handle, const
        }
 
        ret = validate_request(pkgname, id, &inst, &pkg);
-       if (ret != LB_STATUS_SUCCESS)
+       if (ret != LB_STATUS_SUCCESS) {
                goto out;
+       }
 
        if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
                ret = forward_pd_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
@@ -2111,8 +2178,9 @@ static struct packet *client_pd_access_scroll_down(pid_t pid, int handle, const
 
 out:
        result = packet_create_reply(packet, "i", ret);
-       if (!result)
+       if (!result) {
                ErrPrint("Failed to create a reply packet\n");
+       }
 
        return result;
 }
@@ -2145,8 +2213,9 @@ static struct packet *client_pd_access_scroll_move(pid_t pid, int handle, const
        }
 
        ret = validate_request(pkgname, id, &inst, &pkg);
-       if (ret != LB_STATUS_SUCCESS)
+       if (ret != LB_STATUS_SUCCESS) {
                goto out;
+       }
 
        if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
                ret = forward_pd_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
@@ -2194,8 +2263,9 @@ static struct packet *client_pd_access_scroll_move(pid_t pid, int handle, const
 
 out:
        result = packet_create_reply(packet, "i", ret);
-       if (!result)
+       if (!result) {
                ErrPrint("Failed to create a reply packet\n");
+       }
 
        return result;
 }
@@ -2228,8 +2298,9 @@ static struct packet *client_pd_access_scroll_up(pid_t pid, int handle, const st
        }
 
        ret = validate_request(pkgname, id, &inst, &pkg);
-       if (ret != LB_STATUS_SUCCESS)
+       if (ret != LB_STATUS_SUCCESS) {
                goto out;
+       }
 
        if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
                ret = forward_pd_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
@@ -2277,8 +2348,9 @@ static struct packet *client_pd_access_scroll_up(pid_t pid, int handle, const st
 
 out:
        result = packet_create_reply(packet, "i", ret);
-       if (!result)
+       if (!result) {
                ErrPrint("Failed to create a reply packet\n");
+       }
 
        return result;
 }
@@ -2311,8 +2383,9 @@ static struct packet *client_pd_access_unhighlight(pid_t pid, int handle, const
        }
 
        ret = validate_request(pkgname, id, &inst, &pkg);
-       if (ret != LB_STATUS_SUCCESS)
+       if (ret != LB_STATUS_SUCCESS) {
                goto out;
+       }
 
        if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
                ret = forward_pd_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
@@ -2359,8 +2432,9 @@ static struct packet *client_pd_access_unhighlight(pid_t pid, int handle, const
        }
 out:
        result = packet_create_reply(packet, "i", ret);
-       if (!result)
+       if (!result) {
                ErrPrint("Failed to create a reply packet\n");
+       }
 
        return result;
 }
@@ -2393,8 +2467,9 @@ static struct packet *client_pd_access_hl(pid_t pid, int handle, const struct pa
        }
 
        ret = validate_request(pkgname, id, &inst, &pkg);
-       if (ret != LB_STATUS_SUCCESS)
+       if (ret != LB_STATUS_SUCCESS) {
                goto out;
+       }
 
        if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
                ret = forward_pd_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
@@ -2442,8 +2517,9 @@ static struct packet *client_pd_access_hl(pid_t pid, int handle, const struct pa
 
 out:
        result = packet_create_reply(packet, "i", ret);
-       if (!result)
+       if (!result) {
                ErrPrint("Failed to create a reply packet\n");
+       }
 
        return result;
 }
@@ -2476,8 +2552,9 @@ static struct packet *client_pd_access_hl_prev(pid_t pid, int handle, const stru
        }
 
        ret = validate_request(pkgname, id, &inst, &pkg);
-       if (ret != LB_STATUS_SUCCESS)
+       if (ret != LB_STATUS_SUCCESS) {
                goto out;
+       }
 
        if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
                ret = forward_pd_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
@@ -2525,8 +2602,9 @@ static struct packet *client_pd_access_hl_prev(pid_t pid, int handle, const stru
 
 out:
        result = packet_create_reply(packet, "i", ret);
-       if (!result)
+       if (!result) {
                ErrPrint("Failed to create a reply packet\n");
+       }
 
        return result;
 }
@@ -2559,8 +2637,9 @@ static struct packet *client_pd_access_hl_next(pid_t pid, int handle, const stru
        }
 
        ret = validate_request(pkgname, id, &inst, &pkg);
-       if (ret != LB_STATUS_SUCCESS)
+       if (ret != LB_STATUS_SUCCESS) {
                goto out;
+       }
 
        if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
                ret = forward_pd_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
@@ -2614,8 +2693,9 @@ static struct packet *client_pd_access_hl_next(pid_t pid, int handle, const stru
 
 out:
        result = packet_create_reply(packet, "i", ret);
-       if (!result)
+       if (!result) {
                ErrPrint("Failed to create a reply packet\n");
+       }
 
        return result;
 }
@@ -2648,8 +2728,9 @@ static struct packet *client_pd_access_activate(pid_t pid, int handle, const str
        }
 
        ret = validate_request(pkgname, id, &inst, &pkg);
-       if (ret != LB_STATUS_SUCCESS)
+       if (ret != LB_STATUS_SUCCESS) {
                goto out;
+       }
 
        if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
                ret = forward_pd_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
@@ -2697,8 +2778,9 @@ static struct packet *client_pd_access_activate(pid_t pid, int handle, const str
 
 out:
        result = packet_create_reply(packet, "i", ret);
-       if (!result)
+       if (!result) {
                ErrPrint("Failed to create a reply packet\n");
+       }
 
        return result;
 }
@@ -2730,8 +2812,9 @@ static struct packet *client_pd_key_down(pid_t pid, int handle, const struct pac
        }
 
        ret = validate_request(pkgname, id, &inst, &pkg);
-       if (ret != LB_STATUS_SUCCESS)
+       if (ret != LB_STATUS_SUCCESS) {
                goto out;
+       }
 
        if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
                ret = forward_pd_event_packet(pkg, inst, packet);
@@ -2786,10 +2869,11 @@ static struct packet *client_pause_request(pid_t pid, int handle, const struct p
                goto out;
        }
 
-       if (USE_XMONITOR)
+       if (USE_XMONITOR) {
                DbgPrint("XMONITOR enabled. ignore client paused request\n");
-       else
+       } else {
                xmonitor_pause(client);
+       }
 
 out:
        return NULL;
@@ -2813,10 +2897,11 @@ static struct packet *client_resume_request(pid_t pid, int handle, const struct
                goto out;
        }
 
-       if (USE_XMONITOR)
+       if (USE_XMONITOR) {
                DbgPrint("XMONITOR enabled. ignore client resumed request\n");
-       else
+       } else {
                xmonitor_resume(client);
+       }
 
 out:
        return NULL;
@@ -2849,8 +2934,9 @@ static struct packet *client_pd_key_up(pid_t pid, int handle, const struct packe
        }
 
        ret = validate_request(pkgname, id, &inst, &pkg);
-       if (ret != LB_STATUS_SUCCESS)
+       if (ret != LB_STATUS_SUCCESS) {
                goto out;
+       }
 
        if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
                ret = forward_pd_event_packet(pkg, inst, packet);
@@ -2913,8 +2999,9 @@ static struct packet *client_lb_access_hl(pid_t pid, int handle, const struct pa
        }
 
        ret = validate_request(pkgname, id, &inst, &pkg);
-       if (ret != LB_STATUS_SUCCESS)
+       if (ret != LB_STATUS_SUCCESS) {
                goto out;
+       }
 
        if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
                ret = forward_lb_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
@@ -2962,8 +3049,9 @@ static struct packet *client_lb_access_hl(pid_t pid, int handle, const struct pa
 
 out:
        result = packet_create_reply(packet, "i", ret);
-       if (!result)
+       if (!result) {
                ErrPrint("Failed to create a reply packet\n");
+       }
 
        return result;
 }
@@ -2996,8 +3084,9 @@ static struct packet *client_lb_access_hl_prev(pid_t pid, int handle, const stru
        }
 
        ret = validate_request(pkgname, id, &inst, &pkg);
-       if (ret != LB_STATUS_SUCCESS)
+       if (ret != LB_STATUS_SUCCESS) {
                goto out;
+       }
 
        if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
                ret = forward_lb_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
@@ -3045,8 +3134,9 @@ static struct packet *client_lb_access_hl_prev(pid_t pid, int handle, const stru
 
 out:
        result = packet_create_reply(packet, "i", ret);
-       if (!result)
+       if (!result) {
                ErrPrint("Failed to create a reply packet\n");
+       }
 
        return result;
 }
@@ -3079,8 +3169,9 @@ static struct packet *client_lb_access_hl_next(pid_t pid, int handle, const stru
        }
 
        ret = validate_request(pkgname, id, &inst, &pkg);
-       if (ret != LB_STATUS_SUCCESS)
+       if (ret != LB_STATUS_SUCCESS) {
                goto out;
+       }
 
        if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
                ret = forward_lb_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
@@ -3128,8 +3219,9 @@ static struct packet *client_lb_access_hl_next(pid_t pid, int handle, const stru
 
 out:
        result = packet_create_reply(packet, "i", ret);
-       if (!result)
+       if (!result) {
                ErrPrint("Failed to create a reply packet\n");
+       }
 
        return result;
 }
@@ -3162,8 +3254,9 @@ static struct packet *client_lb_access_action_up(pid_t pid, int handle, const st
        }
 
        ret = validate_request(pkgname, id, &inst, &pkg);
-       if (ret != LB_STATUS_SUCCESS)
+       if (ret != LB_STATUS_SUCCESS) {
                goto out;
+       }
 
        if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
                ret = forward_lb_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
@@ -3218,8 +3311,9 @@ static struct packet *client_lb_access_action_up(pid_t pid, int handle, const st
 
 out:
        result = packet_create_reply(packet, "i", ret);
-       if (!result)
+       if (!result) {
                ErrPrint("Failed to create a reply packet\n");
+       }
 
        return result;
 }
@@ -3252,8 +3346,9 @@ static struct packet *client_lb_access_action_down(pid_t pid, int handle, const
        }
 
        ret = validate_request(pkgname, id, &inst, &pkg);
-       if (ret != LB_STATUS_SUCCESS)
+       if (ret != LB_STATUS_SUCCESS) {
                goto out;
+       }
 
        if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
                ret = forward_lb_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
@@ -3308,8 +3403,9 @@ static struct packet *client_lb_access_action_down(pid_t pid, int handle, const
 
 out:
        result = packet_create_reply(packet, "i", ret);
-       if (!result)
+       if (!result) {
                ErrPrint("Failed to create a reply packet\n");
+       }
 
        return result;
 }
@@ -3342,8 +3438,9 @@ static struct packet *client_lb_access_unhighlight(pid_t pid, int handle, const
        }
 
        ret = validate_request(pkgname, id, &inst, &pkg);
-       if (ret != LB_STATUS_SUCCESS)
+       if (ret != LB_STATUS_SUCCESS) {
                goto out;
+       }
 
        if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
                ret = forward_lb_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
@@ -3391,8 +3488,9 @@ static struct packet *client_lb_access_unhighlight(pid_t pid, int handle, const
 
 out:
        result = packet_create_reply(packet, "i", ret);
-       if (!result)
+       if (!result) {
                ErrPrint("Failed to create a reply packet\n");
+       }
 
        return result;
 }
@@ -3425,8 +3523,9 @@ static struct packet *client_lb_access_scroll_down(pid_t pid, int handle, const
        }
 
        ret = validate_request(pkgname, id, &inst, &pkg);
-       if (ret != LB_STATUS_SUCCESS)
+       if (ret != LB_STATUS_SUCCESS) {
                goto out;
+       }
 
        if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
                ret = forward_lb_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
@@ -3481,8 +3580,9 @@ static struct packet *client_lb_access_scroll_down(pid_t pid, int handle, const
 
 out:
        result = packet_create_reply(packet, "i", ret);
-       if (!result)
+       if (!result) {
                ErrPrint("Failed to create a reply packet\n");
+       }
 
        return result;
 }
@@ -3515,8 +3615,9 @@ static struct packet *client_lb_access_scroll_move(pid_t pid, int handle, const
        }
 
        ret = validate_request(pkgname, id, &inst, &pkg);
-       if (ret != LB_STATUS_SUCCESS)
+       if (ret != LB_STATUS_SUCCESS) {
                goto out;
+       }
 
        if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
                ret = forward_lb_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
@@ -3571,8 +3672,9 @@ static struct packet *client_lb_access_scroll_move(pid_t pid, int handle, const
 
 out:
        result = packet_create_reply(packet, "i", ret);
-       if (!result)
+       if (!result) {
                ErrPrint("Failed to create a reply packet\n");
+       }
 
        return result;
 }
@@ -3605,8 +3707,9 @@ static struct packet *client_lb_access_scroll_up(pid_t pid, int handle, const st
        }
 
        ret = validate_request(pkgname, id, &inst, &pkg);
-       if (ret != LB_STATUS_SUCCESS)
+       if (ret != LB_STATUS_SUCCESS) {
                goto out;
+       }
 
        if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
                ret = forward_lb_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
@@ -3661,8 +3764,9 @@ static struct packet *client_lb_access_scroll_up(pid_t pid, int handle, const st
 
 out:
        result = packet_create_reply(packet, "i", ret);
-       if (!result)
+       if (!result) {
                ErrPrint("Failed to create a reply packet\n");
+       }
 
        return result;
 }
@@ -3695,8 +3799,9 @@ static struct packet *client_lb_access_activate(pid_t pid, int handle, const str
        }
 
        ret = validate_request(pkgname, id, &inst, &pkg);
-       if (ret != LB_STATUS_SUCCESS)
+       if (ret != LB_STATUS_SUCCESS) {
                goto out;
+       }
 
        if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
                ret = forward_lb_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
@@ -3746,8 +3851,9 @@ static struct packet *client_lb_access_activate(pid_t pid, int handle, const str
 
 out:
        result = packet_create_reply(packet, "i", ret);
-       if (!result)
+       if (!result) {
                ErrPrint("Failed to create a reply packet\n");
+       }
 
        return result;
 }
@@ -3779,8 +3885,9 @@ static struct packet *client_lb_key_down(pid_t pid, int handle, const struct pac
        }
 
        ret = validate_request(pkgname, id, &inst, &pkg);
-       if (ret != LB_STATUS_SUCCESS)
+       if (ret != LB_STATUS_SUCCESS) {
                goto out;
+       }
 
        if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
                ret = forward_lb_event_packet(pkg, inst, packet);
@@ -3843,8 +3950,9 @@ static struct packet *client_lb_key_up(pid_t pid, int handle, const struct packe
        }
 
        ret = validate_request(pkgname, id, &inst, &pkg);
-       if (ret != LB_STATUS_SUCCESS)
+       if (ret != LB_STATUS_SUCCESS) {
                goto out;
+       }
 
        if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
                ret = forward_lb_event_packet(pkg, inst, packet);
@@ -3912,8 +4020,9 @@ static struct packet *client_lb_acquire_pixmap(pid_t pid, int handle, const stru
        }
 
        ret = validate_request(pkgname, id, &inst, NULL);
-       if (ret != LB_STATUS_SUCCESS)
+       if (ret != LB_STATUS_SUCCESS) {
                goto out;
+       }
 
        buffer = instance_lb_buffer(inst);
        if (!buffer) {
@@ -3955,8 +4064,9 @@ static struct packet *client_lb_acquire_pixmap(pid_t pid, int handle, const stru
 
 out:
        result = packet_create_reply(packet, "i", pixmap);
-       if (!result)
+       if (!result) {
                ErrPrint("Failed to create a reply packet\n");
+       }
 
        return result;
 }
@@ -3984,8 +4094,9 @@ static struct packet *client_lb_release_pixmap(pid_t pid, int handle, const stru
        }
 
        ret = validate_request(pkgname, id, &inst, NULL);
-       if (ret != LB_STATUS_SUCCESS)
+       if (ret != LB_STATUS_SUCCESS) {
                goto out;
+       }
 
        buf_ptr = buffer_handler_pixmap_find(pixmap);
        if (!buf_ptr) {
@@ -3993,8 +4104,9 @@ static struct packet *client_lb_release_pixmap(pid_t pid, int handle, const stru
                goto out;
        }
 
-       if (client_event_callback_del(client, CLIENT_EVENT_DEACTIVATE, release_pixmap_cb, buf_ptr) == 0)
+       if (client_event_callback_del(client, CLIENT_EVENT_DEACTIVATE, release_pixmap_cb, buf_ptr) == 0) {
                buffer_handler_pixmap_unref(buf_ptr);
+       }
 
 out:
        /*! \note No reply packet */
@@ -4026,8 +4138,9 @@ static struct packet *client_pd_acquire_pixmap(pid_t pid, int handle, const stru
        }
 
        ret = validate_request(pkgname, id, &inst, NULL);
-       if (ret != LB_STATUS_SUCCESS)
+       if (ret != LB_STATUS_SUCCESS) {
                goto out;
+       }
 
        buffer = instance_pd_buffer(inst);
        if (!buffer) {
@@ -4060,14 +4173,16 @@ static struct packet *client_pd_acquire_pixmap(pid_t pid, int handle, const stru
        }
 
        ret = client_event_callback_add(client, CLIENT_EVENT_DEACTIVATE, release_pixmap_cb, buf_ptr);
-       if (ret < 0)
+       if (ret < 0) {
                buffer_handler_pixmap_unref(buf_ptr);
+       }
 
        pixmap = buffer_handler_pixmap(buffer);
 out:
        result = packet_create_reply(packet, "i", pixmap);
-       if (!result)
+       if (!result) {
                ErrPrint("Failed to create a reply packet\n");
+       }
 
        return result;
 }
@@ -4094,8 +4209,9 @@ static struct packet *client_pd_release_pixmap(pid_t pid, int handle, const stru
        }
 
        ret = validate_request(pkgname, id, NULL, NULL);
-       if (ret != LB_STATUS_SUCCESS)
+       if (ret != LB_STATUS_SUCCESS) {
                goto out;
+       }
 
        buf_ptr = buffer_handler_pixmap_find(pixmap);
        if (!buf_ptr) {
@@ -4103,8 +4219,9 @@ static struct packet *client_pd_release_pixmap(pid_t pid, int handle, const stru
                goto out;
        }
 
-       if (client_event_callback_del(client, CLIENT_EVENT_DEACTIVATE, release_pixmap_cb, buf_ptr) == 0)
+       if (client_event_callback_del(client, CLIENT_EVENT_DEACTIVATE, release_pixmap_cb, buf_ptr) == 0) {
                buffer_handler_pixmap_unref(buf_ptr);
+       }
 
 out:
        /*! \note No reply packet */
@@ -4138,13 +4255,15 @@ static struct packet *client_pinup_changed(pid_t pid, int handle, const struct p
        }
 
        ret = validate_request(pkgname, id, &inst, NULL);
-       if (ret == LB_STATUS_SUCCESS)
+       if (ret == LB_STATUS_SUCCESS) {
                ret = instance_set_pinup(inst, pinup);
+       }
 
 out:
        result = packet_create_reply(packet, "i", ret);
-       if (!result)
+       if (!result) {
                ErrPrint("Failed to create a packet\n");
+       }
 
        return result;
 }
@@ -4206,7 +4325,9 @@ static Eina_Bool lazy_pd_destroyed_cb(void *inst)
        if (instance_unref(inst)) {
                int ret;
                ret = instance_client_pd_destroyed(inst, LB_STATUS_SUCCESS);
-               DbgPrint("Send PD Destroy event (%d) to client\n", ret);
+               if (ret < 0) {
+                       ErrPrint("Failed sending PD Destroy event (%d)\n", ret);
+               }
        }
 
        return ECORE_CALLBACK_CANCEL;
@@ -4238,8 +4359,9 @@ static struct packet *client_pd_move(pid_t pid, int handle, const struct packet
        }
 
        ret = validate_request(pkgname, id, &inst, &pkg);
-       if (ret != LB_STATUS_SUCCESS)
+       if (ret != LB_STATUS_SUCCESS) {
                goto out;
+       }
 
        if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
                instance_slave_set_pd_pos(inst, x, y);
@@ -4359,8 +4481,9 @@ static struct packet *client_create_pd(pid_t pid, int handle, const struct packe
        }
 
        ret = validate_request(pkgname, id, &inst, &pkg);
-       if (ret != LB_STATUS_SUCCESS)
+       if (ret != LB_STATUS_SUCCESS) {
                goto out;
+       }
 
        if (instance_pd_owner(inst)) {
                ErrPrint("PD is already owned\n");
@@ -4496,17 +4619,19 @@ static struct packet *client_create_pd(pid_t pid, int handle, const struct packe
                                 */
                                pd_monitor = ecore_timer_add(DELAY_TIME, lazy_pd_created_cb, inst);
                                if (!pd_monitor) {
-                                       struct inst_info *tmp_inst;
-
-                                       tmp_inst = instance_unref(inst);
-                                       ErrPrint("Instance: %p (%s)\n", tmp_inst, pkgname);
-
                                        ret = script_handler_unload(instance_pd_script(inst), 1);
                                        ErrPrint("Unload script: %d\n", ret);
 
                                        ret = instance_slave_close_pd(inst, client);
                                        ErrPrint("Close PD %d\n", ret);
 
+                                       inst = instance_unref(inst);
+                                       if (!inst) {
+                                               DbgPrint("Instance destroyed\n");
+                                       }
+
+                                       ErrPrint("Instance: %s\n", pkgname);
+
                                        ret = LB_STATUS_ERROR_FAULT;
                                } else {
                                        struct slave_node *slave;
@@ -4538,8 +4663,9 @@ static struct packet *client_create_pd(pid_t pid, int handle, const struct packe
 
 out:
        result = packet_create_reply(packet, "i", ret);
-       if (!result)
+       if (!result) {
                ErrPrint("Failed to create a packet\n");
+       }
 
        return result;
 }
@@ -4573,8 +4699,9 @@ static struct packet *client_destroy_pd(pid_t pid, int handle, const struct pack
        }
 
        ret = validate_request(pkgname, id, &inst, &pkg);
-       if (ret != LB_STATUS_SUCCESS)
+       if (ret != LB_STATUS_SUCCESS) {
                goto out;
+       }
 
        slave = package_slave(pkg);
        if (!slave) {
@@ -4610,20 +4737,24 @@ static struct packet *client_destroy_pd(pid_t pid, int handle, const struct pack
                         */
                        ret = LB_STATUS_ERROR_CANCEL;
                        ret = instance_client_pd_created(inst, ret);
-                       if (ret < 0)
+                       if (ret < 0) {
                                ErrPrint("PD client create event: %d\n", ret);
+                       }
 
                        ret = instance_client_pd_destroyed(inst, LB_STATUS_SUCCESS);
-                       if (ret < 0)
+                       if (ret < 0) {
                                ErrPrint("PD client destroy event: %d\n", ret);
+                       }
 
                        ret = instance_signal_emit(inst, "pd,hide", instance_id(inst), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0);
-                       if (ret < 0)
+                       if (ret < 0) {
                                ErrPrint("PD close signal emit failed: %d\n", ret);
+                       }
 
                        ret = instance_slave_close_pd(inst, client);
-                       if (ret < 0)
+                       if (ret < 0) {
                                ErrPrint("PD close request failed: %d\n", ret);
+                       }
 
                        ecore_timer_del(pd_monitor);
                        (void)instance_unref(inst);
@@ -4643,15 +4774,17 @@ static struct packet *client_destroy_pd(pid_t pid, int handle, const struct pack
                        ecore_timer_del(pd_monitor);
 
                        inst = instance_unref(inst);
-                       if (!inst)
+                       if (!inst) {
                                goto out;
+                       }
 
                        resize_aborted = 1;
                }
 
                ret = instance_signal_emit(inst, "pd,hide", instance_id(inst), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0);
-               if (ret < 0)
+               if (ret < 0) {
                        ErrPrint("PD close signal emit failed: %d\n", ret);
+               }
 
                ret = instance_slave_close_pd(inst, client);
                if (ret < 0) {
@@ -4690,8 +4823,9 @@ static struct packet *client_destroy_pd(pid_t pid, int handle, const struct pack
                }
 
                ret = script_handler_unload(instance_pd_script(inst), 1);
-               if (ret < 0)
+               if (ret < 0) {
                        ErrPrint("Unable to unload the script: %s, %d\n", pkgname, ret);
+               }
 
                /*!
                 * \note
@@ -4699,8 +4833,9 @@ static struct packet *client_destroy_pd(pid_t pid, int handle, const struct pack
                 * The SLAVE must has to repsonse this via "release_buffer" method.
                 */
                ret = instance_slave_close_pd(inst, client);
-               if (ret < 0)
+               if (ret < 0) {
                        ErrPrint("Unable to close the PD: %s, %d\n", pkgname, ret);
+               }
 
                /*!
                 * \note
@@ -4730,8 +4865,9 @@ static struct packet *client_destroy_pd(pid_t pid, int handle, const struct pack
 
 out:
        result = packet_create_reply(packet, "i", ret);
-       if (!result)
+       if (!result) {
                ErrPrint("Failed to create a packet\n");
+       }
 
        return result;
 }
@@ -4774,15 +4910,17 @@ static struct packet *client_activate_package(pid_t pid, int handle, const struc
        }
 
        info = package_find(pkgname);
-       if (!info)
+       if (!info) {
                ret = LB_STATUS_ERROR_NOT_EXIST;
-       else
+       } else {
                ret = package_clear_fault(info);
+       }
 
 out:
        result = packet_create_reply(packet, "is", ret, pkgname);
-       if (!result)
+       if (!result) {
                ErrPrint("Failed to create a packet\n");
+       }
 
        return result;
 }
@@ -4819,8 +4957,9 @@ static struct packet *client_subscribed(pid_t pid, int handle, const struct pack
         * SUBSCRIBE cluster & sub-cluster for a client.
         */
        ret = client_subscribe(client, cluster, category);
-       if (ret == 0)
+       if (ret == 0) {
                package_alter_instances_to_client(client, ALTER_CREATE);
+       }
 
 out:
        /*! \note No reply packet */
@@ -4863,8 +5002,10 @@ static struct packet *client_delete_cluster(pid_t pid, int handle, const struct
 
 out:
        result = packet_create_reply(packet, "i", ret);
-       if (!result)
+       if (!result) {
                ErrPrint("Failed to create a packet\n");
+       }
+
        return result;
 }
 
@@ -4897,8 +5038,9 @@ static inline int update_pkg_cb(struct category *category, const char *pkgname)
                 * It means. some clients wants to handle this instances ;)
                 */
                inst = instance_create(NULL, timestamp, pkgname, "", c_name, s_name, DEFAULT_PERIOD, 0, 0);
-               if (!inst)
+               if (!inst) {
                        ErrPrint("Failed to create a new instance\n");
+               }
        } else {
                ErrPrint("Not enough space\n");
        }
@@ -4926,8 +5068,9 @@ static struct packet *client_update(pid_t pid, int handle, const struct packet *
        }
 
        ret = validate_request(pkgname, id, &inst, NULL);
-       if (ret != LB_STATUS_SUCCESS)
+       if (ret != LB_STATUS_SUCCESS) {
                goto out;
+       }
 
        if (instance_client(inst) != client) {
                /* PERMISSIONS */
@@ -5030,8 +5173,10 @@ static struct packet *client_delete_category(pid_t pid, int handle, const struct
 
 out:
        result = packet_create_reply(packet, "i", ret);
-       if (!result)
+       if (!result) {
                ErrPrint("Failed to create a packet\n");
+       }
+
        return result;
 }
 
@@ -5068,8 +5213,9 @@ static struct packet *client_unsubscribed(pid_t pid, int handle, const struct pa
         * UNSUBSCRIBE cluster & sub-cluster for a client.
         */
        ret = client_unsubscribe(client, cluster, category);
-       if (ret == 0)
+       if (ret == 0) {
                package_alter_instances_to_client(client, ALTER_DESTROY);
+       }
 
 out:
        /*! \note No reply packet */
@@ -5092,8 +5238,9 @@ static struct packet *slave_hello(pid_t pid, int handle, const struct packet *pa
 
        slave = slave_find_by_name(slavename);
 
-       if (!slave) /* Try again to find a slave using pid */
+       if (!slave) /* Try again to find a slave using pid */
                slave = slave_find_by_pid(pid);
+       }
 
        if (!slave) {
                if (DEBUG_MODE) {
@@ -5125,6 +5272,10 @@ static struct packet *slave_hello(pid_t pid, int handle, const struct packet *pa
                        } else {
                                DbgPrint("Registered slave is replaced with this new one\n");
                                abi = slave_abi(slave);
+                               if (!abi) {
+                                       ErrPrint("ABI is not valid: %s\n", slavename);
+                                       abi = DEFAULT_ABI;
+                               }
                        }
 
                        slave_set_pid(slave, pid);
@@ -5172,10 +5323,11 @@ static struct packet *slave_ping(pid_t pid, int handle, const struct packet *pac
        }
 
        ret = packet_get(packet, "s", &slavename);
-       if (ret != 1)
+       if (ret != 1) {
                ErrPrint("Parameter is not matched\n");
-       else
+       } else {
                slave_rpc_ping(slave);
+       }
 
 out:
        return NULL;
@@ -5243,8 +5395,9 @@ static struct packet *slave_lb_update_begin(pid_t pid, int handle, const struct
        }
 
        ret = validate_request(pkgname, id, &inst, &pkg);
-       if (ret != LB_STATUS_SUCCESS)
+       if (ret != LB_STATUS_SUCCESS) {
                goto out;
+       }
 
        if (instance_state(inst) == INST_DESTROYED) {
                ErrPrint("Package[%s] instance is already destroyed\n", pkgname);
@@ -5253,8 +5406,9 @@ static struct packet *slave_lb_update_begin(pid_t pid, int handle, const struct
 
        if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
                ret = instance_lb_update_begin(inst, priority, content, title);
-               if (ret == LB_STATUS_SUCCESS)
+               if (ret == LB_STATUS_SUCCESS) {
                        slave_freeze_ttl(slave);
+               }
        } else {
                ErrPrint("Invalid request[%s]\n", id);
        }
@@ -5285,8 +5439,9 @@ static struct packet *slave_lb_update_end(pid_t pid, int handle, const struct pa
        }
 
        ret = validate_request(pkgname, id, &inst, &pkg);
-       if (ret != LB_STATUS_SUCCESS)
+       if (ret != LB_STATUS_SUCCESS) {
                goto out;
+       }
 
        if (instance_state(inst) == INST_DESTROYED) {
                ErrPrint("Package[%s] instance is already destroyed\n", pkgname);
@@ -5295,8 +5450,9 @@ static struct packet *slave_lb_update_end(pid_t pid, int handle, const struct pa
 
        if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
                ret = instance_lb_update_end(inst);
-               if (ret == LB_STATUS_SUCCESS)
+               if (ret == LB_STATUS_SUCCESS) {
                        slave_thaw_ttl(slave);
+               }
        } else {
                ErrPrint("Invalid request[%s]\n", id);
        }
@@ -5327,18 +5483,20 @@ static struct packet *slave_pd_update_begin(pid_t pid, int handle, const struct
        }
 
        ret = validate_request(pkgname, id, &inst, &pkg);
-       if (ret != LB_STATUS_SUCCESS)
+       if (ret != LB_STATUS_SUCCESS) {
                goto out;
+       }
 
        if (instance_state(inst) == INST_DESTROYED) {
                ErrPrint("Package[%s] instance is already destroyed\n", pkgname);
                goto out;
        }
 
-       if (package_pd_type(pkg) == PD_TYPE_BUFFER)
+       if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
                (void)instance_pd_update_begin(inst);
-       else
+       } else {
                ErrPrint("Invalid request[%s]\n", id);
+       }
 
 out:
        return NULL;
@@ -5367,10 +5525,11 @@ static struct packet *slave_access_status(pid_t pid, int handle, const struct pa
 
        ret = validate_request(pkgname, id, &inst, NULL);
        if (ret == LB_STATUS_SUCCESS) {
-               if (instance_state(inst) == INST_DESTROYED)
+               if (instance_state(inst) == INST_DESTROYED) {
                        ErrPrint("Package[%s] instance is already destroyed\n", pkgname);
-               else
+               } else {
                        (void)instance_forward_packet(inst, packet_ref((struct packet *)packet));
+               }
        }
 
 out:
@@ -5399,18 +5558,20 @@ static struct packet *slave_pd_update_end(pid_t pid, int handle, const struct pa
        }
 
        ret = validate_request(pkgname, id, &inst, &pkg);
-       if (ret != LB_STATUS_SUCCESS)
+       if (ret != LB_STATUS_SUCCESS) {
                goto out;
+       }
 
        if (instance_state(inst) == INST_DESTROYED) {
                ErrPrint("Package[%s] instance is already destroyed\n", pkgname);
                goto out;
        }
 
-       if (package_pd_type(pkg) == PD_TYPE_BUFFER)
+       if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
                (void)instance_pd_update_end(inst);
-       else
+       } else {
                ErrPrint("Invalid request[%s]\n", id);
+       }
 
 out:
        return NULL;
@@ -5560,10 +5721,11 @@ static struct packet *slave_hold_scroll(pid_t pid, int handle, const struct pack
 
        ret = validate_request(pkgname, id, &inst, NULL);
        if (ret == LB_STATUS_SUCCESS) {
-               if (instance_state(inst) == INST_DESTROYED)
+               if (instance_state(inst) == INST_DESTROYED) {
                        ErrPrint("Package[%s] instance is already destroyed\n", pkgname);
-               else
+               } else {
                        (void)instance_hold_scroll(inst, seize);
+               }
        }
 
 out:
@@ -5592,8 +5754,9 @@ static struct packet *slave_desc_updated(pid_t pid, int handle, const struct pac
        }
 
        ret = validate_request(pkgname, id, &inst, NULL);
-       if (ret != LB_STATUS_SUCCESS)
+       if (ret != LB_STATUS_SUCCESS) {
                goto out;
+       }
 
        if (instance_state(inst) == INST_DESTROYED) {
                ErrPrint("Package[%s] instance is already destroyed\n", pkgname);
@@ -5685,8 +5848,9 @@ static struct packet *slave_acquire_buffer(pid_t pid, int handle, const struct p
        ret = validate_request(pkgname, id, &inst, &pkg);
        id = "";
 
-       if (ret != LB_STATUS_SUCCESS)
+       if (ret != LB_STATUS_SUCCESS) {
                goto out;
+       }
 
        ret = LB_STATUS_ERROR_INVALID;
 
@@ -5786,14 +5950,16 @@ static struct packet *slave_acquire_buffer(pid_t pid, int handle, const struct p
                /*!
                 * Send the PD created event to the client
                 */
-               if (!is_resize)
+               if (!is_resize) {
                        instance_client_pd_created(inst, ret);
+               }
        }
 
 out:
        result = packet_create_reply(packet, "is", ret, id);
-       if (!result)
+       if (!result) {
                ErrPrint("Failed to create a packet\n");
+       }
 
        return result;
 }
@@ -5829,8 +5995,9 @@ static struct packet *slave_resize_buffer(pid_t pid, int handle, const struct pa
 
        ret = validate_request(pkgname, id, &inst, &pkg);
        id = "";
-       if (ret != LB_STATUS_SUCCESS)
+       if (ret != LB_STATUS_SUCCESS) {
                goto out;
+       }
 
        ret = LB_STATUS_ERROR_INVALID;
        /*!
@@ -5847,8 +6014,9 @@ static struct packet *slave_resize_buffer(pid_t pid, int handle, const struct pa
                struct buffer_info *info;
 
                info = instance_lb_buffer(inst);
-               if (!info)
+               if (!info) {
                        goto out;
+               }
 
                ret = buffer_handler_resize(info, w, h);
                /*!
@@ -5864,8 +6032,9 @@ static struct packet *slave_resize_buffer(pid_t pid, int handle, const struct pa
                struct buffer_info *info;
 
                info = instance_pd_buffer(inst);
-               if (!info)
+               if (!info) {
                        goto out;
+               }
 
                ret = buffer_handler_resize(info, w, h);
                /*!
@@ -5880,8 +6049,9 @@ static struct packet *slave_resize_buffer(pid_t pid, int handle, const struct pa
 
 out:
        result = packet_create_reply(packet, "is", ret, id);
-       if (!result)
+       if (!result) {
                ErrPrint("Failed to create a packet\n");
+       }
 
        return result;
 }
@@ -5911,8 +6081,9 @@ static struct packet *slave_release_buffer(pid_t pid, int handle, const struct p
        }
 
        ret = validate_request(pkgname, id, &inst, &pkg);
-       if (ret != LB_STATUS_SUCCESS)
+       if (ret != LB_STATUS_SUCCESS) {
                goto out;
+       }
 
        ret = LB_STATUS_ERROR_INVALID;
 
@@ -5990,13 +6161,13 @@ static struct packet *slave_release_buffer(pid_t pid, int handle, const struct p
                         */
                        instance_client_pd_destroyed(inst, ret);
                }
-
        }
 
 out:
        result = packet_create_reply(packet, "i", ret);
-       if (!result)
+       if (!result) {
                ErrPrint("Failed to create a packet\n");
+       }
 
        return result;
 }
@@ -6032,8 +6203,9 @@ static struct packet *service_change_period(pid_t pid, int handle, const struct
                        inst_list = package_instance_list(pkg);
                        EINA_LIST_FOREACH(inst_list, l, inst) {
                                ret = instance_set_period(inst, period);
-                               if (ret < 0)
+                               if (ret < 0) {
                                        ErrPrint("Failed to change the period of %s to (%lf)\n", pkgname, period);
+                               }
                        }
                }
        } else {
@@ -6052,8 +6224,9 @@ static struct packet *service_change_period(pid_t pid, int handle, const struct
        DbgPrint("Change the update period: %s, %lf : %d\n", pkgname, period, ret);
 out:
        result = packet_create_reply(packet, "i", ret);
-       if (!result)
+       if (!result) {
                ErrPrint("Failed to create a packet\n");
+       }
 
        return result;
 }
@@ -6132,8 +6305,9 @@ static struct packet *service_update(pid_t pid, int handle, const struct packet
 
 out:
        result = packet_create_reply(packet, "i", ret);
-       if (!result)
+       if (!result) {
                ErrPrint("Failed to create a packet\n");
+       }
 
        return result;
 }
@@ -6169,8 +6343,9 @@ static struct packet *liveinfo_hello(pid_t pid, int handle, const struct packet
 
 out:
        result = packet_create_reply(packet, "si", fifo_name, ret);
-       if (!result)
+       if (!result) {
                ErrPrint("Failed to create a result packet\n");
+       }
 
        return result;
 }
@@ -6870,29 +7045,36 @@ HAPI int server_init(void)
 {
        com_core_packet_use_thread(COM_CORE_THREAD);
 
-       if (unlink(INFO_SOCKET) < 0)
+       if (unlink(INFO_SOCKET) < 0) {
                ErrPrint("info socket: %s\n", strerror(errno));
+       }
 
-       if (unlink(SLAVE_SOCKET) < 0)
+       if (unlink(SLAVE_SOCKET) < 0) {
                ErrPrint("slave socket: %s\n", strerror(errno));
+       }
 
-       if (unlink(CLIENT_SOCKET) < 0)
+       if (unlink(CLIENT_SOCKET) < 0) {
                ErrPrint("client socket: %s\n", strerror(errno));
+       }
 
-       if (unlink(SERVICE_SOCKET) < 0)
+       if (unlink(SERVICE_SOCKET) < 0) {
                ErrPrint("service socket: %s\n", strerror(errno));
+       }
 
        s_info.info_fd = com_core_packet_server_init(INFO_SOCKET, s_info_table);
-       if (s_info.info_fd < 0)
+       if (s_info.info_fd < 0) {
                ErrPrint("Failed to create a info socket\n");
+       }
 
        s_info.slave_fd = com_core_packet_server_init(SLAVE_SOCKET, s_slave_table);
-       if (s_info.slave_fd < 0)
+       if (s_info.slave_fd < 0) {
                ErrPrint("Failed to create a slave socket\n");
+       }
 
        s_info.client_fd = com_core_packet_server_init(CLIENT_SOCKET, s_client_table);
-       if (s_info.client_fd < 0)
+       if (s_info.client_fd < 0) {
                ErrPrint("Failed to create a client socket\n");
+       }
 
        /*!
         * \note
@@ -6900,24 +7082,30 @@ HAPI int server_init(void)
         * Skip address to use the NULL.
         */
        s_info.remote_client_fd = com_core_packet_server_init("remote://:"CLIENT_PORT, s_client_table);
-       if (s_info.client_fd < 0)
+       if (s_info.client_fd < 0) {
                ErrPrint("Failed to create a remote client socket\n");
+       }
 
        s_info.service_fd = com_core_packet_server_init(SERVICE_SOCKET, s_service_table);
-       if (s_info.service_fd < 0)
+       if (s_info.service_fd < 0) {
                ErrPrint("Faild to create a service socket\n");
+       }
 
-       if (chmod(INFO_SOCKET, 0600) < 0)
+       if (chmod(INFO_SOCKET, 0600) < 0) {
                ErrPrint("info socket: %s\n", strerror(errno));
+       }
 
-       if (chmod(SLAVE_SOCKET, 0666) < 0)
+       if (chmod(SLAVE_SOCKET, 0666) < 0) {
                ErrPrint("slave socket: %s\n", strerror(errno));
+       }
 
-       if (chmod(CLIENT_SOCKET, 0666) < 0)
+       if (chmod(CLIENT_SOCKET, 0666) < 0) {
                ErrPrint("client socket: %s\n", strerror(errno));
+       }
 
-       if (chmod(SERVICE_SOCKET, 0666) < 0)
+       if (chmod(SERVICE_SOCKET, 0666) < 0) {
                ErrPrint("service socket: %s\n", strerror(errno));
+       }
 
        return 0;
 }
index ea62e33..f09d60a 100644 (file)
@@ -192,8 +192,9 @@ static void *client_packet_pump_main(void *data)
                case RECV_HEADER:
                        ret = secure_socket_recv(tcb->fd, ptr, size - recv_offset, &pid);
                        if (ret <= 0) {
-                               if (ret == 0)
+                               if (ret == 0) {
                                        ret = -ECANCELED;
+                               }
                                free(ptr);
                                ptr = NULL;
                                break;
@@ -233,8 +234,9 @@ static void *client_packet_pump_main(void *data)
                case RECV_PAYLOAD:
                        ret = secure_socket_recv(tcb->fd, ptr, size - recv_offset, &pid);
                        if (ret <= 0) {
-                               if (ret == 0)
+                               if (ret == 0) {
                                        ret = -ECANCELED;
+                               }
                                free(ptr);
                                ptr = NULL;
                                break;
@@ -318,8 +320,9 @@ static void *client_packet_pump_main(void *data)
         * \note
         * Emit a signal to collect this TCB from the SERVER THREAD.
         */
-       if (write(svc_ctx->tcb_pipe[PIPE_WRITE], &tcb, sizeof(tcb)) != sizeof(tcb))
+       if (write(svc_ctx->tcb_pipe[PIPE_WRITE], &tcb, sizeof(tcb)) != sizeof(tcb)) {
                ErrPrint("Unable to write pipe: %s\n", strerror(errno));
+       }
 
        return (void *)ret;
 }
@@ -384,14 +387,16 @@ static inline void tcb_teminate_all(struct service_context *svc_ctx)
                /*!
                 * ASSERT(tcb->fd >= 0);
                 */
-               if (write(tcb->ctrl_pipe[PIPE_WRITE], &ch, sizeof(ch)) != sizeof(ch))
+               if (write(tcb->ctrl_pipe[PIPE_WRITE], &ch, sizeof(ch)) != sizeof(ch)) {
                        ErrPrint("write: %s\n", strerror(errno));
+               }
 
                status = pthread_join(tcb->thid, &ret);
-               if (status != 0)
+               if (status != 0) {
                        ErrPrint("Unable to join a thread: %s\n", strerror(status));
-               else
+               } else {
                        DbgPrint("Thread returns: %d\n", (int)ret);
+               }
 
                secure_socket_destroy_handle(tcb->fd);
 
@@ -417,14 +422,16 @@ static inline void tcb_destroy(struct service_context *svc_ctx, struct tcb *tcb)
         * ASSERT(tcb->fd >= 0);
         * Close the connection, and then collecting the return value of thread
         */
-       if (write(tcb->ctrl_pipe[PIPE_WRITE], &ch, sizeof(ch)) != sizeof(ch))
+       if (write(tcb->ctrl_pipe[PIPE_WRITE], &ch, sizeof(ch)) != sizeof(ch)) {
                ErrPrint("write: %s\n", strerror(errno));
+       }
 
        status = pthread_join(tcb->thid, &ret);
-       if (status != 0)
+       if (status != 0) {
                ErrPrint("Unable to join a thread: %s\n", strerror(status));
-       else
+       } else {
                DbgPrint("Thread returns: %d\n", (int)ret);
+       }
 
        secure_socket_destroy_handle(tcb->fd);
 
@@ -448,18 +455,21 @@ static inline int update_fdset(struct service_context *svc_ctx, fd_set *set)
        fd = svc_ctx->fd;
 
        FD_SET(svc_ctx->tcb_pipe[PIPE_READ], set);
-       if (svc_ctx->tcb_pipe[PIPE_READ] > fd)
+       if (svc_ctx->tcb_pipe[PIPE_READ] > fd) {
                fd = svc_ctx->tcb_pipe[PIPE_READ];
+       }
 
        FD_SET(svc_ctx->evt_pipe[PIPE_READ], set);
-       if (svc_ctx->evt_pipe[PIPE_READ] > fd)
+       if (svc_ctx->evt_pipe[PIPE_READ] > fd) {
                fd = svc_ctx->evt_pipe[PIPE_READ];
+       }
 
        EINA_LIST_FOREACH(svc_ctx->event_list, l, item) {
                if (item->type == SERVICE_EVENT_TIMER) {
                        FD_SET(item->info.timer.fd, set);
-                       if (fd < item->info.timer.fd)
+                       if (fd < item->info.timer.fd) {
                                fd = item->info.timer.fd;
+                       }
                }
        }
 
@@ -480,23 +490,27 @@ static inline void processing_timer_event(struct service_context *svc_ctx, fd_se
        EINA_LIST_FOREACH_SAFE(svc_ctx->event_list, l, n, item) {
                switch (item->type) {
                case SERVICE_EVENT_TIMER:
-                       if (!FD_ISSET(item->info.timer.fd, set))
+                       if (!FD_ISSET(item->info.timer.fd, set)) {
                                break;
+                       }
 
                        if (read(item->info.timer.fd, &expired_count, sizeof(expired_count)) == sizeof(expired_count)) {
                                DbgPrint("Expired %d times\n", expired_count);
-                               if (item->event_cb(svc_ctx, item->cbdata) >= 0)
+                               if (item->event_cb(svc_ctx, item->cbdata) >= 0) {
                                        break;
+                               }
                        } else {
                                ErrPrint("read: %s\n", strerror(errno));
                        }
 
-                       if (!eina_list_data_find(svc_ctx->event_list, item))
+                       if (!eina_list_data_find(svc_ctx->event_list, item)) {
                                break;
+                       }
 
                        svc_ctx->event_list = eina_list_remove(svc_ctx->event_list, item);
-                       if (close(item->info.timer.fd) < 0)
+                       if (close(item->info.timer.fd) < 0) {
                                ErrPrint("close: %s\n", strerror(errno));
+                       }
                        free(item);
                        break;
                default:
@@ -579,8 +593,9 @@ static void *server_main(void *data)
                                 * while processing svc_ctx->service_thread_main?
                                 */
                                ret = svc_ctx->service_thread_main(packet_info->tcb, packet_info->packet, svc_ctx->service_thread_data);
-                               if (ret < 0)
+                               if (ret < 0) {
                                        ErrPrint("Service thread returns: %d\n", ret);
+                               }
 
                                packet_destroy(packet_info->packet);
                                free(packet_info);
@@ -616,8 +631,9 @@ static void *server_main(void *data)
                        lockfree_packet_list = NULL;
                        CRITICAL_SECTION_BEGIN(&svc_ctx->packet_list_lock);
                        EINA_LIST_FOREACH_SAFE(svc_ctx->packet_list, l, n, packet_info) {
-                               if (packet_info->tcb != tcb)
+                               if (packet_info->tcb != tcb) {
                                        continue;
+                               }
 
                                svc_ctx->packet_list = eina_list_remove(svc_ctx->packet_list, packet_info);
                                lockfree_packet_list = eina_list_append(lockfree_packet_list, packet_info);
@@ -628,8 +644,9 @@ static void *server_main(void *data)
                                ret = read(svc_ctx->evt_pipe[PIPE_READ], &evt_ch, sizeof(evt_ch));
                                DbgPrint("Flushing filtered pipe: %d (%c)\n", ret, evt_ch);
                                ret = svc_ctx->service_thread_main(packet_info->tcb, packet_info->packet, svc_ctx->service_thread_data);
-                               if (ret < 0)
+                               if (ret < 0) {
                                        ErrPrint("Service thread returns: %d\n", ret);
+                               }
                                packet_destroy(packet_info->packet);
                                free(packet_info);
                        }
@@ -665,8 +682,9 @@ static void *server_main(void *data)
                ret = read(svc_ctx->evt_pipe[PIPE_READ], &evt_ch, sizeof(evt_ch));
                DbgPrint("Flushing pipe: %d (%c)\n", ret, evt_ch);
                ret = svc_ctx->service_thread_main(packet_info->tcb, packet_info->packet, svc_ctx->service_thread_data);
-               if (ret < 0)
+               if (ret < 0) {
                        ErrPrint("Service thread returns: %d\n", ret);
+               }
                packet_destroy(packet_info->packet);
                free(packet_info);
        }
@@ -690,8 +708,9 @@ HAPI struct service_context *service_common_create(const char *addr, int (*servi
                return NULL;
        }
 
-       if (unlink(addr) < 0)
+       if (unlink(addr) < 0) {
                ErrPrint("[%s] - %s\n", addr, strerror(errno));
+       }
 
        svc_ctx = calloc(1, sizeof(*svc_ctx));
        if (!svc_ctx) {
@@ -708,11 +727,13 @@ HAPI struct service_context *service_common_create(const char *addr, int (*servi
        svc_ctx->service_thread_main = service_thread_main;
        svc_ctx->service_thread_data = data;
 
-       if (fcntl(svc_ctx->fd, F_SETFD, FD_CLOEXEC) < 0)
+       if (fcntl(svc_ctx->fd, F_SETFD, FD_CLOEXEC) < 0) {
                ErrPrint("fcntl: %s\n", strerror(errno));
+       }
 
-       if (fcntl(svc_ctx->fd, F_SETFL, O_NONBLOCK) < 0)
+       if (fcntl(svc_ctx->fd, F_SETFL, O_NONBLOCK) < 0) {
                ErrPrint("fcntl: %s\n", strerror(errno));
+       }
 
        if (pipe2(svc_ctx->evt_pipe, O_NONBLOCK | O_CLOEXEC) < 0) {
                ErrPrint("pipe: %d\n", strerror(errno));
@@ -744,8 +765,9 @@ HAPI struct service_context *service_common_create(const char *addr, int (*servi
        if (status != 0) {
                ErrPrint("Unable to create a thread for shortcut service: %s\n", strerror(status));
                status = pthread_mutex_destroy(&svc_ctx->packet_list_lock);
-               if (status != 0)
+               if (status != 0) {
                        ErrPrint("Error: %s\n", strerror(status));
+               }
                CLOSE_PIPE(svc_ctx->evt_pipe);
                CLOSE_PIPE(svc_ctx->tcb_pipe);
                secure_socket_destroy_handle(svc_ctx->fd);
@@ -772,27 +794,31 @@ HAPI int service_common_destroy(struct service_context *svc_ctx)
        int status = 0;
        void *ret;
 
-       if (!svc_ctx)
+       if (!svc_ctx) {
                return -EINVAL;
+       }
 
        /*!
         * \note
         * Terminate server thread
         */
-       if (write(svc_ctx->tcb_pipe[PIPE_WRITE], &status, sizeof(status)) != sizeof(status))
+       if (write(svc_ctx->tcb_pipe[PIPE_WRITE], &status, sizeof(status)) != sizeof(status)) {
                ErrPrint("Failed to write: %s\n", strerror(errno));
+       }
 
        status = pthread_join(svc_ctx->server_thid, &ret);
-       if (status != 0)
+       if (status != 0) {
                ErrPrint("Join: %s\n", strerror(status));
-       else
+       } else {
                DbgPrint("Thread returns: %d\n", (int)ret);
+       }
 
        secure_socket_destroy_handle(svc_ctx->fd);
 
        status = pthread_mutex_destroy(&svc_ctx->packet_list_lock);
-       if (status != 0)
+       if (status != 0) {
                ErrPrint("Unable to destroy a mutex: %s\n", strerror(status));
+       }
 
        CLOSE_PIPE(svc_ctx->evt_pipe);
        CLOSE_PIPE(svc_ctx->tcb_pipe);
@@ -828,8 +854,9 @@ HAPI int tcb_is_valid(struct service_context *svc_ctx, struct tcb *tcb)
  */
 HAPI int tcb_fd(struct tcb *tcb)
 {
-       if (!tcb)
+       if (!tcb) {
                return -EINVAL;
+       }
 
        return tcb->fd;
 }
@@ -840,8 +867,9 @@ HAPI int tcb_fd(struct tcb *tcb)
  */
 HAPI int tcb_client_type(struct tcb *tcb)
 {
-       if (!tcb)
+       if (!tcb) {
                return -EINVAL;
+       }
 
        return tcb->type;
 }
@@ -852,8 +880,9 @@ HAPI int tcb_client_type(struct tcb *tcb)
  */
 HAPI int tcb_client_type_set(struct tcb *tcb, enum tcb_type type)
 {
-       if (!tcb)
+       if (!tcb) {
                return -EINVAL;
+       }
 
        DbgPrint("TCB[%p] Client type is changed to %d from %d\n", tcb, type, tcb->type);
        tcb->type = type;
@@ -866,8 +895,9 @@ HAPI int tcb_client_type_set(struct tcb *tcb, enum tcb_type type)
  */
 HAPI struct service_context *tcb_svc_ctx(struct tcb *tcb)
 {
-       if (!tcb)
+       if (!tcb) {
                return NULL;
+       }
 
        return tcb->svc_ctx;
 }
@@ -918,8 +948,9 @@ HAPI int service_common_multicast_packet(struct tcb *tcb, struct packet *packet,
                }
 
                ret = com_core_send(target->fd, (void *)packet_data(packet), packet_size(packet), DEFAULT_TIMEOUT);
-               if (ret < 0)
+               if (ret < 0) {
                        ErrPrint("Failed to send packet: %d\n", ret);
+               }
        }
        DbgPrint("Finish to multicast packet\n");
        return 0;
@@ -955,8 +986,9 @@ HAPI struct service_event_item *service_common_add_timer(struct service_context
 
        if (timerfd_settime(item->info.timer.fd, 0, &spec, NULL) < 0) {
                ErrPrint("Error: %s\n", strerror(errno));
-               if (close(item->info.timer.fd) < 0)
+               if (close(item->info.timer.fd) < 0) {
                        ErrPrint("close: %s\n", strerror(errno));
+               }
                free(item);
                return NULL;
        }
@@ -981,8 +1013,9 @@ HAPI int service_common_del_timer(struct service_context *svc_ctx, struct servic
 
        svc_ctx->event_list = eina_list_remove(svc_ctx->event_list, item);
 
-       if (close(item->info.timer.fd) < 0)
+       if (close(item->info.timer.fd) < 0) {
                ErrPrint("close: %s\n", strerror(errno));
+       }
        free(item);
        return 0;
 }
index 47c41c8..f8d41a5 100644 (file)
@@ -47,8 +47,9 @@ int errno;
 
 static void lcd_state_cb(keynode_t *node, void *user_data)
 {
-       if (!node)
+       if (!node) {
                return;
+       }
 
        xmonitor_handle_state_changes();
 }
@@ -80,8 +81,9 @@ static void power_off_cb(keynode_t *node, void *user_data)
                int fd;
 
                fd = creat("/tmp/.stop.provider", 0644);
-               if (fd < 0 || close(fd) < 0)
+               if (fd < 0 || close(fd) < 0) {
                        ErrPrint("stop.provider [%s]\n", strerror(errno));
+               }
 
                vconf_set_bool(VCONFKEY_MASTER_STARTED, 0);
                //exit(0);
@@ -97,8 +99,9 @@ static void region_changed_cb(keynode_t *node, void *user_data)
         char *r;
 
         region = vconf_get_str(VCONFKEY_REGIONFORMAT);
-        if (!region)
+        if (!region) {
                return;
+       }
 
        setenv("LC_CTYPE", region, 1);
        setenv("LC_NUMERIC", region, 1);
@@ -113,8 +116,9 @@ static void region_changed_cb(keynode_t *node, void *user_data)
        setenv("LC_IDENTIFICATION", region, 1);
 
        r = setlocale(LC_ALL, "");
-       if (r == NULL)
+       if (r == NULL) {
                ErrPrint("Failed to change region\n");
+       }
 
        DbgFree(region);
 }
@@ -125,15 +129,17 @@ static void lang_changed_cb(keynode_t *node, void *user_data)
                char *r;
 
         lang = vconf_get_str(VCONFKEY_LANGSET);
-        if (!lang)
+        if (!lang) {
                return;
+       }
 
        setenv("LANG", lang, 1);
        setenv("LC_MESSAGES", lang, 1);
 
        r = setlocale(LC_ALL, "");
-       if (!r)
+       if (!r) {
                ErrPrint("Failed to change locale\n");
+       }
 
        DbgPrint("Locale: %s\n", setlocale(LC_ALL, NULL));
        DbgFree(lang);
@@ -155,12 +161,14 @@ static void ail_info_cb(keynode_t *node, void *user_data)
        int enabled;
 
        event = vconf_get_str(VCONFKEY_AIL_INFO_STATE);
-       if (!event)
+       if (!event) {
                return;
+       }
 
        len = strlen("update:");
-       if (!strncasecmp(event, "update:", len))
+       if (!strncasecmp(event, "update:", len)) {
                goto out;
+       }
 
        appid = event + len;
        DbgPrint("AppId: [%s]\n", appid);
@@ -182,8 +190,9 @@ static void ail_info_cb(keynode_t *node, void *user_data)
        EINA_LIST_FOREACH(pkg_list, l, info) {
                inst_list = NULL;
                pkgname = livebox_service_mainappid(package_name(info));
-               if (!pkgname)
+               if (!pkgname) {
                        continue;
+               }
 
                if (strcmp(appid, pkgname)) {
                        DbgFree(pkgname);
@@ -207,24 +216,29 @@ HAPI int setting_init(void)
        int ret;
 
        ret = vconf_notify_key_changed(VCONFKEY_PM_STATE, lcd_state_cb, NULL);
-       if (ret < 0)
+       if (ret < 0) {
                ErrPrint("Failed to add vconf for lock state: %d\n", ret);
+       }
 
        ret = vconf_notify_key_changed(VCONFKEY_SYSMAN_POWER_OFF_STATUS, power_off_cb, NULL);
-       if (ret < 0)
+       if (ret < 0) {
                ErrPrint("Failed to add vconf for power state: %d \n", ret);
+       }
 
        ret = vconf_notify_key_changed(VCONFKEY_LANGSET, lang_changed_cb, NULL);
-       if (ret < 0)
+       if (ret < 0) {
                ErrPrint("Failed to add vconf for lang change: %d\n", ret);
+       }
 
        ret = vconf_notify_key_changed(VCONFKEY_REGIONFORMAT, region_changed_cb, NULL);
-       if (ret < 0)
+       if (ret < 0) {
                ErrPrint("Failed to add vconf for region change: %d\n", ret);
+       }
 
        ret = vconf_notify_key_changed(VCONFKEY_AIL_INFO_STATE, ail_info_cb, NULL);
-       if (ret < 0)
+       if (ret < 0) {
                ErrPrint("Failed to add vconf for ail info state: %d\n", ret);
+       }
 
        lang_changed_cb(NULL, NULL);
        region_changed_cb(NULL, NULL);
@@ -236,24 +250,29 @@ HAPI int setting_fini(void)
        int ret;
 
        ret = vconf_ignore_key_changed(VCONFKEY_REGIONFORMAT, region_changed_cb);
-       if (ret < 0)
+       if (ret < 0) {
                ErrPrint("Failed to ignore vconf key (%d)\n", ret);
+       }
 
        ret = vconf_ignore_key_changed(VCONFKEY_LANGSET, lang_changed_cb);
-       if (ret < 0)
+       if (ret < 0) {
                ErrPrint("Failed to ignore vconf key (%d)\n", ret);
+       }
 
        ret = vconf_ignore_key_changed(VCONFKEY_PM_STATE, lcd_state_cb);
-       if (ret < 0)
+       if (ret < 0) {
                ErrPrint("Failed to ignore vconf key (%d)\n", ret);
+       }
 
        ret = vconf_ignore_key_changed(VCONFKEY_SYSMAN_POWER_OFF_STATUS, power_off_cb);
-       if (ret < 0)
+       if (ret < 0) {
                ErrPrint("Failed to ignore vconf key (%d)\n", ret);
+       }
 
        ret = vconf_ignore_key_changed(VCONFKEY_AIL_INFO_STATE, ail_info_cb);
-       if (ret < 0)
+       if (ret < 0) {
                ErrPrint("Failed to ignore vconf key (%d)\n", ret);
+       }
 
        return ret;
 }
index edebb38..620798e 100644 (file)
@@ -77,8 +77,9 @@ static inline struct tcb *get_reply_context(double seq)
 
        tcb = NULL;
        EINA_LIST_FOREACH_SAFE(s_info.context_list, l, n, ctx) {
-               if (ctx->seq != seq)
+               if (ctx->seq != seq) {
                        continue;
+               }
 
                s_info.context_list = eina_list_remove(s_info.context_list, ctx);
                tcb = ctx->tcb;
@@ -99,8 +100,9 @@ static inline void send_reply_packet(struct tcb *tcb, struct packet *packet, int
                return;
        }
 
-       if (service_common_unicast_packet(tcb, reply_packet) < 0)
+       if (service_common_unicast_packet(tcb, reply_packet) < 0) {
                ErrPrint("Unable to send reply packet\n");
+       }
 
        packet_destroy(reply_packet);
 }
@@ -146,10 +148,11 @@ static int service_thread_main(struct tcb *tcb, struct packet *packet, void *dat
                        }
                }
 
-               if (service_common_multicast_packet(tcb, packet, TCB_CLIENT_TYPE_SERVICE) < 0)
+               if (service_common_multicast_packet(tcb, packet, TCB_CLIENT_TYPE_SERVICE) < 0) {
                        ErrPrint("Unable to send service request packet\n");
-               else
+               } else {
                        (void)put_reply_context(tcb, packet_seq(packet));
+               }
                break;
        case PACKET_REQ_NOACK:
                /* Doesn't need to send reply packet */
@@ -159,8 +162,9 @@ static int service_thread_main(struct tcb *tcb, struct packet *packet, void *dat
                        break;
                }
 
-               if (service_common_multicast_packet(tcb, packet, TCB_CLIENT_TYPE_SERVICE) < 0)
+               if (service_common_multicast_packet(tcb, packet, TCB_CLIENT_TYPE_SERVICE) < 0) {
                        ErrPrint("Unable to send service reuqest packet\n");
+               }
                break;
        case PACKET_ACK:
                /* Okay, client(or app) send a reply packet to us. */
@@ -176,8 +180,9 @@ static int service_thread_main(struct tcb *tcb, struct packet *packet, void *dat
                        break;
                }
 
-               if (service_common_unicast_packet(tcb, packet) < 0)
+               if (service_common_unicast_packet(tcb, packet) < 0) {
                        ErrPrint("Unable to send reply packet\n");
+               }
                break;
        default:
                ErrPrint("Packet type is not valid[%s]\n", command);
@@ -234,8 +239,9 @@ HAPI int shortcut_service_init(void)
 
 HAPI int shortcut_service_fini(void)
 {
-       if (!s_info.svc_ctx)
+       if (!s_info.svc_ctx) {
                return LB_STATUS_ERROR_INVALID;
+       }
 
        service_common_destroy(s_info.svc_ctx);
        s_info.svc_ctx = NULL;
index 335b193..f5710f6 100644 (file)
@@ -116,7 +116,9 @@ static Eina_Bool slave_ttl_cb(void *data)
        slave_set_reactivate_instances(slave, 1);
 
        slave = slave_deactivate(slave);
-       DbgPrint("Slave is deactivated(%p)\n", slave);
+       if (!slave) {
+               DbgPrint("Slave is deleted\n");
+       }
 
        /*! To recover all instances state it is activated again */
        return ECORE_CALLBACK_CANCEL;
@@ -238,14 +240,17 @@ static inline void destroy_slave_node(struct slave_node *slave)
 
        s_info.slave_list = eina_list_remove(s_info.slave_list, slave);
 
-       if (slave->ttl_timer)
+       if (slave->ttl_timer) {
                ecore_timer_del(slave->ttl_timer);
+       }
 
-       if (slave->activate_timer)
+       if (slave->activate_timer) {
                ecore_timer_del(slave->activate_timer);
+       }
 
-       if (slave->relaunch_timer)
+       if (slave->relaunch_timer) {
                ecore_timer_del(slave->relaunch_timer);
+       }
 
        DbgFree(slave->abi);
        DbgFree(slave->name);
@@ -260,8 +265,9 @@ static inline struct slave_node *find_slave(const char *name)
        Eina_List *l;
 
        EINA_LIST_FOREACH(s_info.slave_list, l, slave) {
-               if (!strcmp(slave->name, name))
+               if (!strcmp(slave->name, name)) {
                        return slave;
+               }
        }
        
        return NULL;
@@ -269,19 +275,22 @@ static inline struct slave_node *find_slave(const char *name)
 
 HAPI int slave_expired_ttl(struct slave_node *slave)
 {
-       if (!slave)
+       if (!slave) {
                return 0;
+       }
 
-       if (!slave->secured)
+       if (!slave->secured) {
                return 0;
+       }
 
        return !!slave->ttl_timer;
 }
 
 HAPI struct slave_node *slave_ref(struct slave_node *slave)
 {
-       if (!slave)
+       if (!slave) {
                return NULL;
+       }
 
        slave->refcnt++;
        return slave;
@@ -289,8 +298,9 @@ HAPI struct slave_node *slave_ref(struct slave_node *slave)
 
 HAPI struct slave_node *slave_unref(struct slave_node *slave)
 {
-       if (!slave)
+       if (!slave) {
                return NULL;
+       }
 
        if (slave->refcnt == 0) {
                ErrPrint("Slave refcnt is not valid\n");
@@ -317,14 +327,16 @@ HAPI struct slave_node *slave_create(const char *name, int is_secured, const cha
 
        slave = find_slave(name);
        if (slave) {
-               if (slave->secured != is_secured)
+               if (slave->secured != is_secured) {
                        ErrPrint("Exists slave and creating slave's security flag is not matched\n");
+               }
                return slave;
        }
 
        slave = create_slave_node(name, is_secured, abi, pkgname, network);
-       if (!slave)
+       if (!slave) {
                return NULL;
+       }
 
        slave_ref(slave);
        slave_rpc_init(slave);
@@ -398,8 +410,9 @@ static Eina_Bool activate_timer_cb(void *data)
                int ret;
                DbgPrint("Try to terminate PID: %d\n", slave_pid(slave));
                ret = aul_terminate_pid(slave_pid(slave));
-               if (ret < 0)
+               if (ret < 0) {
                        ErrPrint("Terminate failed, pid %d (reason: %d)\n", slave_pid(slave), ret);
+               }
        }
 
        CRITICAL_LOG("Slave is not activated in %lf sec (slave: %s)\n", SLAVE_ACTIVATE_TIME, slave_name(slave));
@@ -419,8 +432,9 @@ static inline void invoke_slave_fault_handler(struct slave_node *slave)
                int ret;
                DbgPrint("Try to terminate PID: %d\n", slave_pid(slave));
                ret = aul_terminate_pid(slave_pid(slave));
-               if (ret < 0)
+               if (ret < 0) {
                        ErrPrint("Terminate failed, pid %d (reason: %d)\n", slave_pid(slave), ret);
+               }
        }
 }
 
@@ -464,12 +478,10 @@ static Eina_Bool relaunch_timer_cb(void *data)
                        bundle_free(param);
 
                        switch (slave->pid) {
+                       //case AUL_R_EHIDDENFORGUEST:   /**< App hidden for guest mode */
                        case AUL_R_ENOLAUNCHPAD:        /**< no launchpad */
                        case AUL_R_EILLACC:             /**< Illegal Access */
-                       case AUL_R_LOCAL:               /**< Launch by himself */
-                       case AUL_R_ETIMEOUT:            /**< Timeout */
                        case AUL_R_EINVAL:              /**< Invalid argument */
-                       case AUL_R_OK:                  /**< General success */
                        case AUL_R_ENOINIT:             /**< AUL handler NOT initialized */
                        case AUL_R_ERROR:               /**< General error */
                                CRITICAL_LOG("Failed to launch a new slave %s (%d)\n", slave_name(slave), slave->pid);
@@ -482,6 +494,7 @@ static Eina_Bool relaunch_timer_cb(void *data)
                                invoke_slave_fault_handler(slave);
                                /* Waiting app-launch result */
                                break;
+                       case AUL_R_ETIMEOUT:            /**< Timeout */
                        case AUL_R_ECOMM:               /**< Comunication Error */
                        case AUL_R_ETERMINATING:        /**< application terminating */
                        case AUL_R_ECANCELED:           /**< Operation canceled */
@@ -493,6 +506,8 @@ static Eina_Bool relaunch_timer_cb(void *data)
                                ecore_timer_reset(slave->activate_timer);
                                /* Try again after a few secs later */
                                break;
+                       case AUL_R_LOCAL:               /**< Launch by himself */
+                       case AUL_R_OK:                  /**< General success */
                        default:
                                DbgPrint("Slave %s is launched with %d as %s\n", slave_pkgname(slave), slave->pid, slave_name(slave));
                                slave->relaunch_timer = NULL;
@@ -519,8 +534,9 @@ HAPI int slave_activate(struct slave_node *slave)
         * about it is alive? or not.
         */
        if (slave_pid(slave) != (pid_t)-1) {
-               if (slave_state(slave) == SLAVE_REQUEST_TO_TERMINATE)
+               if (slave_state(slave) == SLAVE_REQUEST_TO_TERMINATE) {
                        slave_set_reactivation(slave, 1);
+               }
                return LB_STATUS_ERROR_ALREADY;
        } else if (slave_state(slave) == SLAVE_REQUEST_TO_LAUNCH) {
                DbgPrint("Slave is already launched: but the AUL is timed out\n");
@@ -549,12 +565,10 @@ HAPI int slave_activate(struct slave_node *slave)
                bundle_free(param);
 
                switch (slave->pid) {
+               //case AUL_R_EHIDDENFORGUEST:   /**< App hidden for guest mode */
                case AUL_R_ENOLAUNCHPAD:        /**< no launchpad */
                case AUL_R_EILLACC:             /**< Illegal Access */
-               case AUL_R_LOCAL:               /**< Launch by himself */
-               case AUL_R_ETIMEOUT:            /**< Timeout */
                case AUL_R_EINVAL:              /**< Invalid argument */
-               case AUL_R_OK:                  /**< General success */
                case AUL_R_ENOINIT:             /**< AUL handler NOT initialized */
                case AUL_R_ERROR:               /**< General error */
                        CRITICAL_LOG("Failed to launch a new slave %s (%d)\n", slave_name(slave), slave->pid);
@@ -564,6 +578,7 @@ HAPI int slave_activate(struct slave_node *slave)
                case AUL_R_ECOMM:               /**< Comunication Error */
                case AUL_R_ETERMINATING:        /**< application terminating */
                case AUL_R_ECANCELED:           /**< Operation canceled */
+               case AUL_R_ETIMEOUT:            /**< Timeout */
                        CRITICAL_LOG("Try relaunch this soon %s (%d)\n", slave_name(slave), slave->pid);
                        slave->relaunch_timer = ecore_timer_add(SLAVE_RELAUNCH_TIME, relaunch_timer_cb, slave);
                        if (!slave->relaunch_timer) {
@@ -573,14 +588,17 @@ HAPI int slave_activate(struct slave_node *slave)
                        }
                        /* Try again after a few secs later */
                        break;
+               case AUL_R_LOCAL:               /**< Launch by himself */
+               case AUL_R_OK:                  /**< General success */
                default:
                        DbgPrint("Slave %s is launched with %d as %s\n", slave_pkgname(slave), slave->pid, slave_name(slave));
                        break;
                }
 
                slave->activate_timer = ecore_timer_add(SLAVE_ACTIVATE_TIME, activate_timer_cb, slave);
-               if (!slave->activate_timer)
+               if (!slave->activate_timer) {
                        ErrPrint("Failed to register an activate timer\n");
+               }
        }
 
        slave->state = SLAVE_REQUEST_TO_LAUNCH;
@@ -598,8 +616,9 @@ HAPI int slave_give_more_ttl(struct slave_node *slave)
 {
        double delay;
 
-       if (!slave->secured || !slave->ttl_timer)
+       if (!slave->secured || !slave->ttl_timer) {
                return LB_STATUS_ERROR_INVALID;
+       }
 
        delay = SLAVE_TTL - ecore_timer_pending_get(slave->ttl_timer);
        ecore_timer_delay(slave->ttl_timer, delay);
@@ -608,8 +627,9 @@ HAPI int slave_give_more_ttl(struct slave_node *slave)
 
 HAPI int slave_freeze_ttl(struct slave_node *slave)
 {
-       if (!slave->secured || !slave->ttl_timer)
+       if (!slave->secured || !slave->ttl_timer) {
                return LB_STATUS_ERROR_INVALID;
+       }
 
        ecore_timer_freeze(slave->ttl_timer);
        return LB_STATUS_SUCCESS;
@@ -619,8 +639,9 @@ HAPI int slave_thaw_ttl(struct slave_node *slave)
 {
        double delay;
 
-       if (!slave->secured || !slave->ttl_timer)
+       if (!slave->secured || !slave->ttl_timer) {
                return LB_STATUS_ERROR_INVALID;
+       }
 
        ecore_timer_thaw(slave->ttl_timer);
 
@@ -633,14 +654,16 @@ HAPI int slave_activated(struct slave_node *slave)
 {
        slave->state = SLAVE_RESUMED;
 
-       if (xmonitor_is_paused())
+       if (xmonitor_is_paused()) {
                slave_pause(slave);
+       }
 
        if (slave->secured == 1) {
                DbgPrint("Slave deactivation timer is added (%s - %lf)\n", slave_name(slave), SLAVE_TTL);
                slave->ttl_timer = ecore_timer_add(SLAVE_TTL, slave_ttl_cb, slave);
-               if (!slave->ttl_timer)
+               if (!slave->ttl_timer) {
                        ErrPrint("Failed to create a TTL timer\n");
+               }
        }
 
        invoke_activate_cb(slave);
@@ -760,8 +783,9 @@ HAPI struct slave_node *slave_deactivated(struct slave_node *slave)
 
                DbgPrint("Need to reactivate a slave\n");
                ret = slave_activate(slave);
-               if (ret < 0 && ret != LB_STATUS_ERROR_ALREADY)
+               if (ret < 0 && ret != LB_STATUS_ERROR_ALREADY) {
                        ErrPrint("Failed to reactivate a slave\n");
+               }
        } else if (slave_loaded_instance(slave) == 0) {
                /*!
                 * \note
@@ -783,8 +807,9 @@ HAPI struct slave_node *slave_deactivated_by_fault(struct slave_node *slave)
 
        if (!slave_is_activated(slave)) {
                DbgPrint("Deactivating in progress\n");
-               if (slave_loaded_instance(slave) == 0)
+               if (slave_loaded_instance(slave) == 0) {
                        slave = slave_unref(slave);
+               }
 
                return slave;
        }
@@ -1029,8 +1054,9 @@ HAPI void *slave_data(struct slave_node *slave, const char *tag)
        Eina_List *l;
 
        EINA_LIST_FOREACH(slave->data_list, l, priv) {
-               if (!strcmp(priv->tag, tag))
+               if (!strcmp(priv->tag, tag)) {
                        return priv->data;
+               }
        }
 
        return NULL;
@@ -1042,8 +1068,9 @@ HAPI struct slave_node *slave_find_by_pid(pid_t pid)
        struct slave_node *slave;
 
        EINA_LIST_FOREACH(s_info.slave_list, l, slave) {
-               if (slave_pid(slave) == pid)
+               if (slave_pid(slave) == pid) {
                        return slave;
+               }
        }
 
        return NULL;
@@ -1055,8 +1082,9 @@ HAPI struct slave_node *slave_find_by_name(const char *name)
        struct slave_node *slave;
 
        EINA_LIST_FOREACH(s_info.slave_list, l, slave) {
-               if (!strcmp(slave_name(slave), name))
+               if (!strcmp(slave_name(slave), name)) {
                        return slave;
+               }
        }
 
        return NULL;
@@ -1068,8 +1096,9 @@ HAPI struct slave_node *slave_find_available(const char *abi, int secured, int n
        struct slave_node *slave;
 
        EINA_LIST_FOREACH(s_info.slave_list, l, slave) {
-               if (slave->secured != secured)
+               if (slave->secured != secured) {
                        continue;
+               }
 
                if (slave->state == SLAVE_REQUEST_TO_TERMINATE && slave->loaded_instance == 0) {
                        /*!
@@ -1084,8 +1113,9 @@ HAPI struct slave_node *slave_find_available(const char *abi, int secured, int n
                        continue;
                }
 
-               if (strcasecmp(slave->abi, abi))
+               if (strcasecmp(slave->abi, abi)) {
                        continue;
+               }
 
                if (slave->secured) {
                        if (slave->loaded_package == 0) {
@@ -1095,8 +1125,9 @@ HAPI struct slave_node *slave_find_available(const char *abi, int secured, int n
                } else if (slave->network == network) {
                        DbgPrint("slave[%s] loaded_package[%d] net: [%d]\n", slave_name(slave), slave->loaded_package, slave->network);
                        if (!strcasecmp(abi, DEFAULT_ABI)) {
-                               if (slave->loaded_package < SLAVE_MAX_LOAD)
+                               if (slave->loaded_package < SLAVE_MAX_LOAD) {
                                        return slave;
+                               }
                        } else {
                                return slave;
                        }
@@ -1133,8 +1164,9 @@ HAPI struct slave_node *slave_find_by_rpc_handle(int handle)
        }
 
        EINA_LIST_FOREACH(s_info.slave_list, l, slave) {
-               if (slave_rpc_handle(slave) == handle)
+               if (slave_rpc_handle(slave) == handle) {
                        return slave;
+               }
        }
 
        /* Not found */
@@ -1213,8 +1245,9 @@ HAPI const pid_t const slave_pid(const struct slave_node *slave)
 
 HAPI int slave_set_pid(struct slave_node *slave, pid_t pid)
 {
-       if (!slave)
+       if (!slave) {
                return LB_STATUS_ERROR_INVALID;
+       }
 
        DbgPrint("Slave PID is updated to %d from %d\n", pid, slave_pid(slave));
 
@@ -1418,8 +1451,9 @@ HAPI int const slave_fault_count(const struct slave_node *slave)
 
 HAPI double const slave_ttl(const struct slave_node *slave)
 {
-       if (!slave->ttl_timer)
+       if (!slave->ttl_timer) {
                return 0.0f;
+       }
 
        return ecore_timer_pending_get(slave->ttl_timer);
 }
@@ -1465,8 +1499,9 @@ HAPI int slave_deactivate_all(int reactivate, int reactivate_instances)
                slave_set_reactivate_instances(slave, reactivate_instances);
                slave_set_reactivation(slave, reactivate);
 
-               if (!slave_deactivate(slave))
+               if (!slave_deactivate(slave)) {
                        s_info.slave_list = eina_list_remove(s_info.slave_list, slave);
+               }
 
                cnt++;
        }
index 0e66261..d316331 100644 (file)
@@ -111,8 +111,9 @@ static inline struct command *pop_command(void)
        struct command *command;
 
        command = eina_list_nth(s_info.command_list, 0);
-       if (!command)
+       if (!command) {
                return NULL;
+       }
 
        s_info.command_list = eina_list_remove(s_info.command_list, command);
        return command;
@@ -133,15 +134,17 @@ static int slave_async_cb(pid_t pid, int handle, const struct packet *packet, vo
         */
        if (!slave_is_activated(command->slave)) {
                ErrPrint("Slave is not activated (accidently dead)\n");
-               if (command->ret_cb)
+               if (command->ret_cb) {
                        command->ret_cb(command->slave, packet, command->cbdata);
+               }
                goto out;
        }
 
        if (!packet) {
                DbgPrint("packet == NULL\n");
-               if (command->ret_cb)
+               if (command->ret_cb) {
                        command->ret_cb(command->slave, packet, command->cbdata);
+               }
 
                /*
                 * \NOTE
@@ -154,8 +157,9 @@ static int slave_async_cb(pid_t pid, int handle, const struct packet *packet, vo
                goto out;
        }
 
-       if (command->ret_cb)
+       if (command->ret_cb) {
                command->ret_cb(command->slave, packet, command->cbdata);
+       }
 
 out:
        destroy_command(command);
@@ -239,8 +243,9 @@ static Eina_Bool command_consumer_cb(void *data)
        return ECORE_CALLBACK_RENEW;
 
 errout:
-       if (command->ret_cb)
+       if (command->ret_cb) {
                command->ret_cb(command->slave, NULL, command->cbdata);
+       }
 
        destroy_command(command);
        return ECORE_CALLBACK_RENEW;
@@ -250,8 +255,9 @@ static inline void prepend_command(struct command *command)
 {
        s_info.command_list = eina_list_prepend(s_info.command_list, command);
 
-       if (s_info.command_consuming_timer)
+       if (s_info.command_consuming_timer) {
                return;
+       }
 
        s_info.command_consuming_timer = ecore_timer_add(PACKET_TIME, command_consumer_cb, NULL);
        if (!s_info.command_consuming_timer) {
@@ -265,8 +271,9 @@ static inline void push_command(struct command *command)
 {
        s_info.command_list = eina_list_append(s_info.command_list, command);
 
-       if (s_info.command_consuming_timer)
+       if (s_info.command_consuming_timer) {
                return;
+       }
 
        s_info.command_consuming_timer = ecore_timer_add(PACKET_TIME, command_consumer_cb, NULL);
        if (!s_info.command_consuming_timer) {
@@ -302,16 +309,18 @@ static int slave_deactivate_cb(struct slave_node *slave, void *data)
        if (rpc->handle < 0) {
                EINA_LIST_FREE(rpc->pending_list, command) {
                        assert(command->slave == slave);
-                       if (command->ret_cb)
+                       if (command->ret_cb) {
                                command->ret_cb(command->slave, NULL, command->cbdata);
+                       }
                        destroy_command(command);
                }
        } else {
                EINA_LIST_FOREACH_SAFE(s_info.command_list, l, n, command) {
                        if (command->slave == slave) {
                                s_info.command_list = eina_list_remove(s_info.command_list, command);
-                               if (command->ret_cb)
+                               if (command->ret_cb) {
                                        command->ret_cb(command->slave, NULL, command->cbdata);
+                               }
                                destroy_command(command);
                        }
                }
@@ -360,7 +369,10 @@ static Eina_Bool ping_timeout_cb(void *data)
         */
        DbgPrint("Slave PING TIMEOUT: %s(%d) : %p\n", slave_name(slave), slave_pid(slave), slave);
        slave = slave_deactivated_by_fault(slave);
-       DbgPrint("Slave: %p\n", slave);
+       if (!slave) {
+               DbgPrint("Slave is deleted\n");
+       }
+
        return ECORE_CALLBACK_CANCEL;
 }
 
@@ -373,8 +385,9 @@ HAPI int slave_rpc_async_request(struct slave_node *slave, const char *pkgname,
        if (!command) {
                ErrPrint("Failed to create command\n");
 
-               if (ret_cb)
+               if (ret_cb) {
                        ret_cb(slave, NULL, data);
+               }
 
                packet_unref(packet);
                return LB_STATUS_ERROR_MEMORY;
@@ -387,8 +400,9 @@ HAPI int slave_rpc_async_request(struct slave_node *slave, const char *pkgname,
        rpc = slave_data(slave, "rpc");
        if (!rpc) {
                ErrPrint("Slave has no RPC\n");
-               if (ret_cb)
+               if (ret_cb) {
                        ret_cb(slave, NULL, data);
+               }
                destroy_command(command);
                return LB_STATUS_ERROR_FAULT;
        }
@@ -401,26 +415,29 @@ HAPI int slave_rpc_async_request(struct slave_node *slave, const char *pkgname,
                        ret = slave_activate(slave);
                        if (ret < 0 && ret != LB_STATUS_ERROR_ALREADY) {
 
-                               if (ret_cb)
+                               if (ret_cb) {
                                        ret_cb(slave, NULL, data);
+                               }
 
                                destroy_command(command);
                                return ret;
                        }
                }
 
-               if (urgent)
+               if (urgent) {
                        rpc->pending_list = eina_list_prepend(rpc->pending_list, command);
-               else
+               } else {
                        rpc->pending_list = eina_list_append(rpc->pending_list, command);
+               }
 
                return LB_STATUS_SUCCESS;
        }
 
-       if (urgent)
+       if (urgent) {
                prepend_command(command);
-       else
+       } else {
                push_command(command);
+       }
 
        return LB_STATUS_SUCCESS;
 }
@@ -462,18 +479,20 @@ HAPI int slave_rpc_request_only(struct slave_node *slave, const char *pkgname, s
                        }
                }
 
-               if (urgent)
+               if (urgent) {
                        rpc->pending_list = eina_list_prepend(rpc->pending_list, command);
-               else
+               } else {
                        rpc->pending_list = eina_list_append(rpc->pending_list, command);
+               }
 
                return LB_STATUS_SUCCESS;
        }
 
-       if (urgent)
+       if (urgent) {
                prepend_command(command);
-       else
+       } else {
                push_command(command);
+       }
 
        return LB_STATUS_SUCCESS;
 }
@@ -484,17 +503,20 @@ HAPI int slave_rpc_update_handle(struct slave_node *slave, int handle)
        struct command *command;
 
        rpc = slave_data(slave, "rpc");
-       if (!rpc)
+       if (!rpc) {
                return LB_STATUS_ERROR_INVALID;
+       }
 
        DbgPrint("SLAVE: New handle assigned for %d, %d\n", slave_pid(slave), handle);
        rpc->handle = handle;
-       if (rpc->pong_timer)
+       if (rpc->pong_timer) {
                ecore_timer_del(rpc->pong_timer);
+       }
 
        rpc->pong_timer = ecore_timer_add(DEFAULT_PING_TIME, ping_timeout_cb, slave);
-       if (!rpc->pong_timer)
+       if (!rpc->pong_timer) {
                ErrPrint("Failed to add ping timer\n");
+       }
 
        /*!
         * \note
@@ -540,13 +562,15 @@ HAPI int slave_rpc_fini(struct slave_node *slave)
        struct slave_rpc *rpc;
 
        rpc = slave_del_data(slave, "rpc");
-       if (!rpc)
+       if (!rpc) {
                return LB_STATUS_ERROR_INVALID;
+       }
 
        slave_event_callback_del(slave, SLAVE_EVENT_DEACTIVATE, slave_deactivate_cb, NULL);
 
-       if (rpc->pong_timer)
+       if (rpc->pong_timer) {
                ecore_timer_del(rpc->pong_timer);
+       }
 
        DbgFree(rpc);
        return LB_STATUS_SUCCESS;
index 60792ce..2349631 100644 (file)
@@ -40,8 +40,9 @@ HAPI unsigned long util_string_hash(const char *str)
 {
        unsigned long ret = 0;
 
-       while (*str)
+       while (*str) {
                ret += (unsigned long)(*str++);
+       }
 
        ret %= 371773;
        return ret;
@@ -67,8 +68,9 @@ HAPI int util_check_ext(const char *filename, const char *check_ptr)
 
        name_len = strlen(filename);
        while (--name_len >= 0 && *check_ptr) {
-               if (filename[name_len] != *check_ptr)
+               if (filename[name_len] != *check_ptr) {
                        return LB_STATUS_ERROR_INVALID;
+               }
 
                check_ptr ++;
        }
@@ -134,8 +136,9 @@ HAPI int util_validate_livebox_package(const char *pkgname)
                return LB_STATUS_ERROR_INVALID;
        }
 
-       if (!check_native_livebox(pkgname) || !check_web_livebox(pkgname))
+       if (!check_native_livebox(pkgname) || !check_web_livebox(pkgname)) {
                return LB_STATUS_SUCCESS;
+       }
 
        return LB_STATUS_ERROR_INVALID;
 }
@@ -146,8 +149,9 @@ HAPI int util_unlink(const char *filename)
        int desclen;
        int ret;
 
-       if (!filename)
+       if (!filename) {
                return LB_STATUS_ERROR_INVALID;
+       }
 
        desclen = strlen(filename) + 6; /* .desc */
        descfile = malloc(desclen);
@@ -183,8 +187,9 @@ HAPI const char *util_basename(const char *name)
 {
        int length;
        length = name ? strlen(name) : 0;
-       if (!length)
+       if (!length) {
                return ".";
+       }
 
        while (--length > 0 && name[length] != '/');
 
@@ -243,8 +248,9 @@ HAPI char *util_replace_string(const char *src, const char *pattern, const char
                STATE_END
        } state;
 
-       if (!src || !pattern)
+       if (!src || !pattern) {
                return NULL;
+       }
 
        out_sz = strlen(src);
        ret = strdup(src);
@@ -339,8 +345,9 @@ HAPI const char *util_uri_to_path(const char *uri)
        int len;
 
        len = strlen(SCHEMA_FILE);
-       if (strncasecmp(uri, SCHEMA_FILE, len))
+       if (strncasecmp(uri, SCHEMA_FILE, len)) {
                return NULL;
+       }
 
        return uri + len;
 }
@@ -382,8 +389,9 @@ HAPI void *util_timer_add(double interval, Eina_Bool (*cb)(void *data), void *da
        double delay;
 
        timer = ecore_timer_add(interval, cb, data);
-       if (!timer)
+       if (!timer) {
                return NULL;
+       }
 
        delay = util_time_delay_for_compensation(interval) - interval;
        ecore_timer_delay(timer, delay);
@@ -417,8 +425,9 @@ HAPI char *util_get_file_kept_in_safe(const char *id)
        /*!
         * TODO: Remove me
         */
-       if (OVERWRITE_CONTENT)
+       if (OVERWRITE_CONTENT) {
                return strdup(path);
+       }
 
        len = strlen(path);
        base_idx = len - 1;
@@ -462,11 +471,13 @@ HAPI int util_unlink_files(const char *folder)
        }
 
        while ((entry = readdir(handle))) {
-               if (!strcmp(entry->d_name, "."))
+               if (!strcmp(entry->d_name, ".")) {
                        continue;
+               }
 
-               if (!strcmp(entry->d_name, ".."))
+               if (!strcmp(entry->d_name, "..")) {
                        continue;
+               }
 
                len = strlen(folder) + strlen(entry->d_name) + 3;
                abspath = calloc(1, len);
@@ -476,13 +487,16 @@ HAPI int util_unlink_files(const char *folder)
                }
                snprintf(abspath, len - 1, "%s/%s", folder, entry->d_name);
 
-               if (unlink(abspath) < 0)
+               if (unlink(abspath) < 0) {
                        DbgPrint("unlink: %s\n", strerror(errno));
+               }
 
                free(abspath);
        }
 
-       closedir(handle);
+       if (closedir(handle) < 0) {
+               ErrPrint("closedir: %s\n", strerror(errno));
+       }
        return LB_STATUS_SUCCESS;
 }
 
index 723d22a..c21f7cd 100644 (file)
@@ -99,8 +99,9 @@ static inline struct tcb *get_reply_tcb(double seq)
        struct tcb *tcb;
 
        EINA_LIST_FOREACH_SAFE(s_info.context_list, l, n, ctx) {
-               if (ctx->seq != seq)
+               if (ctx->seq != seq) {
                        continue;
+               }
 
                s_info.context_list = eina_list_remove(s_info.context_list, ctx);
                tcb = ctx->tcb;
@@ -124,8 +125,9 @@ static inline int flush_pended_request(void)
                if (ret < 0) {
                        struct packet *reply;
                        reply = packet_create_reply(item->packet, "i", ret);
-                       if (service_common_unicast_packet(item->tcb, reply) < 0)
+                       if (service_common_unicast_packet(item->tcb, reply) < 0) {
                                ErrPrint("Unable to send packet\n");
+                       }
                        packet_destroy(reply);
                } else {
                        put_reply_tcb(item->tcb, packet_seq(item->packet));
@@ -172,8 +174,9 @@ static int launch_timeout_cb(struct service_context *svc_ctx, void *data)
                        int ret;
 
                        ret = service_common_unicast_packet(item->tcb, reply);
-                       if (ret < 0)
+                       if (ret < 0) {
                                ErrPrint("Failed to send reply packet: %d\n", ret);
+                       }
 
                        packet_destroy(reply);
                }
@@ -193,29 +196,38 @@ static inline int launch_svc(struct service_context *svc_ctx)
        int ret = LB_STATUS_SUCCESS;
 
        pid = aul_launch_app(SVC_PKG, NULL);
-       if (pid > 0) {
-               s_info.svc_daemon_is_launched = 1;
-               s_info.launch_timer = service_common_add_timer(svc_ctx, LAUNCH_TIMEOUT, launch_timeout_cb, NULL);
-               if (!s_info.launch_timer)
-                       ErrPrint("Unable to create launch timer\n");
-       } else if (pid == AUL_R_ETIMEOUT || pid == AUL_R_ECOMM) {
-               s_info.svc_daemon_is_launched = 1;
-               CRITICAL_LOG("SVC launch failed with timeout(%d), But waiting response\n", pid);
-               s_info.launch_timer = service_common_add_timer(svc_ctx, LAUNCH_TIMEOUT, launch_timeout_cb, NULL);
-               if (!s_info.launch_timer)
-                       ErrPrint("Unable to create launch timer\n");
-       } else if (pid == AUL_R_ETERMINATING) {
+       switch (pid) {
+       //case AUL_R_EHIDDENFORGUEST:   /**< App hidden for guest mode */
+       case AUL_R_ENOLAUNCHPAD:        /**< no launchpad */
+       case AUL_R_EILLACC:             /**< Illegal Access */
+       case AUL_R_EINVAL:              /**< Invalid argument */
+       case AUL_R_ENOINIT:             /**< AUL handler NOT initialized */
+       case AUL_R_ERROR:               /**< General error */
+               ErrPrint("Failed to launch an app: %s(%d)\n", SVC_PKG, pid);
+               ret = LB_STATUS_ERROR_FAULT;
+               break;
+       case AUL_R_ETIMEOUT:            /**< Timeout */
+       case AUL_R_ECOMM:               /**< Comunication Error */
+       case AUL_R_ETERMINATING:        /**< application terminating */
+       case AUL_R_ECANCELED:           /**< Operation canceled */
                /* Need time to launch app again */
-               ErrPrint("Terminating now, try to launch this after few sec later\n");
+               ErrPrint("Terminating now, try to launch this after few sec later: %s(%d)\n", SVC_PKG, pid);
                s_info.svc_daemon_is_launched = 1;
                s_info.delay_launcher = service_common_add_timer(svc_ctx, LAUNCH_TIMEOUT, lazy_launcher_cb, NULL);
                if (!s_info.delay_launcher) {
                        ErrPrint("Unable to add delay launcher\n");
                        ret = LB_STATUS_ERROR_FAULT;
                }
-       } else {
-               ErrPrint("Failed to launch an app: %s(%d)\n", SVC_PKG, pid);
-               ret = LB_STATUS_ERROR_FAULT;
+               break;
+       case AUL_R_LOCAL:               /**< Launch by himself */
+       case AUL_R_OK:                  /**< General success */
+       default:
+               DbgPrint("Launched: %s(%d)\n", SVC_PKG, pid);
+               s_info.svc_daemon_is_launched = 1;
+               s_info.launch_timer = service_common_add_timer(svc_ctx, LAUNCH_TIMEOUT, launch_timeout_cb, NULL);
+               if (!s_info.launch_timer) {
+                       ErrPrint("Unable to create launch timer\n");
+               }
        }
 
        return ret;
@@ -255,18 +267,21 @@ static int service_thread_main(struct tcb *tcb, struct packet *packet, void *dat
        case PACKET_REQ:
                if (!s_info.svc_daemon_is_launched) {
                        ret = launch_svc(tcb_svc_ctx(tcb));
-                       if (ret != LB_STATUS_SUCCESS)
+                       if (ret != LB_STATUS_SUCCESS) {
                                goto reply_out;
+                       }
                }
 
                if (!s_info.svc_daemon) {
                        ret = put_pended_request(tcb, packet);
-                       if (ret < 0)
+                       if (ret < 0) {
                                goto reply_out;
+                       }
                } else {
                        ret = service_common_unicast_packet(s_info.svc_daemon, packet);
-                       if (ret <0)
+                       if (ret <0) {
                                goto reply_out;
+                       }
 
                        put_reply_tcb(tcb, packet_seq(packet));
                }
@@ -299,8 +314,9 @@ static int service_thread_main(struct tcb *tcb, struct packet *packet, void *dat
                        ErrPrint("Unable to find reply tcb\n");
                } else {
                        ret = service_common_unicast_packet(tcb, packet);
-                       if (ret < 0)
+                       if (ret < 0) {
                                ErrPrint("Unable to forward the reply packet\n");
+                       }
                }
                break;
        default:
@@ -313,8 +329,9 @@ static int service_thread_main(struct tcb *tcb, struct packet *packet, void *dat
 reply_out:
        ErrPrint("Error: %d\n", ret);
        reply = packet_create_reply(packet, "i", ret);
-       if (service_common_unicast_packet(tcb, reply) < 0)
+       if (service_common_unicast_packet(tcb, reply) < 0) {
                ErrPrint("Unable to send reply packet\n");
+       }
        packet_destroy(reply);
        return ret;
 }
@@ -356,8 +373,9 @@ int utility_service_init(void)
 
 int utility_service_fini(void)
 {
-       if (!s_info.svc_ctx)
+       if (!s_info.svc_ctx) {
                return LB_STATUS_ERROR_INVALID;
+       }
 
        service_common_destroy(s_info.svc_ctx);
        s_info.svc_ctx = NULL;
index e986215..36da47f 100644 (file)
@@ -75,8 +75,9 @@ static inline void touch_paused_file(void)
        int fd;
        fd = creat(PAUSED_FILE, 0644);
        if (fd >= 0) {
-               if (close(fd) < 0)
+               if (close(fd) < 0) {
                        ErrPrint("close: %s\n", strerror(errno));
+               }
        } else {
                ErrPrint("Create .live.paused: %s\n", strerror(errno));
        }
@@ -84,8 +85,9 @@ static inline void touch_paused_file(void)
 
 static inline void remove_paused_file(void)
 {
-       if (unlink(PAUSED_FILE) < 0)
+       if (unlink(PAUSED_FILE) < 0) {
                ErrPrint("Unlink .live.paused: %s\n", strerror(errno));
+       }
 }
 
 static inline int get_pid(Ecore_X_Window win)
@@ -133,15 +135,17 @@ HAPI void xmonitor_handle_state_changes(void)
        struct event_item *item;
 
        paused = client_is_all_paused() || setting_is_lcd_off();
-       if (s_info.paused == paused)
+       if (s_info.paused == paused) {
                return;
+       }
 
        s_info.paused = paused;
 
        if (s_info.paused) {
                EINA_LIST_FOREACH(s_info.pause_list, l, item) {
-                       if (item->cb)
+                       if (item->cb) {
                                item->cb(item->user_data);
+                       }
                }
 
                touch_paused_file();
@@ -152,8 +156,9 @@ HAPI void xmonitor_handle_state_changes(void)
                remove_paused_file();
 
                EINA_LIST_FOREACH(s_info.resume_list, l, item) {
-                       if (item->cb)
+                       if (item->cb) {
                                item->cb(item->user_data);
+                       }
                }
        }
 }
@@ -164,8 +169,9 @@ HAPI int xmonitor_update_state(int target_pid)
        struct client_node *client;
        int pid;
 
-       if (!USE_XMONITOR || target_pid < 0)
+       if (!USE_XMONITOR || target_pid < 0) {
                return LB_STATUS_SUCCESS;
+       }
 
        win = ecore_x_window_focus_get();
 
@@ -211,16 +217,19 @@ static Eina_Bool client_cb(void *data, int type, void *event)
        int pid;
 
        pid = get_pid(info->win);
-       if (pid <= 0)
+       if (pid <= 0) {
                return ECORE_CALLBACK_PASS_ON;
+       }
 
        client = client_find_by_pid(pid);
-       if (!client)
+       if (!client) {
                return ECORE_CALLBACK_PASS_ON;
+       }
 
        name = ecore_x_atom_name_get(info->message_type);
-       if (!name)
+       if (!name) {
                return ECORE_CALLBACK_PASS_ON;
+       }
 
        if (!strcmp(name, "_X_ILLUME_DEACTIVATE_WINDOW")) {
                xmonitor_pause(client);
@@ -264,10 +273,11 @@ static inline void sniff_all_windows(void)
 
        win_stack = NULL;
 
-       if (new_item->wins)
+       if (new_item->wins) {
                win_stack = eina_list_append(win_stack, new_item);
-       else
+       } else {
                DbgFree(new_item);
+       }
 
        while ((item = eina_list_nth(win_stack, 0))) {
                win_stack = eina_list_remove(win_stack, item);
@@ -345,8 +355,9 @@ static inline void disable_xmonitor(void)
 
 static inline int enable_xmonitor(void)
 {
-       if (ecore_x_composite_query() == EINA_FALSE)
+       if (ecore_x_composite_query() == EINA_FALSE) {
                DbgPrint("====> COMPOSITOR IS NOT ENABLED\n");
+       }
 
        s_info.create_handler =
                ecore_event_handler_add(ECORE_X_EVENT_WINDOW_CREATE,
@@ -387,23 +398,26 @@ HAPI int xmonitor_init(void)
        if (USE_XMONITOR) {
                int ret;
                ret = enable_xmonitor();
-               if (ret < 0)
+               if (ret < 0) {
                        return ret;
+               }
        }
 
        s_info.paused = client_is_all_paused() || setting_is_lcd_off();
-       if (s_info.paused)
+       if (s_info.paused) {
                touch_paused_file();
-       else
+       } else {
                remove_paused_file();
+       }
 
        return LB_STATUS_SUCCESS;
 }
 
 HAPI void xmonitor_fini(void)
 {
-       if (USE_XMONITOR)
+       if (USE_XMONITOR) {
                disable_xmonitor();
+       }
 }
 
 HAPI int xmonitor_add_event_callback(enum xmonitor_event event, int (*cb)(void *user_data), void *user_data)
index 705b100..8cc024e 100644 (file)
@@ -291,6 +291,7 @@ static inline void ls(void)
 static void send_slave_list(void)
 {
        struct packet *packet;
+       int ret;
 
        if (s_info.cmd != NOP) {
                printf("Previous command is not finished\n");
@@ -303,8 +304,13 @@ static void send_slave_list(void)
                return;
        }
 
-       com_core_packet_send_only(s_info.fd, packet);
+       ret = com_core_packet_send_only(s_info.fd, packet);
        packet_destroy(packet);
+       if (ret < 0) {
+               printf("Failed to send a packet: %d\n", ret);
+               return;
+       }
+
        s_info.cmd = SLAVE_LIST;
        s_info.age++;
 }
@@ -316,6 +322,7 @@ static void send_slave_list(void)
 static void send_command(const char *cmd, const char *var, const char *val)
 {
        struct packet *packet;
+       int ret;
 
        if (s_info.cmd != NOP) {
                printf("Previous command is not finished\n");
@@ -323,8 +330,18 @@ static void send_command(const char *cmd, const char *var, const char *val)
        }
 
        packet = packet_create_noack("master_ctrl", "sss", cmd, var, val);
-       com_core_packet_send_only(s_info.fd, packet);
+       if (!packet) {
+               printf("Failed to create a ctrl packet\n");
+               return;
+       }
+
+       ret = com_core_packet_send_only(s_info.fd, packet);
        packet_destroy(packet);
+       if (ret < 0) {
+               printf("Failed to send packet ctrl\n");
+               return;
+       }
+
        s_info.cmd = MASTER_CTRL;
        s_info.age++;
 }
@@ -385,6 +402,7 @@ static int pkglist_cb(const char *appid, const char *lbid, int is_prime, void *d
 static void send_pkg_list(void)
 {
        struct packet *packet;
+       int ret;
 
        if (s_info.cmd != NOP) {
                printf("Previous command is not finished\n");
@@ -397,8 +415,13 @@ static void send_pkg_list(void)
                return;
        }
 
-       com_core_packet_send_only(s_info.fd, packet);
+       ret = com_core_packet_send_only(s_info.fd, packet);
        packet_destroy(packet);
+       if (ret < 0) {
+               printf("Failed to create a packet\n");
+               return;
+       }
+
        s_info.cmd = PKG_LIST;
        s_info.age++;
 
@@ -411,6 +434,7 @@ static void send_inst_delete(void)
        struct node *parent;
        const char *name;
        struct instance *inst;
+       int ret;
 
        if (s_info.cmd != NOP) {
                printf("Previous command is not finished\n");
@@ -443,8 +467,13 @@ static void send_inst_delete(void)
                return;
        }
 
-       com_core_packet_send_only(s_info.fd, packet);
+       ret = com_core_packet_send_only(s_info.fd, packet);
        packet_destroy(packet);
+       if (ret < 0) {
+               printf("Failed to send a packet: %d\n", ret);
+               return;
+       }
+
        s_info.cmd = INST_CTRL;
        s_info.age++;
 }
@@ -452,6 +481,7 @@ static void send_inst_delete(void)
 static void send_inst_list(const char *pkgname)
 {
        struct packet *packet;
+       int ret;
 
        if (s_info.cmd != NOP) {
                printf("Previous command is not finished\n");
@@ -464,8 +494,13 @@ static void send_inst_list(const char *pkgname)
                return;
        }
 
-       com_core_packet_send_only(s_info.fd, packet);
+       ret = com_core_packet_send_only(s_info.fd, packet);
        packet_destroy(packet);
+       if (ret < 0) {
+               printf("Failed to send a packet: %d\n", ret);
+               return;
+       }
+
        s_info.cmd = INST_LIST;
        s_info.age++;
 }