From: Marek Vasut Date: Sat, 28 Oct 2023 07:12:48 +0000 (+0200) Subject: ols: Get GString content from proper API calls X-Git-Url: https://sigrok.org/gitweb/?a=commitdiff_plain;h=d41c4131a2dcdb3f1eec7bfc1065e70eb2597158;p=libsigrok.git ols: Get GString content from proper API calls Use the g_string_free() routine's return value instead of pulling the string content out of the buffer structure bypassing the library's API. This improves portability and readability, also happens to silence an "ignoring return value" warning which is seen with GCC 13.2.0. See https://docs.gtk.org/glib/method.String.free.html#return-value for a discussion of the g_string_free() return value. Signed-off-by: Marek Vasut --- diff --git a/src/hardware/openbench-logic-sniffer/protocol.c b/src/hardware/openbench-logic-sniffer/protocol.c index 528b05ce..125c279d 100644 --- a/src/hardware/openbench-logic-sniffer/protocol.c +++ b/src/hardware/openbench-logic-sniffer/protocol.c @@ -292,10 +292,8 @@ SR_PRIV int ols_get_metadata(struct sr_dev_inst *sdi) } } - sdi->model = devname->str; - sdi->version = version->str; - g_string_free(devname, FALSE); - g_string_free(version, FALSE); + sdi->model = g_string_free(devname, FALSE); + sdi->version = g_string_free(version, FALSE); /* Optionally amend received metadata, model specific quirks. */ ols_metadata_quirks(sdi); diff --git a/src/hardware/pipistrello-ols/protocol.c b/src/hardware/pipistrello-ols/protocol.c index 1b54dd16..8f6f97f7 100644 --- a/src/hardware/pipistrello-ols/protocol.c +++ b/src/hardware/pipistrello-ols/protocol.c @@ -325,10 +325,8 @@ SR_PRIV struct sr_dev_inst *p_ols_get_metadata(uint8_t *buf, int bytes_read, str } } - sdi->model = devname->str; - sdi->version = version->str; - g_string_free(devname, FALSE); - g_string_free(version, FALSE); + sdi->model = g_string_free(devname, FALSE); + sdi->version = g_string_free(version, FALSE); return sdi; }