Validate parameter before use it.
authorSung-jae Park <nicesj.park@samsung.com>
Mon, 2 Feb 2015 05:38:25 +0000 (14:38 +0900)
committerSung-jae Park <nicesj.park@samsung.com>
Mon, 2 Feb 2015 05:38:25 +0000 (14:38 +0900)
[model] Redwood,Kiran,B3(Wearable)
[binary_type] AP
[customer] Docomo/Orange/ATT/Open
[issue#] N/A
[problem]
[cause]
[solution]
[team] HomeTF
[request]
[horizontal_expansion]

Change-Id: Ifd2eddd1b24f8ad51a00c02ec4fe56e54695b429

src/client_life.c
src/package.c

index eb2d9ae..1d6491b 100644 (file)
@@ -768,7 +768,13 @@ HAPI int client_subscribe_category(struct client_node *client, const char *categ
        struct category_subscribe_item *item;
        Eina_List *l;
 
+       if (!category) {
+               ErrPrint("category: %p\n", category);
+               return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+       }
+
        EINA_LIST_FOREACH(client->category_subscribe_list, l, item) {
+               DbgPrint("item[%p], item->category[%p], category[%p]\n", item, item->category, category);
                if (!strcasecmp(item->category, category)) {
                        DbgPrint("[%s] is already subscribed\n");
                        return DBOX_STATUS_ERROR_ALREADY;
@@ -788,6 +794,7 @@ HAPI int client_subscribe_category(struct client_node *client, const char *categ
                return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
        }
 
+       DbgPrint("Subscribe category[%s]\n", item->category);
        client->category_subscribe_list = eina_list_append(client->category_subscribe_list, item);
        return DBOX_STATUS_ERROR_NONE;
 }
@@ -798,6 +805,11 @@ HAPI int client_unsubscribe_category(struct client_node *client, const char *cat
        Eina_List *l;
        Eina_List *n;
 
+       if (!category) {
+               ErrPrint("category: %p\n", category);
+               return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+       }
+
        EINA_LIST_FOREACH_SAFE(client->category_subscribe_list, l, n, item) {
                if (!strcasecmp(category, item->category)) {
                        client->category_subscribe_list = eina_list_remove(client->category_subscribe_list, item);
@@ -815,7 +827,13 @@ HAPI int client_is_subscribed_by_category(struct client_node *client, const char
        struct category_subscribe_item *item;
        Eina_List *l;
 
+       if (!category) {
+               DbgPrint("category[%p]\n", category);
+               return 0;
+       }
+
        EINA_LIST_FOREACH(client->category_subscribe_list, l, item) {
+               DbgPrint("item[%p], item->cateogyr[%p], category[%p]\n", item, item->category, category);
                if (!strcasecmp(item->category, category)) {
                        return 1;
                }
@@ -828,6 +846,11 @@ HAPI int client_subscribe_group(struct client_node *client, const char *cluster,
 {
        struct subscribe_item *item;
 
+       if (!cluster || !category) {
+               ErrPrint("Cluster[%p] Category[%p]\n", cluster, category);
+               return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+       }
+
        item = malloc(sizeof(*item));
        if (!item) {
                ErrPrint("Heap: %s\n", strerror(errno));
@@ -859,6 +882,11 @@ HAPI int client_unsubscribe_group(struct client_node *client, const char *cluste
        Eina_List *l;
        Eina_List *n;
 
+       if (!cluster || !category) {
+               ErrPrint("cluster: %p, category: %p\n", cluster, category);
+               return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+       }
+
        EINA_LIST_FOREACH_SAFE(client->subscribe_list, l, n, item) {
                if (!strcasecmp(cluster, item->cluster) && !strcasecmp(category, item->category)) {
                        client->subscribe_list = eina_list_remove(client->subscribe_list, item);
@@ -877,6 +905,11 @@ HAPI int client_is_subscribed_group(struct client_node *client, const char *clus
        struct subscribe_item *item;
        Eina_List *l;
 
+       if (!cluster || !category) {
+               ErrPrint("cluster: %p, category: %p\n", cluster, category);
+               return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+       }
+
        EINA_LIST_FOREACH(client->subscribe_list, l, item) {
                if (!strcmp(item->cluster, "*")) {
                        return 1;
index f3cb64b..eeb374c 100644 (file)
@@ -1526,12 +1526,14 @@ 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) == client) {
+                               DbgPrint("Skip owner\n");
                                continue;
                        }
 
                        if (!client_is_subscribed_group(client, instance_cluster(inst), instance_category(inst))
                                && !client_is_subscribed_by_category(client, package_category(instance_package(inst))))
                        {
+                               DbgPrint("Not subscribed [%s]\n", package_category(instance_package(inst)));
                                continue;
                        }
 
@@ -1541,11 +1543,13 @@ HAPI int package_alter_instances_to_client(struct client_node *client, enum alte
                                /* Will be send a created event after the instance gets created event */
                                switch (alter) {
                                case ALTER_CREATE:
+                                       DbgPrint("ALTER_CREATE\n");
                                        if (!instance_has_client(inst, client)) {
                                                instance_add_client(inst, client);
                                        }
                                        break;
                                case ALTER_DESTROY:
+                                       DbgPrint("ALTER_DESTROY\n");
                                        if (instance_has_client(inst, client)) {
                                                instance_del_client(inst, client);
                                        }
@@ -1563,6 +1567,7 @@ HAPI int package_alter_instances_to_client(struct client_node *client, enum alte
                                 */
                                switch (alter) {
                                case ALTER_CREATE:
+                                       DbgPrint("ALTER_CREATE\n");
                                        if (!instance_has_client(inst, client)) {
                                                instance_unicast_created_event(inst, client);
                                                instance_add_client(inst, client);
@@ -1570,6 +1575,7 @@ HAPI int package_alter_instances_to_client(struct client_node *client, enum alte
                                        }
                                        break;
                                case ALTER_DESTROY:
+                                       DbgPrint("ALTER_DESTROY\n");
                                        if (instance_has_client(inst, client)) {
                                                instance_unicast_deleted_event(inst, client, DBOX_STATUS_ERROR_NONE);
                                                instance_del_client(inst, client);
@@ -1581,8 +1587,7 @@ HAPI int package_alter_instances_to_client(struct client_node *client, enum alte
 
                                break;
                        default:
-                               DbgPrint("%s(%s) is not activated (%d)\n",
-                                               package_name(info), instance_id(inst), instance_state(inst));
+                               DbgPrint("%s(%s) is not activated (%d)\n", package_name(info), instance_id(inst), instance_state(inst));
                                break;
                        }
                }