mirror of
https://gitlab.freedesktop.org/libfprint/libfprint.git
synced 2026-09-10 13:00:08 +00:00
fp-print: Use a switch to match the print type
This commit is contained in:
+21
-13
@@ -605,18 +605,16 @@ fp_print_equal (FpPrint *self, FpPrint *other)
|
|||||||
if (g_strcmp0 (self->device_id, other->device_id))
|
if (g_strcmp0 (self->device_id, other->device_id))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (self->type == FPI_PRINT_RAW)
|
switch (self->type)
|
||||||
{
|
{
|
||||||
|
case FPI_PRINT_RAW:
|
||||||
return g_variant_equal (self->data, other->data);
|
return g_variant_equal (self->data, other->data);
|
||||||
}
|
|
||||||
else if (self->type == FPI_PRINT_NBIS)
|
|
||||||
{
|
|
||||||
guint i;
|
|
||||||
|
|
||||||
|
case FPI_PRINT_NBIS:
|
||||||
if (self->prints->len != other->prints->len)
|
if (self->prints->len != other->prints->len)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
for (i = 0; i < self->prints->len; i++)
|
for (guint i = 0; i < self->prints->len; i++)
|
||||||
{
|
{
|
||||||
struct xyt_struct *a = g_ptr_array_index (self->prints, i);
|
struct xyt_struct *a = g_ptr_array_index (self->prints, i);
|
||||||
struct xyt_struct *b = g_ptr_array_index (other->prints, i);
|
struct xyt_struct *b = g_ptr_array_index (other->prints, i);
|
||||||
@@ -626,11 +624,12 @@ fp_print_equal (FpPrint *self, FpPrint *other)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
|
||||||
else
|
case FPI_PRINT_UNDEFINED:
|
||||||
{
|
|
||||||
g_assert_not_reached ();
|
g_assert_not_reached ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_return_val_if_reached (FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define FPI_PRINT_VARIANT_TYPE G_VARIANT_TYPE ("(issbymsmsia{sv}v)")
|
#define FPI_PRINT_VARIANT_TYPE G_VARIANT_TYPE ("(issbymsmsia{sv}v)")
|
||||||
@@ -821,7 +820,9 @@ fp_print_deserialize (const guchar *data,
|
|||||||
finger = finger_int8;
|
finger = finger_int8;
|
||||||
|
|
||||||
/* Assume data is valid at this point if the values are somewhat sane. */
|
/* Assume data is valid at this point if the values are somewhat sane. */
|
||||||
if (type == FPI_PRINT_NBIS)
|
switch (type)
|
||||||
|
{
|
||||||
|
case FPI_PRINT_NBIS:
|
||||||
{
|
{
|
||||||
g_autoptr(GVariant) prints = g_variant_get_child_value (print_data, 0);
|
g_autoptr(GVariant) prints = g_variant_get_child_value (print_data, 0);
|
||||||
guint i;
|
guint i;
|
||||||
@@ -870,7 +871,9 @@ fp_print_deserialize (const guchar *data,
|
|||||||
g_ptr_array_add (result->prints, g_steal_pointer (&xyt));
|
g_ptr_array_add (result->prints, g_steal_pointer (&xyt));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (type == FPI_PRINT_RAW)
|
break;
|
||||||
|
|
||||||
|
case FPI_PRINT_RAW:
|
||||||
{
|
{
|
||||||
g_autoptr(GVariant) fp_data = g_variant_get_child_value (print_data, 0);
|
g_autoptr(GVariant) fp_data = g_variant_get_child_value (print_data, 0);
|
||||||
|
|
||||||
@@ -883,11 +886,16 @@ fp_print_deserialize (const guchar *data,
|
|||||||
NULL);
|
NULL);
|
||||||
g_object_ref_sink (result);
|
g_object_ref_sink (result);
|
||||||
}
|
}
|
||||||
else
|
break;
|
||||||
|
|
||||||
|
case FPI_PRINT_UNDEFINED:
|
||||||
{
|
{
|
||||||
g_warning ("Invalid print type: 0x%X", type);
|
g_autofree char *type_str = g_enum_to_string (fpi_print_type_get_type (), type);
|
||||||
|
g_warning ("Invalid print type: 0x%X (%s)", type, type_str);
|
||||||
|
|
||||||
goto invalid_format;
|
goto invalid_format;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
date = g_date_new_julian (julian_date);
|
date = g_date_new_julian (julian_date);
|
||||||
g_object_set (result,
|
g_object_set (result,
|
||||||
|
|||||||
Reference in New Issue
Block a user