summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSung-jae Park <nicesj.park@samsung.com>2013-08-13 10:28:47 +0900
committerSung-jae Park <nicesj.park@samsung.com>2013-08-13 10:28:47 +0900
commit27ab3bb038e6c57f7589f96526edcb0daaccba29 (patch)
tree774bade5aa9bb3f6225c95b89a12f98315ccd14a
parent6e8c159dc831a1838b9688f40c23a7f761d8d20a (diff)
downloadlivebox-service-27ab3bb038e6c57f7589f96526edcb0daaccba29.tar.gz
livebox-service-27ab3bb038e6c57f7589f96526edcb0daaccba29.tar.bz2
livebox-service-27ab3bb038e6c57f7589f96526edcb0daaccba29.zip
Update coding convention
Change-Id: I4a088f7f3969d9e23785d0b4ba46dcc03ee6467f
-rw-r--r--packaging/liblivebox-service.spec7
-rw-r--r--src/dlist.c29
-rw-r--r--src/livebox-service.c282
-rw-r--r--src/util.c14
4 files changed, 222 insertions, 110 deletions
diff --git a/packaging/liblivebox-service.spec b/packaging/liblivebox-service.spec
index 778e3c6..a591e57 100644
--- a/packaging/liblivebox-service.spec
+++ b/packaging/liblivebox-service.spec
@@ -1,6 +1,6 @@
Name: liblivebox-service
Summary: Service API for gathering installed livebox information.
-Version: 0.5.1
+Version: 0.5.2
Release: 1
Group: HomeTF/Livebox
License: Flora License
@@ -34,6 +34,11 @@ Gathering the installed livebox information.
%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}
diff --git a/src/dlist.c b/src/dlist.c
index fa3082a..3ae571b 100644
--- a/src/dlist.c
+++ b/src/dlist.c
@@ -45,8 +45,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;
@@ -71,8 +72,9 @@ struct dlist *dlist_prepend(struct dlist *list, void *data)
struct dlist *item;
item = malloc(sizeof(*item));
- if (!item)
+ if (!item) {
return NULL;
+ }
item->data = data;
@@ -80,8 +82,9 @@ struct dlist *dlist_prepend(struct dlist *list, void *data)
item->prev = item;
item->next = NULL;
} else {
- if (list->prev->next)
+ if (list->prev->next) {
list->prev->next = item;
+ }
item->prev = list->prev;
item->next = list;
@@ -95,16 +98,19 @@ 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)
+ if (l == list) {
list = l->next;
- else
+ } else {
l->prev->next = l->next;
+ }
- if (l->next)
+ if (l->next) {
l->next->prev = l->prev;
+ }
/*!
* \note
* If the removed entry 'l' has no next element, it is the last element.
@@ -113,8 +119,9 @@ struct dlist *dlist_remove(struct dlist *list, struct dlist *l)
*
* If we didn't care about this, the head element(list) can indicates the invalid element.
*/
- else if (list)
+ else if (list) {
list->prev = l->prev;
+ }
free(l);
return list;
@@ -126,8 +133,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;
@@ -169,8 +177,9 @@ struct dlist *dlist_nth(struct dlist *l, int nth)
i = 0;
for (n = l; n; n = n->next) {
- if (i == nth)
+ if (i == nth) {
return n;
+ }
i++;
}
diff --git a/src/livebox-service.c b/src/livebox-service.c
index 90b26cd..785570e 100644
--- a/src/livebox-service.c
+++ b/src/livebox-service.c
@@ -181,8 +181,9 @@ static inline int update_from_file(void)
switch (status) {
case START:
- if (isspace(ch) || ch == EOF)
+ if (isspace(ch) || ch == EOF) {
continue;
+ }
if (ch == '#') {
status = COMMENT;
@@ -217,12 +218,14 @@ static inline int update_from_file(void)
buffer[idx++] = ch;
break;
case TYPE_END:
- if (ch == '=')
+ if (ch == '=') {
status = SIZE_START;
+ }
break;
case SIZE_START:
- if (isspace(ch) || ch == EOF)
+ if (isspace(ch) || ch == EOF) {
continue;
+ }
status = SIZE;
idx = 0;
@@ -249,19 +252,24 @@ static inline int update_from_file(void)
ungetc(ch, fp);
break;
case ERROR:
- if (ch == '\n' || ch == '\r' || ch == '\f')
+ if (ch == '\n' || ch == '\r' || ch == '\f') {
status = START;
+ }
break;
case COMMENT:
- if (ch == '\n' || ch == '\r' || ch == '\f')
+ if (ch == '\n' || ch == '\r' || ch == '\f') {
status = START;
+ }
break;
default:
ErrPrint("Unknown status. couldn't be reach to here\n");
break;
}
} while (!feof(fp));
- fclose(fp);
+
+ if (fclose(fp) != 0) {
+ ErrPrint("fclose: %s\n", strerror(errno));
+ }
return NR_OF_SIZE_LIST - updated;
}
@@ -278,8 +286,9 @@ static int update_resolution(void)
unsigned int depth;
register int i;
- if (s_info.res_resolved)
+ if (s_info.res_resolved) {
return LB_STATUS_SUCCESS;
+ }
disp = XOpenDisplay(NULL);
if (!disp) {
@@ -293,8 +302,9 @@ static int update_resolution(void)
return LB_STATUS_ERROR_FAULT;
}
- if (update_from_file() == 0)
+ if (update_from_file() == 0) {
DbgPrint("Resolution info is all updated by file\n");
+ }
for (i = 0; i < NR_OF_SIZE_LIST; i++) {
SIZE_LIST[i].w = (unsigned int)((double)SIZE_LIST[i].w * (double)width / 720.0f);
@@ -327,8 +337,9 @@ static sqlite3 *open_db(void)
static inline __attribute__((always_inline)) void close_db(sqlite3 *handle)
{
- if (!s_info.handle)
+ if (!s_info.handle) {
db_util_close(handle);
+ }
}
static inline int convert_size_from_type(enum livebox_size_type type, int *width, int *height)
@@ -379,8 +390,9 @@ static inline int convert_size_from_type(enum livebox_size_type type, int *width
return LB_STATUS_ERROR_INVALID;
}
- if (update_resolution() < 0)
+ if (update_resolution() < 0) {
ErrPrint("Failed to update resolution\n");
+ }
*width = SIZE_LIST[idx].w;
*height = SIZE_LIST[idx].h;
@@ -400,8 +412,9 @@ EAPI int livebox_service_change_period(const char *pkgname, const char *id, doub
}
uri = util_id_to_uri(id);
- if (!uri)
+ if (!uri) {
return LB_STATUS_ERROR_MEMORY;
+ }
packet = packet_create("service_change_period", "ssd", pkgname, uri, period);
free(uri);
@@ -445,14 +458,17 @@ EAPI int livebox_service_trigger_update(const char *pkgname, const char *id, con
}
uri = util_id_to_uri(id);
- if (!uri)
+ if (!uri) {
return LB_STATUS_ERROR_MEMORY;
+ }
- if (!cluster)
+ if (!cluster) {
cluster = "user,created";
+ }
- if (!category)
+ if (!category) {
category = "default";
+ }
packet = packet_create("service_update", "ssss", pkgname, uri, cluster, category);
free(uri);
@@ -551,11 +567,13 @@ EAPI int livebox_service_get_pkglist_item(struct pkglist_handle *handle, char **
char *_appid = NULL;
char *_pkgname = NULL;
- if (!handle || handle->type != PKGLIST_TYPE_LB_LIST)
+ if (!handle || handle->type != PKGLIST_TYPE_LB_LIST) {
return LB_STATUS_ERROR_INVALID;
+ }
- if (sqlite3_step(handle->stmt) != SQLITE_ROW)
+ if (sqlite3_step(handle->stmt) != SQLITE_ROW) {
return LB_STATUS_ERROR_NOT_EXIST;
+ }
if (appid) {
tmp = (const char *)sqlite3_column_text(handle->stmt, 0);
@@ -580,22 +598,26 @@ EAPI int livebox_service_get_pkglist_item(struct pkglist_handle *handle, char **
}
}
- if (is_prime)
+ if (is_prime) {
*is_prime = sqlite3_column_int(handle->stmt, 2);
+ }
- if (appid)
+ if (appid) {
*appid = _appid;
+ }
- if (pkgname)
+ if (pkgname) {
*pkgname = _pkgname;
+ }
return LB_STATUS_SUCCESS;
}
EAPI int livebox_service_pkglist_destroy(struct pkglist_handle *handle)
{
- if (!handle || handle->type != PKGLIST_TYPE_LB_LIST)
+ if (!handle || handle->type != PKGLIST_TYPE_LB_LIST) {
return LB_STATUS_ERROR_INVALID;
+ }
handle->type = PKGLIST_TYPE_UNKNOWN;
sqlite3_reset(handle->stmt);
@@ -614,12 +636,14 @@ EAPI int livebox_service_get_pkglist(int (*cb)(const char *appid, const char *pk
int is_prime;
sqlite3 *handle;
- if (!cb)
+ if (!cb) {
return LB_STATUS_ERROR_INVALID;
+ }
handle = open_db();
- if (!handle)
+ if (!handle) {
return LB_STATUS_ERROR_IO;
+ }
ret = sqlite3_prepare_v2(handle, "SELECT appid, pkgid, prime FROM pkgmap", -1, &stmt, NULL);
if (ret != SQLITE_OK) {
@@ -668,12 +692,14 @@ EAPI int livebox_service_get_pkglist_by_pkgid(const char *pkgid, int (*cb)(const
int is_prime;
sqlite3 *handle;
- if (!cb)
+ if (!cb) {
return LB_STATUS_ERROR_INVALID;
+ }
handle = open_db();
- if (!handle)
+ if (!handle) {
return LB_STATUS_ERROR_IO;
+ }
ret = sqlite3_prepare_v2(handle, "SELECT pkgid, prime FROM pkgmap WHERE appid = ?", -1, &stmt, NULL);
if (ret != SQLITE_OK) {
@@ -730,10 +756,11 @@ static int pkgmgr_cb(const pkgmgrinfo_appinfo_h handle, void *user_data)
int ret;
ret = pkgmgrinfo_appinfo_get_appid(handle, &appid);
- if (ret < 0)
+ if (ret < 0) {
ErrPrint("Unable to get appid\n");
- else
+ } else {
cbdata->cb(cbdata->lbid, appid, cbdata->cbdata);
+ }
return 0;
}
@@ -777,8 +804,9 @@ static inline int pkgmgr_get_applist(const char *pkgid, const char *lbid, void (
cbdata.cbdata = data;
ret = pkgmgrinfo_appinfo_get_list(handle, PM_UI_APP, pkgmgr_cb, &cbdata);
- if (ret < 0)
+ if (ret < 0) {
ErrPrint("Failed to get applist\n");
+ }
pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
return ret;
@@ -792,12 +820,14 @@ EAPI int livebox_service_get_applist(const char *lbid, void (*cb)(const char *lb
sqlite3 *handle;
int ret;
- if (!lbid || !cb)
+ if (!lbid || !cb) {
return LB_STATUS_ERROR_INVALID;
+ }
handle = open_db();
- if (!handle)
+ if (!handle) {
return LB_STATUS_ERROR_IO;
+ }
ret = sqlite3_prepare_v2(handle, "SELECT appid FROM pkgmap WHERE (pkgid = ?) or (appid = ?)", -1, &stmt, NULL);
if (ret != SQLITE_OK) {
@@ -864,12 +894,14 @@ EAPI char *livebox_service_mainappid(const char *lbid)
sqlite3 *handle;
char *ret = NULL;
- if (!lbid)
+ if (!lbid) {
return NULL;
+ }
handle = open_db();
- if (!handle)
+ if (!handle) {
return NULL;
+ }
if (sqlite3_prepare_v2(handle, "SELECT appid, uiapp FROM pkgmap WHERE (pkgid = ?) or (appid = ? and prime = 1)", -1, &stmt, NULL) != SQLITE_OK) {
ErrPrint("Error: %s\n", sqlite3_errmsg(handle));
@@ -909,8 +941,9 @@ EAPI char *livebox_service_mainappid(const char *lbid)
ret = pkgmgr_get_mainapp(tmp);
} else {
ret = strdup(pkgid);
- if (!ret)
+ if (!ret) {
ErrPrint("Error: %s\n", strerror(errno));
+ }
}
sqlite3_reset(stmt);
@@ -928,12 +961,14 @@ EAPI int livebox_service_get_supported_size_types(const char *pkgid, int *cnt, i
int size;
int ret;
- if (!types || !cnt || !pkgid)
+ if (!types || !cnt || !pkgid) {
return LB_STATUS_ERROR_INVALID;
+ }
handle = open_db();
- if (!handle)
+ if (!handle) {
return LB_STATUS_ERROR_IO;
+ }
ret = sqlite3_prepare_v2(handle, "SELECT size_type FROM box_size WHERE pkgid = ? ORDER BY size_type ASC", -1, &stmt, NULL);
if (ret != SQLITE_OK) {
@@ -951,8 +986,9 @@ EAPI int livebox_service_get_supported_size_types(const char *pkgid, int *cnt, i
goto out;
}
- if (*cnt > NR_OF_SIZE_LIST)
+ if (*cnt > NR_OF_SIZE_LIST) {
*cnt = NR_OF_SIZE_LIST;
+ }
ret = 0;
while (sqlite3_step(stmt) == SQLITE_ROW && ret < *cnt) {
@@ -984,15 +1020,17 @@ static inline char *cur_locale(void)
break;
}
- if (*ptr == '_')
+ if (*ptr == '_') {
*ptr = '-';
+ }
ptr++;
}
} else {
language = strdup("en-us");
- if (!language)
+ if (!language) {
ErrPrint("Heap: %s\n", strerror(errno));
+ }
}
return language;
@@ -1006,8 +1044,9 @@ static inline char *get_default_name(const char *pkgid)
int ret;
handle = open_db();
- if (!handle)
+ if (!handle) {
return NULL;
+ }
ret = sqlite3_prepare_v2(handle, "SELECT name FROM client WHERE pkgid = ?", -1, &stmt, NULL);
if (ret != SQLITE_OK) {
@@ -1029,8 +1068,9 @@ static inline char *get_default_name(const char *pkgid)
tmp = (const char *)sqlite3_column_text(stmt, 0);
if (tmp && strlen(tmp)) {
name = strdup(tmp);
- if (!name)
+ if (!name) {
ErrPrint("Heap: %s\n", strerror(errno));
+ }
}
}
@@ -1049,8 +1089,9 @@ static inline char *get_default_icon(const char *pkgid)
int ret;
handle = open_db();
- if (!handle)
+ if (!handle) {
return NULL;
+ }
ret = sqlite3_prepare_v2(handle, "SELECT icon FROM client WHERE pkgid = ?", -1, &stmt, NULL);
if (ret != SQLITE_OK) {
@@ -1072,8 +1113,9 @@ static inline char *get_default_icon(const char *pkgid)
tmp = (const char *)sqlite3_column_text(stmt, 0);
if (tmp && strlen(tmp)) {
icon = strdup(tmp);
- if (!icon)
+ if (!icon) {
ErrPrint("Heap: %s\n", strerror(errno));
+ }
}
}
@@ -1092,8 +1134,9 @@ EAPI char *livebox_service_content(const char *pkgid)
int ret;
handle = open_db();
- if (!handle)
+ if (!handle) {
return NULL;
+ }
ret = sqlite3_prepare_v2(handle, "SELECT content FROM client WHERE pkgid = ?", -1, &stmt, NULL);
if (ret != SQLITE_OK) {
@@ -1115,8 +1158,9 @@ EAPI char *livebox_service_content(const char *pkgid)
tmp = (const char *)sqlite3_column_text(stmt, 0);
if (tmp && strlen(tmp)) {
content = strdup(tmp);
- if (!content)
+ if (!content) {
ErrPrint("Heap: %s\n", strerror(errno));
+ }
}
}
@@ -1135,8 +1179,9 @@ EAPI char *livebox_service_setup_appid(const char *lbid)
char *appid;
handle = open_db();
- if (!handle)
+ if (!handle) {
return NULL;
+ }
ret = sqlite3_prepare_v2(handle, "SELECT setup FROM client WHERE pkgid = ?", -1, &stmt, NULL);
if (ret != SQLITE_OK) {
@@ -1157,12 +1202,14 @@ EAPI char *livebox_service_setup_appid(const char *lbid)
const char *tmp;
tmp = (const char *)sqlite3_column_text(stmt, 0);
- if (!tmp || !strlen(tmp))
+ if (!tmp || !strlen(tmp)) {
goto out;
+ }
appid = strdup(tmp);
- if (!appid)
+ if (!appid) {
ErrPrint("Error: %s\n", strerror(errno));
+ }
}
out:
@@ -1179,8 +1226,9 @@ EAPI int livebox_service_nodisplay(const char *pkgid)
int ret;
handle = open_db();
- if (!handle)
+ if (!handle) {
return 0;
+ }
ret = sqlite3_prepare_v2(handle, "SELECT nodisplay FROM client WHERE pkgid = ?", -1, &stmt, NULL);
if (ret != SQLITE_OK) {
@@ -1197,10 +1245,11 @@ EAPI int livebox_service_nodisplay(const char *pkgid)
}
ret = sqlite3_step(stmt);
- if (ret == SQLITE_ROW)
+ if (ret == SQLITE_ROW) {
ret = !!sqlite3_column_int(stmt, 0);
- else
+ } else {
ret = 0;
+ }
out:
sqlite3_reset(stmt);
@@ -1217,13 +1266,15 @@ static inline char *get_lb_pkgname_by_appid(const char *appid)
sqlite3 *handle;
int ret;
- if (!appid)
+ if (!appid) {
return NULL;
+ }
pkgid = NULL;
handle = open_db();
- if (!handle)
+ if (!handle) {
return NULL;
+ }
ret = sqlite3_prepare_v2(handle, "SELECT pkgid FROM pkgmap WHERE (appid = ? AND prime = 1) OR pkgid = ?", -1, &stmt, NULL);
if (ret != SQLITE_OK) {
@@ -1252,8 +1303,9 @@ static inline char *get_lb_pkgname_by_appid(const char *appid)
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:
@@ -1392,8 +1444,9 @@ EAPI int livebox_service_mouse_event(const char *pkgid)
int ret;
handle = open_db();
- if (!handle)
+ if (!handle) {
return 0;
+ }
ret = sqlite3_prepare_v2(handle, "SELECT mouse_event FROM client WHERE pkgid = ?", -1, &stmt, NULL);
if (ret != SQLITE_OK) {
@@ -1494,8 +1547,9 @@ EAPI char *livebox_service_preview(const char *pkgid, int size_type)
int printed;
handle = open_db();
- if (!handle)
+ if (!handle) {
return NULL;
+ }
ret = sqlite3_prepare_v2(handle, "SELECT preview FROM box_size WHERE pkgid = ? AND size_type = ?", -1, &stmt, NULL);
if (ret != SQLITE_OK) {
@@ -1586,8 +1640,9 @@ EAPI char *livebox_service_i18n_icon(const char *pkgid, const char *lang)
}
} else {
language = cur_locale();
- if (!language)
+ if (!language) {
return NULL;
+ }
}
handle = open_db();
@@ -1624,8 +1679,9 @@ EAPI char *livebox_service_i18n_icon(const char *pkgid, const char *lang)
icon = get_default_icon(pkgid);
} else {
icon = strdup(tmp);
- if (!icon)
+ if (!icon) {
ErrPrint("Heap: %s\n", strerror(errno));
+ }
}
} else {
icon = get_default_icon(pkgid);
@@ -1655,8 +1711,9 @@ EAPI char *livebox_service_i18n_name(const char *pkgid, const char *lang)
}
} else {
language = cur_locale();
- if (!language)
+ if (!language) {
return NULL;
+ }
}
handle = open_db();
@@ -1693,8 +1750,9 @@ EAPI char *livebox_service_i18n_name(const char *pkgid, const char *lang)
name = get_default_name(pkgid);
} else {
name = strdup(tmp);
- if (!name)
+ if (!name) {
ErrPrint("Heap: %s\n", strerror(errno));
+ }
}
} else {
name = get_default_name(pkgid);
@@ -1715,12 +1773,14 @@ EAPI int livebox_service_get_supported_sizes(const char *pkgid, int *cnt, int *w
int size;
int ret;
- if (!w || !h || !cnt || !pkgid)
+ if (!w || !h || !cnt || !pkgid) {
return LB_STATUS_ERROR_INVALID;
+ }
handle = open_db();
- if (!handle)
+ if (!handle) {
return LB_STATUS_ERROR_IO;
+ }
ret = sqlite3_prepare_v2(handle, "SELECT size_type FROM box_size WHERE pkgid = ? ORDER BY size_type ASC", -1, &stmt, NULL);
if (ret != SQLITE_OK) {
@@ -1738,8 +1798,9 @@ EAPI int livebox_service_get_supported_sizes(const char *pkgid, int *cnt, int *w
goto out;
}
- if (*cnt > NR_OF_SIZE_LIST)
+ if (*cnt > NR_OF_SIZE_LIST) {
*cnt = NR_OF_SIZE_LIST;
+ }
ret = 0;
while (sqlite3_step(stmt) == SQLITE_ROW && ret < *cnt) {
@@ -1765,13 +1826,15 @@ EAPI char *livebox_service_libexec(const char *pkgid)
char *appid;
char *path;
- if (!pkgid)
+ if (!pkgid) {
return NULL;
+ }
libexec = NULL;
handle = open_db();
- if (!handle)
+ if (!handle) {
return NULL;
+ }
ret = sqlite3_prepare_v2(handle, "SELECT pkgmap.appid, provider.libexec FROM pkgmap, provider WHERE pkgmap.pkgid = ? AND provider.pkgid = ?", -1, &stmt, NULL);
if (ret != SQLITE_OK) {
@@ -1843,12 +1906,14 @@ EAPI char *livebox_service_pkgname(const char *appid)
int ret;
char *new_appid;
- if (!appid)
+ if (!appid) {
return NULL;
+ }
lb_pkgname = get_lb_pkgname_by_appid(appid);
- if (lb_pkgname)
+ if (lb_pkgname) {
return lb_pkgname;
+ }
/*!
* \note
@@ -1870,8 +1935,9 @@ EAPI char *livebox_service_pkgname(const char *appid)
lb_pkgname = get_lb_pkgname_by_appid(new_appid);
pkgmgr_appinfo_destroy_appinfo(handle);
- if (!lb_pkgname && util_validate_livebox_package(appid) == 0)
+ if (!lb_pkgname && util_validate_livebox_package(appid) == 0) {
return strdup(appid);
+ }
return lb_pkgname;
}
@@ -1884,8 +1950,9 @@ EAPI char *livebox_service_provider_name(const char *lbid)
int idx = 0;
char *str = SAMSUNG_PREFIX;
- if (!lbid)
+ if (!lbid) {
return NULL;
+ }
while (str[idx] && lbid[idx] && lbid[idx] == str[idx]) {
idx++;
@@ -1958,12 +2025,14 @@ EAPI int livebox_service_is_primary(const char *lbid)
sqlite3 *handle;
int ret = 0;
- if (!lbid)
+ if (!lbid) {
return 0;
+ }
handle = open_db();
- if (!handle)
+ if (!handle) {
return 0;
+ }
ret = sqlite3_prepare_v2(handle, "SELECT prime FROM pkgmap WHERE pkgid = ?", -1, &stmt, NULL);
if (ret != SQLITE_OK) {
@@ -2006,13 +2075,15 @@ EAPI char *livebox_service_appid(const char *pkgname)
int is_prime __attribute__((__unused__));
int ret;
- if (!pkgname)
+ if (!pkgname) {
return NULL;
+ }
appid = NULL;
handle = open_db();
- if (!handle)
+ if (!handle) {
return NULL;
+ }
ret = sqlite3_prepare_v2(handle, "SELECT appid, prime FROM pkgmap WHERE pkgid = ? OR appid = ?", -1, &stmt, NULL);
if (ret != SQLITE_OK) {
@@ -2059,8 +2130,9 @@ EAPI char *livebox_service_appid(const char *pkgname)
}
appid = strdup(new_appid);
- if (!appid)
+ if (!appid) {
ErrPrint("Heap: %s\n", strerror(errno));
+ }
pkgmgr_appinfo_destroy_appinfo(pkg_handle);
goto out;
@@ -2100,13 +2172,15 @@ EAPI char *livebox_service_lb_script_path(const char *pkgid)
char *appid;
char *lb_src;
- if (!pkgid)
+ if (!pkgid) {
return NULL;
+ }
path = NULL;
handle = open_db();
- if (!handle)
+ if (!handle) {
return NULL;
+ }
ret = sqlite3_prepare_v2(handle, "SELECT pkgmap.appid, provider.box_src FROM provider, pkgmap WHERE pkgmap.pkgid = ? AND provider.pkgid = ?", -1, &stmt, NULL);
if (ret != SQLITE_OK) {
@@ -2176,13 +2250,15 @@ EAPI char *livebox_service_lb_script_group(const char *pkgid)
char *group;
char *tmp;
- if (!pkgid)
+ if (!pkgid) {
return NULL;
+ }
group = NULL;
handle = open_db();
- if (!handle)
+ if (!handle) {
return NULL;
+ }
ret = sqlite3_prepare_v2(handle, "SELECT box_group FROM provider WHERE pkgid = ?", -1, &stmt, NULL);
if (ret != SQLITE_OK) {
@@ -2208,8 +2284,9 @@ EAPI char *livebox_service_lb_script_group(const char *pkgid)
tmp = (char *)sqlite3_column_text(stmt, 0);
if (tmp && strlen(tmp)) {
group = strdup(tmp);
- if (!group)
+ if (!group) {
ErrPrint("Heap: %s\n", strerror(errno));
+ }
}
sqlite3_reset(stmt);
@@ -2228,13 +2305,15 @@ EAPI char *livebox_service_pd_script_path(const char *pkgid)
char *pd_src;
const char *appid;
- if (!pkgid)
+ if (!pkgid) {
return NULL;
+ }
path = NULL;
handle = open_db();
- if (!handle)
+ if (!handle) {
return NULL;
+ }
ret = sqlite3_prepare_v2(handle, "SELECT pkgmap.appid, provider.pd_src FROM provider, pkgmap WHERE provider.pkgid = ? AND pkgmap.pkgid = ?", -1, &stmt, NULL);
if (ret != SQLITE_OK) {
@@ -2304,13 +2383,15 @@ EAPI char *livebox_service_pd_script_group(const char *pkgid)
char *group;
char *tmp;
- if (!pkgid)
+ if (!pkgid) {
return NULL;
+ }
group = NULL;
handle = open_db();
- if (!handle)
+ if (!handle) {
return NULL;
+ }
ret = sqlite3_prepare_v2(handle, "SELECT pd_group FROM provider WHERE pkgid = ?", -1, &stmt, NULL);
if (ret != SQLITE_OK) {
@@ -2336,8 +2417,9 @@ EAPI char *livebox_service_pd_script_group(const char *pkgid)
tmp = (char *)sqlite3_column_text(stmt, 0);
if (tmp && strlen(tmp)) {
group = strdup(tmp);
- if (!group)
+ if (!group) {
ErrPrint("Heap: %s\n", strerror(errno));
+ }
}
sqlite3_reset(stmt);
sqlite3_finalize(stmt);
@@ -2354,12 +2436,14 @@ EAPI int livebox_service_enumerate_cluster_list(int (*cb)(const char *cluster, v
int cnt;
int ret;
- if (!cb)
+ if (!cb) {
return LB_STATUS_ERROR_INVALID;
+ }
handle = open_db();
- if (!handle)
+ if (!handle) {
return LB_STATUS_ERROR_IO;
+ }
cnt = 0;
ret = sqlite3_prepare_v2(handle, "SELECT DISTINCT cluster FROM groupinfo", -1, &stmt, NULL);
@@ -2371,11 +2455,13 @@ EAPI int livebox_service_enumerate_cluster_list(int (*cb)(const char *cluster, v
while (sqlite3_step(stmt) == SQLITE_ROW) {
cluster = (const char *)sqlite3_column_text(stmt, 0);
- if (!cluster || !strlen(cluster))
+ if (!cluster || !strlen(cluster)) {
continue;
+ }
- if (cb(cluster, data) < 0)
+ if (cb(cluster, data) < 0) {
break;
+ }
cnt++;
}
@@ -2395,12 +2481,14 @@ EAPI int livebox_service_enumerate_category_list(const char *cluster, int (*cb)(
int cnt;
int ret;
- if (!cluster || !cb)
+ if (!cluster || !cb) {
return LB_STATUS_ERROR_INVALID;
+ }
handle = open_db();
- if (!handle)
+ if (!handle) {
return LB_STATUS_ERROR_IO;
+ }
ret = sqlite3_prepare_v2(handle, "SELECT DISTINCT category FROM groupinfo WHERE cluster = ?", -1, &stmt, NULL);
if (ret != SQLITE_OK) {
@@ -2412,11 +2500,13 @@ EAPI int livebox_service_enumerate_category_list(const char *cluster, int (*cb)(
cnt = 0;
while (sqlite3_step(stmt) == SQLITE_ROW) {
category = (const char *)sqlite3_column_text(stmt, 0);
- if (!category || !strlen(category))
+ if (!category || !strlen(category)) {
continue;
+ }
- if (cb(cluster, category, data) < 0)
+ if (cb(cluster, category, data) < 0) {
break;
+ }
cnt++;
}
@@ -2468,11 +2558,13 @@ EAPI int livebox_service_get_size(int type, int *width, int *height)
int _width;
int _height;
- if (!width)
+ if (!width) {
width = &_width;
+ }
- if (!height)
+ if (!height) {
height = &_height;
+ }
return convert_size_from_type(type, width, height);
}
@@ -2481,12 +2573,14 @@ EAPI int livebox_service_size_type(int width, int height)
{
int idx;
- if (update_resolution() < 0)
+ if (update_resolution() < 0) {
ErrPrint("Failed to update the size list\n");
+ }
for (idx = 0; idx < NR_OF_SIZE_LIST; idx++) {
- if (SIZE_LIST[idx].w == width && SIZE_LIST[idx].h == height)
+ if (SIZE_LIST[idx].w == width && SIZE_LIST[idx].h == height) {
break;
+ }
}
switch (idx) {
diff --git a/src/util.c b/src/util.c
index 04ba967..8b3e92c 100644
--- a/src/util.c
+++ b/src/util.c
@@ -115,8 +115,9 @@ const char *util_basename(const char *name)
{
int length;
length = name ? strlen(name) : 0;
- if (!length)
+ if (!length) {
return ".";
+ }
while (--length > 0 && name[length] != '/');
@@ -228,10 +229,11 @@ char *util_replace_string(const char *src, const char *pattern, const char *repl
continue;
}
- if (n_idx < 0)
+ if (n_idx < 0) {
s_idx = t_idx;
- else
+ } else {
s_idx = n_idx;
+ }
break;
}
@@ -276,8 +278,9 @@ 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;
}
@@ -292,8 +295,9 @@ char *util_conf_get_libexec(const char *pkgname)
}
path = check_native_livebox(pkgname);
- if (!path)
+ if (!path) {
path = check_web_livebox(pkgname);
+ }
return path;
}