From: Marcel Holtmann Date: Tue, 9 Dec 2008 00:54:55 +0000 (+0100) Subject: Fix handling of properties with byte values X-Git-Tag: 2.0_alpha~4508 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=70f5d6b292a3b1e32aa2cfc6900506c35267b31b;p=framework%2Fconnectivity%2Fconnman.git Fix handling of properties with byte values --- diff --git a/src/element.c b/src/element.c index 00da43a..407afc7 100644 --- a/src/element.c +++ b/src/element.c @@ -186,12 +186,20 @@ static void append_property(DBusMessageIter *dict, if (property->value == NULL) return; - if (property->type == DBUS_TYPE_ARRAY) + switch (property->type) { + case DBUS_TYPE_ARRAY: connman_dbus_dict_append_array(dict, property->name, property->subtype, &property->value, property->size); - else + break; + case DBUS_TYPE_STRING: connman_dbus_dict_append_variant(dict, property->name, property->type, &property->value); + break; + default: + connman_dbus_dict_append_variant(dict, property->name, + property->type, property->value); + break; + } } static void add_common_properties(struct connman_element *element, @@ -1068,8 +1076,7 @@ int connman_element_add_static_property(struct connman_element *element, DBG("element %p name %s", element, element->name); - if (type != DBUS_TYPE_STRING && type != DBUS_TYPE_BYTE && - type != DBUS_TYPE_INT32) + if (type != DBUS_TYPE_STRING && type != DBUS_TYPE_BYTE) return -EINVAL; property = g_try_new0(struct connman_property, 1); @@ -1092,11 +1099,6 @@ int connman_element_add_static_property(struct connman_element *element, if (property->value != NULL) memcpy(property->value, value, 1); break; - case DBUS_TYPE_INT32: - property->value = g_try_malloc(sizeof(gint32)); - if (property->value != NULL) - memcpy(property->value, value, sizeof(gint32)); - break; } __connman_element_lock(element); @@ -1438,15 +1440,9 @@ gboolean connman_element_get_static_property(struct connman_element *element, switch (property->type) { case DBUS_TYPE_STRING: *((char **) value) = property->value; - break; - case DBUS_TYPE_BYTE: - *((guint8 *) value) = *((guint8 *) property->value); - break; - case DBUS_TYPE_INT32: - *((gint32 *) value) = *((gint32 *) property->value); + found = TRUE; break; } - found = TRUE; break; } }