libfprint/SOURCES/0053-synaptics-Use-an-autoptr-to-handle-the-FpiUsbTransfe.patch
2021-09-09 20:12:48 +00:00

40 lines
1.4 KiB
Diff

From b5d9916157d5b215224ba799c1a2b707fd435554 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= <mail@3v1n0.net>
Date: Thu, 28 Nov 2019 20:34:20 +0100
Subject: [PATCH 053/181] synaptics: Use an autoptr to handle the
FpiUsbTransfer sync transfers
When using fpi_usb_transfer_submit_sync we still need to unref the transfer
once done with it, so let's use an auto pointer so we free it also on
errors and early returns without having to handle this manually.
---
libfprint/drivers/synaptics/synaptics.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/libfprint/drivers/synaptics/synaptics.c b/libfprint/drivers/synaptics/synaptics.c
index ccaf60e..284973c 100644
--- a/libfprint/drivers/synaptics/synaptics.c
+++ b/libfprint/drivers/synaptics/synaptics.c
@@ -950,7 +950,8 @@ dev_probe (FpDevice *device)
{
FpiDeviceSynaptics *self = FPI_DEVICE_SYNAPTICS (device);
GUsbDevice *usb_dev;
- FpiUsbTransfer *transfer;
+
+ g_autoptr(FpiUsbTransfer) transfer = NULL;
FpiByteReader reader;
GError *error = NULL;
guint16 status;
@@ -985,7 +986,7 @@ dev_probe (FpDevice *device)
if (!fpi_usb_transfer_submit_sync (transfer, 1000, &error))
goto err_close;
-
+ g_clear_pointer (&transfer, fpi_usb_transfer_unref);
transfer = fpi_usb_transfer_new (device);
fpi_usb_transfer_fill_bulk (transfer, USB_EP_REPLY, 40);
if (!fpi_usb_transfer_submit_sync (transfer, 1000, &error))
--
2.24.1