]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
hw/gpio/pca9552: Avoid using g_newa()
authorPhilippe Mathieu-Daudé <philmd@linaro.org>
Thu, 5 Jun 2025 17:56:52 +0000 (19:56 +0200)
committerPhilippe Mathieu-Daudé <philmd@linaro.org>
Tue, 10 Jun 2025 10:59:09 +0000 (12:59 +0200)
We have pin_count <= PCA955X_PIN_COUNT_MAX. Having
PCA955X_PIN_COUNT_MAX = 16, it is safe to explicitly
allocate the char buffer on the stack, without g_newa().

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Glenn Miles <milesg@linux.ibm.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-Id: <20250605193540.59874-2-philmd@linaro.org>

hw/gpio/pca9552.c

index d65c0a2e90fd1aca9ba5843e6d4070201c3af9e9..1e10238b2e011aeeee20c5c6250267ff7f91038a 100644 (file)
@@ -76,7 +76,7 @@ static void pca955x_display_pins_status(PCA955xState *s,
         return;
     }
     if (trace_event_get_state_backends(TRACE_PCA955X_GPIO_STATUS)) {
-        char *buf = g_newa(char, k->pin_count + 1);
+        char buf[PCA955X_PIN_COUNT_MAX + 1];
 
         for (i = 0; i < k->pin_count; i++) {
             if (extract32(pins_status, i, 1)) {