mirror of
https://gitlab.freedesktop.org/libfprint/libfprint.git
synced 2025-11-15 07:38:12 +00:00
examples: Check whether the returned date is valid
Prints may have an invalid date. Extend the checks so that this is also caught in addition to a NULL date.
This commit is contained in:
@@ -143,6 +143,7 @@ on_identify_cb (FpDevice *dev, FpPrint *match, FpPrint *print,
|
||||
if (match)
|
||||
{
|
||||
g_autoptr(FpPrint) matched_print = g_object_ref (match);
|
||||
const GDate *date;
|
||||
char date_str[128] = {};
|
||||
|
||||
identify_data->ret_value = EXIT_SUCCESS;
|
||||
@@ -155,7 +156,8 @@ on_identify_cb (FpDevice *dev, FpPrint *match, FpPrint *print,
|
||||
matched_print = g_steal_pointer (&stored_print);
|
||||
}
|
||||
|
||||
if (fp_print_get_enroll_date (matched_print))
|
||||
date = fp_print_get_enroll_date (matched_print);
|
||||
if (date && g_date_valid (date))
|
||||
g_date_strftime (date_str, G_N_ELEMENTS (date_str), "%Y-%m-%d\0",
|
||||
fp_print_get_enroll_date (matched_print));
|
||||
else
|
||||
|
||||
@@ -161,7 +161,7 @@ on_list_completed (FpDevice *dev,
|
||||
finger_to_string (fp_print_get_finger (print)),
|
||||
fp_print_get_username (print));
|
||||
|
||||
if (date)
|
||||
if (date && g_date_valid (date))
|
||||
{
|
||||
g_date_strftime (buf, G_N_ELEMENTS (buf), "%Y-%m-%d\0", date);
|
||||
g_print (", enrolled on %s", buf);
|
||||
|
||||
@@ -130,10 +130,12 @@ on_match_cb (FpDevice *dev, FpPrint *match, FpPrint *print,
|
||||
|
||||
if (match)
|
||||
{
|
||||
char date_str[128];
|
||||
const GDate *date = fp_print_get_enroll_date (match);
|
||||
char date_str[128] = "<unknown>";
|
||||
|
||||
verify_data->ret_value = EXIT_SUCCESS;
|
||||
|
||||
if (date && g_date_valid (date))
|
||||
g_date_strftime (date_str, G_N_ELEMENTS (date_str), "%Y-%m-%d\0",
|
||||
fp_print_get_enroll_date (match));
|
||||
g_debug ("Match report: device %s matched finger %s successifully "
|
||||
|
||||
Reference in New Issue
Block a user