From: Bert Vermeulen Date: Wed, 22 Oct 2014 20:18:52 +0000 (+0200) Subject: Accept subtype of expected GVariant values. X-Git-Tag: libsigrok-0.4.0~831 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=61b0292217465ea50ebbf8f9c960330d8c1cbacd;p=libsigrok.git Accept subtype of expected GVariant values. --- diff --git a/src/hwdriver.c b/src/hwdriver.c index c46fcdfc..dc727a56 100644 --- a/src/hwdriver.c +++ b/src/hwdriver.c @@ -178,20 +178,25 @@ SR_PRIV int sr_variant_type_check(uint32_t key, GVariant *value) { const struct sr_config_info *info; const GVariantType *type, *expected; + char *expected_string, *type_string; + info = sr_config_info_get(key); if (!info) return SR_OK; + expected = sr_variant_type_get(info->datatype); type = g_variant_get_type(value); - if (!g_variant_type_equal(type, expected)) { - gchar *expected_string = g_variant_type_dup_string(expected); - gchar *type_string = g_variant_type_dup_string(type); + if (!g_variant_type_equal(type, expected) + && !g_variant_type_is_subtype_of(type, expected)) { + expected_string = g_variant_type_dup_string(expected); + type_string = g_variant_type_dup_string(type); sr_err("Wrong variant type for key '%s': expected '%s', got '%s'", info->name, expected_string, type_string); g_free(expected_string); g_free(type_string); return SR_ERR_ARG; } + return SR_OK; }