Skip to content

Commit

Permalink
gcenumeration: don't check enum entry avalability on read
Browse files Browse the repository at this point in the history
Fixes #678

Removing this check, we will not know anymore if the value returned by the
device is a valid one. But it is the device fault, as on write the availability
is still checked.

And know we avoid an infinite loop on some devices like the one in the issue
report.
  • Loading branch information
EmmanuelP committed Jul 7, 2022
1 parent 6f76be7 commit a1b7cbf
Showing 1 changed file with 0 additions and 28 deletions.
28 changes: 0 additions & 28 deletions src/arvgcenumeration.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,10 +317,6 @@ _get_int_value (ArvGcEnumeration *enumeration, GError **error)
{
GError *local_error = NULL;
gint64 value;
gint64 *available_values;
unsigned n_values;
unsigned i;
gboolean found = FALSE;

g_return_val_if_fail (ARV_IS_GC_ENUMERATION (enumeration), 0);
g_return_val_if_fail (error == NULL || *error == NULL, 0);
Expand All @@ -336,30 +332,6 @@ _get_int_value (ArvGcEnumeration *enumeration, GError **error)
return 0;
}

available_values = arv_gc_enumeration_dup_available_int_values (enumeration, &n_values, &local_error);
if (local_error != NULL) {
g_propagate_error (error, local_error);
return value;
}

if (available_values == NULL) {
g_set_error (error, ARV_GC_ERROR, ARV_GC_ERROR_EMPTY_ENUMERATION,
"[%s] No available entry",
arv_gc_feature_node_get_name (ARV_GC_FEATURE_NODE (enumeration)));
return value;
}

for (i = 0; i < n_values; i++)
if (available_values[i] == value)
found = TRUE;

g_free (available_values);

if (!found)
g_set_error (error, ARV_GC_ERROR, ARV_GC_ERROR_OUT_OF_RANGE,
"[%s] Value not found",
arv_gc_feature_node_get_name (ARV_GC_FEATURE_NODE (enumeration)));

return value;
}

Expand Down

0 comments on commit a1b7cbf

Please sign in to comment.