lib/values.c: use assert() instead of checking error
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Sun, 14 May 2017 21:34:18 +0000 (17:34 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Sun, 28 May 2017 16:57:43 +0000 (12:57 -0400)
In this case we know that it should not fail.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
lib/values.c

index f4810da944399f1b5360525f96e5c38dac4b30ce..42ad8bdd32e569283c27490de6015baf788cf6af 100644 (file)
@@ -196,17 +196,9 @@ struct bt_value *bt_value_array_copy(const struct bt_value *array_obj)
                struct bt_value *element_obj_copy;
                struct bt_value *element_obj = bt_value_array_get(array_obj, i);
 
-               if (!element_obj) {
-                       BT_LOGE("Cannot get array value's element: "
-                               "addr=%p, index=%d",
-                               array_obj, i);
-                       BT_PUT(copy_obj);
-                       goto end;
-               }
-
+               assert(element_obj);
                element_obj_copy = bt_value_copy(element_obj);
                BT_PUT(element_obj);
-
                if (!element_obj_copy) {
                        BT_LOGE("Cannot copy array value's element: "
                                "array-addr=%p, index=%d",
@@ -217,7 +209,6 @@ struct bt_value *bt_value_array_copy(const struct bt_value *array_obj)
 
                ret = bt_value_array_append(copy_obj, element_obj_copy);
                BT_PUT(element_obj_copy);
-
                if (ret) {
                        BT_LOGE("Cannot append to array value: addr=%p",
                                array_obj);
@@ -257,7 +248,6 @@ struct bt_value *bt_value_map_copy(const struct bt_value *map_obj)
                const char *key_str = g_quark_to_string(GPOINTER_TO_UINT(key));
 
                element_obj_copy = bt_value_copy(element_obj);
-
                if (!element_obj_copy) {
                        BT_LOGE("Cannot copy map value's element: "
                                "map-addr=%p, key=\"%s\"",
@@ -268,7 +258,6 @@ struct bt_value *bt_value_map_copy(const struct bt_value *map_obj)
 
                ret = bt_value_map_insert(copy_obj, key_str, element_obj_copy);
                BT_PUT(element_obj_copy);
-
                if (ret) {
                        BT_LOGE("Cannot insert into map value: addr=%p, key=\"%s\"",
                                map_obj, key_str);
This page took 0.025819 seconds and 4 git commands to generate.