Update coding convention.
authorSung-jae Park <nicesj.park@samsung.com>
Tue, 13 Aug 2013 01:19:22 +0000 (10:19 +0900)
committerSung-jae Park <nicesj.park@samsung.com>
Tue, 13 Aug 2013 01:19:22 +0000 (10:19 +0900)
Change-Id: Ic04562a4db5a7cc52d7e507e23102f3d53e34fcc

packaging/liblivebox.spec
src/dlist.c
src/livebox.c
src/snapshot_window.c
src/virtual_window.c

index 5ec837f..f987da5 100644 (file)
@@ -1,6 +1,6 @@
 Name: liblivebox
 Summary: Library for the development of a livebox 
-Version: 0.4.2
+Version: 0.4.3
 Release: 1
 Group: HomeTF/Livebox
 License: Flora License
@@ -27,6 +27,11 @@ Livebox development library (dev)
 %setup -q
 
 %build
+%if 0%{?tizen_build_binary_release_type_eng}
+export CFLAGS="${CFLAGS} -DTIZEN_ENGINEER_MODE"
+export CXXFLAGS="${CXXFLAGS} -DTIZEN_ENGINEER_MODE"
+export FFLAGS="${FFLAGS} -DTIZEN_ENGINEER_MODE"
+%endif
 %cmake .
 make %{?jobs:-j%jobs}
 
index 05800e3..b545904 100644 (file)
@@ -31,8 +31,9 @@ struct dlist *dlist_append(struct dlist *list, void *data)
        struct dlist *item;
 
        item = malloc(sizeof(*item));
-       if (!item)
+       if (!item) {
                return NULL;
+       }
 
        item->next = NULL;
        item->data = data;
@@ -58,8 +59,9 @@ struct dlist *dlist_prepend(struct dlist *list, void *data)
        struct dlist *item;
 
        item = malloc(sizeof(*item));
