libmm-glib,simple-status: avoid shadowing 'properties' variable

../libmm-glib/mm-simple-status.c: In function ‘mm_simple_status_new_from_dictionary’:
  ../libmm-glib/mm-simple-status.c:426:21: warning: declaration of ‘properties’ shadows a global declaration [-Wshadow]
    426 |     MMSimpleStatus *properties;
        |                     ^~~~~~~~~~
  ../libmm-glib/mm-simple-status.c:55:20: note: shadowed declaration is here
     55 | static GParamSpec *properties[PROP_LAST];
        |                    ^~~~~~~~~~
This commit is contained in:
Aleksander Morgado
2021-09-07 11:14:32 +02:00
parent 93a0476b4d
commit 12ada44156

View File

@@ -419,15 +419,16 @@ MMSimpleStatus *
mm_simple_status_new_from_dictionary (GVariant *dictionary, mm_simple_status_new_from_dictionary (GVariant *dictionary,
GError **error) GError **error)
{ {
GError *inner_error = NULL; GError *inner_error = NULL;
GVariantIter iter; GVariantIter iter;
gchar *key; gchar *key;
GVariant *value; GVariant *value;
MMSimpleStatus *properties; g_autoptr(MMSimpleStatus) props = NULL;
props = mm_simple_status_new ();
properties = mm_simple_status_new ();
if (!dictionary) if (!dictionary)
return properties; return g_steal_pointer (&props);
if (!g_variant_is_of_type (dictionary, G_VARIANT_TYPE ("a{sv}"))) { if (!g_variant_is_of_type (dictionary, G_VARIANT_TYPE ("a{sv}"))) {
g_set_error (error, g_set_error (error,
@@ -435,13 +436,11 @@ mm_simple_status_new_from_dictionary (GVariant *dictionary,
MM_CORE_ERROR_INVALID_ARGS, MM_CORE_ERROR_INVALID_ARGS,
"Cannot create Simple status from dictionary: " "Cannot create Simple status from dictionary: "
"invalid variant type received"); "invalid variant type received");
g_object_unref (properties);
return NULL; return NULL;
} }
g_variant_iter_init (&iter, dictionary); g_variant_iter_init (&iter, dictionary);
while (!inner_error && while (!inner_error && g_variant_iter_next (&iter, "{sv}", &key, &value)) {
g_variant_iter_next (&iter, "{sv}", &key, &value)) {
/* Note: we could do a more efficient matching by checking the variant type /* Note: we could do a more efficient matching by checking the variant type
* and just g_object_set()-ing they specific 'key' and value, but we do want * and just g_object_set()-ing they specific 'key' and value, but we do want
* to check which input keys we receive, in order to propagate the error. * to check which input keys we receive, in order to propagate the error.
@@ -454,19 +453,19 @@ mm_simple_status_new_from_dictionary (GVariant *dictionary,
g_str_equal (key, MM_SIMPLE_PROPERTY_CDMA_SID) || g_str_equal (key, MM_SIMPLE_PROPERTY_CDMA_SID) ||
g_str_equal (key, MM_SIMPLE_PROPERTY_CDMA_NID)) { g_str_equal (key, MM_SIMPLE_PROPERTY_CDMA_NID)) {
/* uint properties */ /* uint properties */
g_object_set (properties, g_object_set (props,
key, g_variant_get_uint32 (value), key, g_variant_get_uint32 (value),
NULL); NULL);
} else if (g_str_equal (key, MM_SIMPLE_PROPERTY_3GPP_OPERATOR_CODE) || } else if (g_str_equal (key, MM_SIMPLE_PROPERTY_3GPP_OPERATOR_CODE) ||
g_str_equal (key, MM_SIMPLE_PROPERTY_3GPP_OPERATOR_NAME)) { g_str_equal (key, MM_SIMPLE_PROPERTY_3GPP_OPERATOR_NAME)) {
/* string properties */ /* string properties */
g_object_set (properties, g_object_set (props,
key, g_variant_get_string (value, NULL), key, g_variant_get_string (value, NULL),
NULL); NULL);
} else if (g_str_equal (key, MM_SIMPLE_PROPERTY_CURRENT_BANDS) || } else if (g_str_equal (key, MM_SIMPLE_PROPERTY_CURRENT_BANDS) ||
g_str_equal (key, MM_SIMPLE_PROPERTY_SIGNAL_QUALITY)) { g_str_equal (key, MM_SIMPLE_PROPERTY_SIGNAL_QUALITY)) {
/* remaining complex types, as variant */ /* remaining complex types, as variant */
g_object_set (properties, g_object_set (props,
key, value, key, value,
NULL); NULL);
} else { } else {
@@ -484,11 +483,10 @@ mm_simple_status_new_from_dictionary (GVariant *dictionary,
/* If error, destroy the object */ /* If error, destroy the object */
if (inner_error) { if (inner_error) {
g_propagate_error (error, inner_error); g_propagate_error (error, inner_error);
g_object_unref (properties); return NULL;
properties = NULL;
} }
return properties; return g_steal_pointer (&props);
} }
/*****************************************************************************/ /*****************************************************************************/