54 lines
1.9 KiB
Diff
54 lines
1.9 KiB
Diff
|
|
From 68657107f970ea068b662e7a13b8b3ebcfcb36e1 Mon Sep 17 00:00:00 2001
|
||
|
|
From: Liu Jing <liujing_yewu@cmss.chinamobile.com>
|
||
|
|
Date: Mon, 21 Oct 2024 20:04:58 +0800
|
||
|
|
Subject: [PATCH] chardev/baum: Use definitions to avoid dynamic stack
|
||
|
|
allocation
|
||
|
|
MIME-Version: 1.0
|
||
|
|
Content-Type: text/plain; charset=UTF-8
|
||
|
|
Content-Transfer-Encoding: 8bit
|
||
|
|
|
||
|
|
We know 'x * y' will be at most 'X_MAX * Y_MAX' (which is not
|
||
|
|
a big value, it is actually 84). Instead of having the compiler
|
||
|
|
use variable-length array, declare an array able to hold the
|
||
|
|
maximum 'x * y'.
|
||
|
|
|
||
|
|
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
|
||
|
|
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
|
||
|
|
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
|
||
|
|
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
|
||
|
|
Message-id: 20220819153931.3147384-3-peter.maydell@linaro.org
|
||
|
|
Signed-off-by: Liu Jing <liujing_yewu@cmss.chinamobile.com>
|
||
|
|
---
|
||
|
|
chardev/baum.c | 8 ++++----
|
||
|
|
1 file changed, 4 insertions(+), 4 deletions(-)
|
||
|
|
|
||
|
|
diff --git a/chardev/baum.c b/chardev/baum.c
|
||
|
|
index 79d618e350..522ea1351e 100644
|
||
|
|
--- a/chardev/baum.c
|
||
|
|
+++ b/chardev/baum.c
|
||
|
|
@@ -380,9 +380,9 @@ static int baum_eat_packet(BaumChardev *baum, const uint8_t *buf, int len)
|
||
|
|
switch (req) {
|
||
|
|
case BAUM_REQ_DisplayData:
|
||
|
|
{
|
||
|
|
- uint8_t cells[baum->x * baum->y], c;
|
||
|
|
- uint8_t text[baum->x * baum->y];
|
||
|
|
- uint8_t zero[baum->x * baum->y];
|
||
|
|
+ uint8_t cells[X_MAX * Y_MAX], c;
|
||
|
|
+ uint8_t text[X_MAX * Y_MAX];
|
||
|
|
+ uint8_t zero[X_MAX * Y_MAX];
|
||
|
|
int cursor = BRLAPI_CURSOR_OFF;
|
||
|
|
int i;
|
||
|
|
|
||
|
|
@@ -405,7 +405,7 @@ static int baum_eat_packet(BaumChardev *baum, const uint8_t *buf, int len)
|
||
|
|
}
|
||
|
|
timer_del(baum->cellCount_timer);
|
||
|
|
|
||
|
|
- memset(zero, 0, sizeof(zero));
|
||
|
|
+ memset(zero, 0, baum->x * baum->y);
|
||
|
|
|
||
|
|
brlapi_writeArguments_t wa = {
|
||
|
|
.displayNumber = BRLAPI_DISPLAY_DEFAULT,
|
||
|
|
--
|
||
|
|
2.41.0.windows.1
|
||
|
|
|