-       if (!item)
+       if (!item) {
                return NULL;
+       }
 
        if (!list) {
                item->prev = item;
@@ -75,8 +77,9 @@ struct dlist *dlist_prepend(struct dlist *list, void *data)
 
 struct dlist *dlist_remove(struct dlist *list, struct dlist *l)
 {
-       if (!list || !l)
+       if (!list || !l) {
                return NULL;
+       }
 
        if (l == list) {
                l->prev = list->prev;
@@ -85,8 +88,9 @@ struct dlist *dlist_remove(struct dlist *list, struct dlist *l)
                l->prev->next = l->next;
        }
 
-       if (l->next)
+       if (l->next) {
                l->next->prev = l->prev;
+       }
 
        free(l);
        return list;
@@ -98,8 +102,9 @@ struct dlist *dlist_find_data(struct dlist *list, void *data)
        void *_data;
 
        dlist_foreach(list, l, _data) {
-               if (data == _data)
+               if (data == _data) {
                        return l;
+               }
        }
 
        return NULL;
@@ -142,8 +147,9 @@ struct dlist *dlist_nth(struct dlist *l, int nth)
 
        i = 0;
        dlist_foreach(l, n, data) {
-               if (i == nth)
+               if (i == nth) {
                        return l;
+               }
 
                i++;
        }
index adf4c25..646025e 100644 (file)
@@ -141,30 +141,37 @@ PUBLIC int livebox_desc_close(struct livebox_desc *handle)
        struct dlist *n;
        struct block *block;
 
-       if (!handle)
+       if (!handle) {
                return LB_STATUS_ERROR_INVALID;
+       }
 
        dlist_foreach_safe(handle->block_list, l, n, block) {
                handle->block_list = dlist_remove(handle->block_list, l);
 
                fprintf(handle->fp, "{\n");
-               if (block->type)
+               if (block->type) {
                        fprintf(handle->fp, "type=%s\n", block->type);
+               }
 
-               if (block->part)
+               if (block->part) {
                        fprintf(handle->fp, "part=%s\n", block->part);
+               }
 
-               if (block->data)
+               if (block->data) {
                        fprintf(handle->fp, "data=%s\n", block->data);
+               }
 
-               if (block->option)
+               if (block->option) {
                        fprintf(handle->fp, "option=%s\n", block->option);
+               }
 
-               if (block->id)
+               if (block->id) {
                        fprintf(handle->fp, "id=%s\n", block->id);
+               }
 
-               if (block->target_id)
+               if (block->target_id) {
                        fprintf(handle->fp, "target=%s\n", block->target_id);
+               }
                fprintf(handle->fp, "}\n");
 
                free(block->type);
@@ -176,7 +183,9 @@ PUBLIC int livebox_desc_close(struct livebox_desc *handle)
                free(block);
        }
 
-       fclose(handle->fp);
+       if (fclose(handle->fp) != 0) {
+               ErrPrint("fclose: %s\n", strerror(errno));
+       }
        free(handle);
        return LB_STATUS_SUCCESS;
 }
@@ -185,12 +194,14 @@ PUBLIC int livebox_desc_set_category(struct livebox_desc *handle, const char *id
 {
        struct block *block;
 
-       if (!handle || !category)
+       if (!handle || !category) {
                return LB_STATUS_ERROR_INVALID;
+       }
 
        block = calloc(1, sizeof(*block));
-       if (!block)
+       if (!block) {
                return LB_STATUS_ERROR_MEMORY;
+       }
 
        block->type = strdup(LB_DESC_TYPE_INFO);
        if (!block->type) {
@@ -234,12 +245,14 @@ PUBLIC int livebox_desc_set_size(struct livebox_desc *handle, const char *id, in
        struct block *block;
        char buffer[BUFSIZ];
 
-       if (!handle)
+       if (!handle) {
                return LB_STATUS_ERROR_INVALID;
+       }
 
        block = calloc(1, sizeof(*block));
-       if (!block)
+       if (!block) {
                return LB_STATUS_ERROR_MEMORY;
+       }
 
        block->type = strdup(LB_DESC_TYPE_INFO);
        if (!block->type) {
@@ -285,16 +298,19 @@ PUBLIC char *livebox_util_nl2br(const char *str)
        char *ret;
        char *ptr;
 
-       if (!str)
+       if (!str) {
                return NULL;
+       }
 
        len = strlen(str);
-       if (!len)
+       if (!len) {
                return NULL;
+       }
 
        ret = malloc(len + 1);
-       if (!ret)
+       if (!ret) {
                return NULL;
+       }
 
        ptr = ret;
        i = 0;
@@ -347,8 +363,9 @@ PUBLIC int livebox_desc_set_id(struct livebox_desc *handle, int idx, const char
                        free(block->target_id);
                        block->target_id = NULL;
 
-                       if (!id || !strlen(id))
+                       if (!id || !strlen(id)) {
                                return LB_STATUS_SUCCESS;
+                       }
 
                        block->target_id = strdup(id);
                        if (!block->target_id) {
@@ -370,14 +387,17 @@ PUBLIC int livebox_desc_add_block(struct livebox_desc *handle, const char *id, c
 {
        struct block *block;
 
-       if (!handle || !type)
+       if (!handle || !type) {
                return LB_STATUS_ERROR_INVALID;
+       }
 
-       if (!part)
+       if (!part) {
                part = "";
+       }
 
-       if (!data)
+       if (!data) {
                data = "";
+       }
 
        block = calloc(1, sizeof(*block));
        if (!block) {
@@ -498,10 +518,11 @@ static inline int event_handler_wrapper(struct livebox_buffer *buffer, enum buff
        case BUFFER_EVENT_SCROLL_DOWN:
        case BUFFER_EVENT_UNHIGHLIGHT:
                DbgPrint("Accessibility event: %d\n", event);
-               if (ret < 0)
+               if (ret < 0) {
                        (void)provider_send_access_status(pkgname, id, LB_ACCESS_STATUS_ERROR);
-               else
+               } else {
                        (void)provider_send_access_status(pkgname, id, ret);
+               }
                break;
        default:
                break;
@@ -602,8 +623,9 @@ PUBLIC int livebox_release_buffer(struct livebox_buffer *handle)
 {
        struct livebox_buffer_data *user_data;
 
-       if (!handle)
+       if (!handle) {
                return LB_STATUS_ERROR_INVALID;
+       }
 
        user_data = provider_buffer_user_data(handle);
        if (user_data) {
@@ -622,12 +644,14 @@ PUBLIC void *livebox_ref_buffer(struct livebox_buffer *handle)
        int w, h, size;
        int ret;
 
-       if (!handle)
+       if (!handle) {
                return NULL;
+       }
 
        user_data = provider_buffer_user_data(handle);
-       if (!user_data)
+       if (!user_data) {
                return NULL;
+       }
 
        if (user_data->accelerated) {
                DbgPrint("H/W accelerated buffer is allocated\n");
@@ -648,8 +672,9 @@ PUBLIC void *livebox_ref_buffer(struct livebox_buffer *handle)
 
 PUBLIC int livebox_unref_buffer(void *buffer)
 {
-       if (!buffer)
+       if (!buffer) {
                return LB_STATUS_ERROR_INVALID;
+       }
 
        DbgPrint("Unref buffer\n");
        return provider_buffer_unref(buffer);
@@ -661,8 +686,9 @@ PUBLIC int livebox_sync_buffer(struct livebox_buffer *handle)
        const char *pkgname;
        const char *id;
 
-       if (!handle)
+       if (!handle) {
                return LB_STATUS_ERROR_INVALID;
+       }
 
        user_data = provider_buffer_user_data(handle);
        if (!user_data) {
@@ -690,18 +716,21 @@ PUBLIC int livebox_sync_buffer(struct livebox_buffer *handle)
        provider_buffer_sync(handle);
 
        if (user_data->is_pd) {
-               if (provider_send_desc_updated(pkgname, id, NULL) < 0)
+               if (provider_send_desc_updated(pkgname, id, NULL) < 0) {
                        ErrPrint("Failed to send PD updated (%s)\n", id);
+               }
        } else {
                int w;
                int h;
                int pixel_size;
 
-               if (provider_buffer_get_size(handle, &w, &h, &pixel_size) < 0)
+               if (provider_buffer_get_size(handle, &w, &h, &pixel_size) < 0) {
                        ErrPrint("Failed to get size (%s)\n", id);
+               }
 
-               if (provider_send_updated(pkgname, id, w, h, -1.0f, NULL, NULL) < 0)
+               if (provider_send_updated(pkgname, id, w, h, -1.0f, NULL, NULL) < 0) {
                        ErrPrint("Failed to send updated (%s)\n", id);
+               }
        }
 
        return LB_STATUS_SUCCESS;
@@ -709,8 +738,9 @@ PUBLIC int livebox_sync_buffer(struct livebox_buffer *handle)
 
 PUBLIC int livebox_support_hw_buffer(struct livebox_buffer *handle)
 {
-       if (!handle)
+       if (!handle) {
                return LB_STATUS_ERROR_INVALID;
+       }
 
        return provider_buffer_pixmap_is_support_hw(handle);
 }
@@ -720,15 +750,18 @@ PUBLIC int livebox_create_hw_buffer(struct livebox_buffer *handle)
        struct livebox_buffer_data *user_data;
        int ret;
 
-       if (!handle)
+       if (!handle) {
                return LB_STATUS_ERROR_INVALID;
+       }
 
        user_data = provider_buffer_user_data(handle);
-       if (!user_data)
+       if (!user_data) {
                return LB_STATUS_ERROR_INVALID;
+       }
 
-       if (user_data->accelerated)
+       if (user_data->accelerated) {
                return -EALREADY;
+       }
 
        ret = provider_buffer_pixmap_create_hw(handle);
        user_data->accelerated = (ret == 0);
@@ -738,12 +771,14 @@ PUBLIC int livebox_create_hw_buffer(struct livebox_buffer *handle)
 PUBLIC int livebox_destroy_hw_buffer(struct livebox_buffer *handle)
 {
        struct livebox_buffer_data *user_data;
-       if (!handle)
+       if (!handle) {
                return LB_STATUS_ERROR_INVALID;
+       }
 
        user_data = provider_buffer_user_data(handle);
-       if (!user_data || !user_data->accelerated)
+       if (!user_data || !user_data->accelerated) {
                return LB_STATUS_ERROR_INVALID;
+       }
 
        user_data->accelerated = 0;
 
@@ -754,12 +789,14 @@ PUBLIC void *livebox_buffer_hw_buffer(struct livebox_buffer *handle)
 {
        struct livebox_buffer_data *user_data;
 
-       if (!handle)
+       if (!handle) {
                return NULL;
+       }
 
        user_data = provider_buffer_user_data(handle);
-       if (!user_data || !user_data->accelerated)
+       if (!user_data || !user_data->accelerated) {
                return NULL;
+       }
 
        return provider_buffer_pixmap_hw_addr(handle);
 }
@@ -768,15 +805,18 @@ PUBLIC int livebox_buffer_pre_render(struct livebox_buffer *handle)
 {
        struct livebox_buffer_data *user_data;
 
-       if (!handle)
+       if (!handle) {
                return LB_STATUS_ERROR_INVALID;
+       }
 
        user_data = provider_buffer_user_data(handle);
-       if (!user_data)
+       if (!user_data) {
                return LB_STATUS_ERROR_INVALID;
+       }
 
-       if (!user_data->accelerated)
+       if (!user_data->accelerated) {
                return LB_STATUS_SUCCESS;
+       }
 
        /*!
         * \note
@@ -792,15 +832,18 @@ PUBLIC int livebox_buffer_post_render(struct livebox_buffer *handle)
        const char *id;
        struct livebox_buffer_data *user_data;
 
-       if (!handle)
+       if (!handle) {
                return LB_STATUS_ERROR_INVALID;
+       }
 
        user_data = provider_buffer_user_data(handle);
-       if (!user_data)
+       if (!user_data) {
                return LB_STATUS_ERROR_INVALID;
+       }
 
-       if (!user_data->accelerated)
+       if (!user_data->accelerated) {
                return LB_STATUS_SUCCESS;
+       }
 
        pkgname = provider_buffer_pkgname(handle);
        if (!pkgname) {
@@ -821,18 +864,21 @@ PUBLIC int livebox_buffer_post_render(struct livebox_buffer *handle)
        }
 
        if (user_data->is_pd == 1) {
-               if (provider_send_desc_updated(pkgname, id, NULL) < 0)
+               if (provider_send_desc_updated(pkgname, id, NULL) < 0) {
                        ErrPrint("Failed to send PD updated (%s)\n", id);
+               }
        } else {
                int w;
                int h;
                int pixel_size;
 
-               if (provider_buffer_get_size(handle, &w, &h, &pixel_size) < 0)
+               if (provider_buffer_get_size(handle, &w, &h, &pixel_size) < 0) {
                        ErrPrint("Failed to get size (%s)\n", id);
+               }
 
-               if (provider_send_updated(pkgname, id, w, h, -1.0f, NULL, NULL) < 0)
+               if (provider_send_updated(pkgname, id, w, h, -1.0f, NULL, NULL) < 0) {
                        ErrPrint("Failed to send updated (%s)\n", id);
+               }
        }
 
        return LB_STATUS_SUCCESS;
index 97b0b96..e8f9cd4 100644 (file)
@@ -157,8 +157,9 @@ static void del_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
        struct snapshot_info *info;
 
        info = evas_object_data_del(obj, "snapshot,info");
-       if (!info)
+       if (!info) {
                return;
+       }
 
        SECURE_LOGD("Delete object (%s)\n", info->id);
 
@@ -203,16 +204,18 @@ static Eina_Bool direct_snapshot_cb(void *data)
        e = evas_object_evas_get(snapshot_win);
        if (!e) {
                LOGE("Invalid object, failed to get Evas\n");
-               if (flush_cb)
+               if (flush_cb) {
                        flush_cb(snapshot_win, info->id, LB_STATUS_ERROR_FAULT, info->data);
+               }
                return ECORE_CALLBACK_CANCEL;
        }
 
        ee = ecore_evas_ecore_evas_get(e);
        if (!ee) {
                LOGE("Unable to get Ecore_Evas object\n");
-               if (flush_cb)
+               if (flush_cb) {
                        flush_cb(snapshot_win, info->id, LB_STATUS_ERROR_FAULT, info->data);
+               }
                return ECORE_CALLBACK_CANCEL;
        }
 
@@ -222,14 +225,16 @@ static Eina_Bool direct_snapshot_cb(void *data)
        canvas = ecore_evas_buffer_pixels_get(ee);
        if (!canvas) {
                LOGE("Failed to get canvas\n");
-               if (flush_cb)
+               if (flush_cb) {
                        flush_cb(snapshot_win, info->id, LB_STATUS_ERROR_FAULT, info->data);
+               }
                return ECORE_CALLBACK_CANCEL;
        }
 
        status = flush_to_file(canvas, info->id, w, h);
-       if (flush_cb)
+       if (flush_cb) {
                flush_cb(snapshot_win, info->id, status, info->data);
+       }
        return ECORE_CALLBACK_CANCEL;
 }
 
@@ -257,24 +262,27 @@ static Eina_Bool snapshot_cb(void *data)
        e = evas_object_evas_get(snapshot_win);
        if (!e) {
                LOGE("Invalid object\n");
-               if (flush_cb)
+               if (flush_cb) {
                        flush_cb(snapshot_win, info->id, LB_STATUS_ERROR_FAULT, info->data);
+               }
                return ECORE_CALLBACK_CANCEL;
        }
 
        ee = ecore_evas_ecore_evas_get(e);
        if (!ee) {
                LOGE("Invalid object (ee)\n");
-               if (flush_cb)
+               if (flush_cb) {
                        flush_cb(snapshot_win, info->id, LB_STATUS_ERROR_FAULT, info->data);
+               }
                return ECORE_CALLBACK_CANCEL;
        }
 
        canvas = (void*)ecore_evas_buffer_pixels_get(ee);
        if (!canvas) {
                LOGD("Failed to get pixel canvas\n");
-               if (flush_cb)
+               if (flush_cb) {
                        flush_cb(snapshot_win, info->id, LB_STATUS_ERROR_FAULT, info->data);
+               }
                return ECORE_CALLBACK_CANCEL;
        }
 
@@ -383,8 +391,9 @@ static void resize_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
        int oh;
 
        ee = ecore_evas_ecore_evas_get(e);
-       if (!ee)
+       if (!ee) {
                return;
+       }
 
        ecore_evas_geometry_get(ee, NULL, NULL, &w, &h);
        evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
@@ -489,8 +498,9 @@ PUBLIC int livebox_snapshot_window_flush(Evas_Object *snapshot_win, double timeo
                 * or the developer will get confused
                 */
                info->flush_timer = ecore_timer_add(0.0001f, direct_snapshot_cb, snapshot_win);
-               if (!info->flush_timer)
+               if (!info->flush_timer) {
                        return LB_STATUS_ERROR_FAULT;
+               }
        } else if (info->render_cnt) {
                /*!
                 * Try to watit pre-render callback.
@@ -498,8 +508,9 @@ PUBLIC int livebox_snapshot_window_flush(Evas_Object *snapshot_win, double timeo
                 */
                DbgPrint("Rendered %d times already\n", info->render_cnt);
                info->flush_timer = ecore_timer_add(info->timeout, snapshot_cb, snapshot_win);
-               if (!info->flush_timer)
+               if (!info->flush_timer) {
                        return LB_STATUS_ERROR_FAULT;
+               }
        }
 
        info->flush_cb = flush_cb;
@@ -513,8 +524,9 @@ PUBLIC int livebox_snapshot_window_flush(Evas_Object *snapshot_win, double timeo
 PUBLIC int livebox_snapshot_window_del(Evas_Object *snapshot_win)
 {
        Evas *e;
-       if (!snapshot_win || !evas_object_data_get(snapshot_win, "snapshot,info"))
+       if (!snapshot_win || !evas_object_data_get(snapshot_win, "snapshot,info")) {
                return LB_STATUS_ERROR_INVALID;
+       }
 
        e = evas_object_evas_get(snapshot_win);
        evas_event_callback_del(e, EVAS_CALLBACK_RENDER_POST, post_render_cb);
index 27ab079..ef212bb 100644 (file)
@@ -243,8 +243,9 @@ static void free_fb(void *data, void *ptr)
 {
        struct info *info = data;
 
-       if (!info->handle)
+       if (!info->handle) {
                return;
+       }
 
        if (info->is_hw) {
                if (livebox_destroy_hw_buffer(info->handle) == 0) {
@@ -266,8 +267,9 @@ static void resize_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
        Ecore_Evas *ee;
 
        ee = ecore_evas_ecore_evas_get(e);
-       if (!ee)
+       if (!ee) {
                return;
+       }
 
        evas_object_geometry_get(obj, NULL, NULL, &info->width, &info->height);
        SECURE_LOGD("Resize to %dx%d\n", info->width, info->height);
@@ -288,8 +290,9 @@ static void del_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
        struct info *info = data;
 
        ee = ecore_evas_ecore_evas_get(e);
-       if (!ee)
+       if (!ee) {
                return;
+       }
 
        ecore_evas_free(ee);
        free(info->id);
@@ -300,24 +303,28 @@ static void pre_render_cb(void *data, Evas *e, void *event_info)
 {
        struct info *info = data;
 
-       if (!info->handle)
+       if (!info->handle) {
                return;
+       }
 
-       if (info->is_hw)
+       if (info->is_hw) {
                livebox_buffer_pre_render(info->handle);
+       }
 }
 
 static void post_render_cb(void *data, Evas *e, void *event_info)
 {
        struct info *info = data;
 
-       if (!info->handle)
+       if (!info->handle) {
                return;
+       }
 
-       if (info->is_hw)
+       if (info->is_hw) {
                livebox_buffer_post_render(info->handle);
-       else
+       } else {
                livebox_sync_buffer(info->handle);
+       }
 }
 
 PUBLIC Evas_Object *virtual_window_create(const char *id, int width, int height)
@@ -382,16 +389,19 @@ PUBLIC int virtual_window_set_parent_elm(Evas_Object *win, Evas_Object *parent)
        Evas *e;
        Ecore_Evas *ee;
 
-       if (!win)
+       if (!win) {
                return LB_STATUS_ERROR_INVALID;
+       }
 
        e = evas_object_evas_get(win);
-       if (!e)
+       if (!e) {
                return LB_STATUS_ERROR_FAULT;
+       }
 
        ee = ecore_evas_ecore_evas_get(e);
-       if (!ee)
+       if (!ee) {
                return LB_STATUS_ERROR_FAULT;
+       }
 
        ecore_evas_data_set(ee, "parent,elm", parent);
        return 0;