const char *uri, const char *icon, int allow_duplicate,
result_cb cb, void *data)
{
- struct result_cb_item *item;
- char *appid;
+ struct result_cb_item *item = NULL;
+ char *appid = NULL;
int ret;
- GVariant *body;
+ GVariant *body = NULL;
char *request_id = NULL;
CHECK_SHORTCUT_FEATURE();
if (ret != SHORTCUT_ERROR_NONE) {
/* LCOV_EXCL_START */
SHORTCUT_ERR("ready to send error [%d]", ret);
- return ret;
+ goto out;
/* LCOV_EXCL_STOP */
}
item = malloc(sizeof(struct result_cb_item));
if (!item) {
/* LCOV_EXCL_START */
- if (appid)
- free(appid);
-
SHORTCUT_ERR("Heap: %d\n", errno);
- return SHORTCUT_ERROR_OUT_OF_MEMORY;
+ ret = SHORTCUT_ERROR_OUT_OF_MEMORY;
+ goto out;
/* LCOV_EXCL_STOP */
}
type, uri, icon, allow_duplicate);
ret = _send_async_shortcut(body, item, "add_shortcut");
- if (ret != SHORTCUT_ERROR_NONE) {
- /* LCOV_EXCL_START */
- free(item);
- item = NULL;
- /* LCOV_EXCL_STOP */
- }
+out:
if (appid)
free(appid);
if (body)
g_variant_unref(body);
if (request_id)
free(request_id);
+ if (ret != SHORTCUT_ERROR_NONE && item)
+ free(item);
return ret;
}
const char *widget_id, const char *icon, double period,
int allow_duplicate, result_cb cb, void *data)
{
- struct result_cb_item *item;
- char *appid;
+ struct result_cb_item *item = NULL;
+ char *appid = NULL;
int ret;
- GVariant *body;
+ GVariant *body = NULL;
char *request_id = NULL;
CHECK_SHORTCUT_FEATURE();
if (ret != SHORTCUT_ERROR_NONE) {
/* LCOV_EXCL_START */
SHORTCUT_ERR("ready to send error [%d]", ret);
- return ret;
+ goto out;
/* LCOV_EXCL_STOP */
}
item = malloc(sizeof(struct result_cb_item));
if (!item) {
/* LCOV_EXCL_START */
- if (appid)
- free(appid);
-
SHORTCUT_ERR("Heap: %d\n", errno);
- return SHORTCUT_ERROR_OUT_OF_MEMORY;
+ ret = SHORTCUT_ERROR_OUT_OF_MEMORY;
+ goto out;
/* LCOV_EXCL_STOP */
}
ret = _send_async_shortcut(body, item, "add_shortcut_widget");
- if (ret != SHORTCUT_ERROR_NONE) {
- /* LCOV_EXCL_START */
- free(item);
- item = NULL;
- /* LCOV_EXCL_STOP */
- }
-
+out:
if (appid)
free(appid);
if (body)
g_variant_unref(body);
if (request_id)
free(request_id);
+ if (ret != SHORTCUT_ERROR_NONE && item)
+ free(item);
return ret;
}
EAPI int shortcut_remove_from_home(const char *name, result_cb cb, void *user_data)
{
- struct result_cb_item *item;
- char *appid;
+ struct result_cb_item *item = NULL;
+ char *appid = NULL;
int ret;
- GVariant *body;
+ GVariant *body = NULL;
char *request_id = NULL;
CHECK_SHORTCUT_FEATURE();
if (ret != SHORTCUT_ERROR_NONE) {
/* LCOV_EXCL_START */
SHORTCUT_ERR("ready to send error [%d]", ret);
- return ret;
+ goto out;
/* LCOV_EXCL_STOP */
}
item = malloc(sizeof(struct result_cb_item));
if (!item) {
/* LCOV_EXCL_START */
- if (appid)
- free(appid);
-
SHORTCUT_ERR("Heap: %d\n", errno);
- return SHORTCUT_ERROR_OUT_OF_MEMORY;
+ ret = SHORTCUT_ERROR_OUT_OF_MEMORY;
+ goto out;
/* LCOV_EXCL_STOP */
}
body = g_variant_new("(siss)", request_id, getpid(), appid, name);
ret = _send_async_shortcut(body, item, "remove_shortcut");
- if (ret != SHORTCUT_ERROR_NONE) {
- /* LCOV_EXCL_START */
- free(item);
- item = NULL;
- /* LCOV_EXCL_STOP */
- }
+out:
if (appid)
free(appid);
if (body)
g_variant_unref(body);
if (request_id)
free(request_id);
-
+ if (ret != SHORTCUT_ERROR_NONE && item)
+ free(item);
return ret;
}