From 90c4afded4e669464c866235698d16d9bd940964 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Mon, 19 Feb 2024 22:14:14 +0100 Subject: [PATCH] cleanup: Use non-const pointers for non constant cases We had various cases in which we were using const pointers for non constant data, and in fact we were allocating and free'ing them. So let's handle all these case properly, so that we won't have newer GLib complaining at us! --- libfprint/drivers/elanmoc/elanmoc.c | 4 ++-- libfprint/drivers/focaltech_moc/focaltech_moc.c | 4 ++-- libfprint/fp-device-private.h | 2 +- libfprint/fpi-ssm.c | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/libfprint/drivers/elanmoc/elanmoc.c b/libfprint/drivers/elanmoc/elanmoc.c index 0261bfff..e86b79a2 100644 --- a/libfprint/drivers/elanmoc/elanmoc.c +++ b/libfprint/drivers/elanmoc/elanmoc.c @@ -50,9 +50,9 @@ elanmoc_compose_cmd ( const struct elanmoc_cmd *cmd_info ) { - g_autofree char *cmd_buf = NULL; + g_autofree uint8_t *cmd_buf = NULL; - cmd_buf = g_malloc0 (cmd_info->cmd_len); + cmd_buf = g_new0 (uint8_t, cmd_info->cmd_len); if(cmd_info->cmd_len < ELAN_MAX_HDR_LEN) memcpy (cmd_buf, &cmd_info->cmd_header, cmd_info->cmd_len); else diff --git a/libfprint/drivers/focaltech_moc/focaltech_moc.c b/libfprint/drivers/focaltech_moc/focaltech_moc.c index 190ab436..9872c7c7 100644 --- a/libfprint/drivers/focaltech_moc/focaltech_moc.c +++ b/libfprint/drivers/focaltech_moc/focaltech_moc.c @@ -126,12 +126,12 @@ fp_cmd_bcc (uint8_t *data, uint16_t len) static uint8_t * focaltech_moc_compose_cmd (uint8_t cmd, const uint8_t *data, uint16_t len) { - g_autofree char *cmd_buf = NULL; + g_autofree uint8_t *cmd_buf = NULL; FpCmd *fp_cmd = NULL; uint8_t *bcc = NULL; uint16_t header_len = len + sizeof (*bcc); - cmd_buf = g_malloc0 (sizeof (FpCmd) + header_len); + cmd_buf = g_new0 (uint8_t, sizeof (FpCmd) + header_len); fp_cmd = (FpCmd *) cmd_buf; diff --git a/libfprint/fp-device-private.h b/libfprint/fp-device-private.h index 759a678f..1c3702fa 100644 --- a/libfprint/fp-device-private.h +++ b/libfprint/fp-device-private.h @@ -44,7 +44,7 @@ typedef struct FpDeviceType type; GUsbDevice *usb_device; - const gchar *virtual_env; + gchar *virtual_env; struct { gchar *spidev_path; diff --git a/libfprint/fpi-ssm.c b/libfprint/fpi-ssm.c index c34498ab..b816945f 100644 --- a/libfprint/fpi-ssm.c +++ b/libfprint/fpi-ssm.c @@ -73,7 +73,7 @@ struct _FpiSsm { FpDevice *dev; - const char *name; + char *name; FpiSsm *parentsm; gpointer ssm_data; GDestroyNotify ssm_data_destroy;