]> sigrok.org Git - libsigrok.git/commitdiff
ols: Get GString content from proper API calls
authorMarek Vasut <redacted>
Sat, 28 Oct 2023 07:12:48 +0000 (09:12 +0200)
committerGerhard Sittig <redacted>
Sat, 28 Oct 2023 09:14:02 +0000 (11:14 +0200)
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 <redacted>
src/hardware/openbench-logic-sniffer/protocol.c
src/hardware/pipistrello-ols/protocol.c

index 528b05ce0ed6ef70a08b7769500d805327b7dadb..125c279d0f8f11cb455089a2e41c3df937a68d75 100644 (file)
@@ -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);
index 1b54dd164e23075f4fb3c77c53fb3a810d5bf081..8f6f97f7d716e5aac585a72f49cf70a667517b6a 100644 (file)
@@ -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;
 }