libfprint/SOURCES/0023-fp-device-Support-vari...

81 lines
2.6 KiB
Diff

From 555fa2dc485b455faa730406faf57acd4d954197 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= <mail@3v1n0.net>
Date: Mon, 25 Nov 2019 21:22:47 +0100
Subject: [PATCH 023/181] fp-device: Support variadic arguments to error
functions
Make possible to generate a formatted message when creating an error from
a device, without having save it first.
---
libfprint/fp-device.c | 26 ++++++++++++++++++++++----
libfprint/fpi-device.h | 6 ++++--
2 files changed, 26 insertions(+), 6 deletions(-)
diff --git a/libfprint/fp-device.c b/libfprint/fp-device.c
index 480d5cf..13f1b5a 100644
--- a/libfprint/fp-device.c
+++ b/libfprint/fp-device.c
@@ -243,9 +243,18 @@ fpi_device_error_new (FpDeviceError error)
* and similar calls.
*/
GError *
-fpi_device_retry_new_msg (FpDeviceRetry error, const gchar *msg)
+fpi_device_retry_new_msg (FpDeviceRetry device_error,
+ const gchar *msg,
+ ...)
{
- return g_error_new_literal (FP_DEVICE_RETRY, error, msg);
+ GError *error;
+ va_list args;
+
+ va_start (args, msg);
+ error = g_error_new_valist (FP_DEVICE_RETRY, device_error, msg, args);
+ va_end (args);
+
+ return error;
}
/**
@@ -257,9 +266,18 @@ fpi_device_retry_new_msg (FpDeviceRetry error, const gchar *msg)
* and similar calls.
*/
GError *
-fpi_device_error_new_msg (FpDeviceError error, const gchar *msg)
+fpi_device_error_new_msg (FpDeviceError device_error,
+ const gchar *msg,
+ ...)
{
- return g_error_new_literal (FP_DEVICE_ERROR, error, msg);
+ GError *error;
+ va_list args;
+
+ va_start (args, msg);
+ error = g_error_new_valist (FP_DEVICE_ERROR, device_error, msg, args);
+ va_end (args);
+
+ return error;
}
static gboolean
diff --git a/libfprint/fpi-device.h b/libfprint/fpi-device.h
index a206798..d83a5a3 100644
--- a/libfprint/fpi-device.h
+++ b/libfprint/fpi-device.h
@@ -181,9 +181,11 @@ GError * fpi_device_retry_new (FpDeviceRetry error);
GError * fpi_device_error_new (FpDeviceError error);
GError * fpi_device_retry_new_msg (FpDeviceRetry error,
- const gchar *msg);
+ const gchar *msg,
+ ...) G_GNUC_PRINTF (2, 3);
GError * fpi_device_error_new_msg (FpDeviceError error,
- const gchar *msg);
+ const gchar *msg,
+ ...) G_GNUC_PRINTF (2, 3);
guint64 fpi_device_get_driver_data (FpDevice *device);
--
2.24.1