bcm2835-utils: fix gcc-14 build

This commit is contained in:
Rudi Heitbaum 2024-05-22 12:13:17 +00:00
parent 51381a56c7
commit f2805be997
2 changed files with 68 additions and 0 deletions

View File

@ -0,0 +1,29 @@
From 4e4e5736b5c69de3c68c5c02ceddfbe42eb8f915 Mon Sep 17 00:00:00 2001
From: Rudi Heitbaum <rudi@heitbaum.com>
Date: Wed, 22 May 2024 21:29:31 +1000
Subject: [PATCH] vclog: fix compiler error with gcc-14.1
Fixes:
./vclog/vclog.c:199:30: error: 'msg.size' may be used uninitialized [-Werror=maybe-uninitialized]
199 | payload_len = msg.size - sizeof(msg_hdr_t);
| ~~~^~~~~
./vclog/vclog.c:193:23: note: 'msg' declared here
193 | msg_hdr_t msg;
| ^~~
---
vclog/vclog.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/vclog/vclog.c b/vclog/vclog.c
index 85e1366..34590fd 100644
--- a/vclog/vclog.c
+++ b/vclog/vclog.c
@@ -194,6 +194,7 @@ int32_t main(int32_t argc, char *argv[])
uint32_t payload_pos;
uint32_t payload_len;
+ msg.size = 0;
payload_pos = log_copy_wrap(log_buffer, log_size,
read_pos, sizeof(msg), (char *)&msg);
payload_len = msg.size - sizeof(msg_hdr_t);

View File

@ -0,0 +1,39 @@
From dc0fd4723907775bdfc3ffb2a612a04d60789ed8 Mon Sep 17 00:00:00 2001
From: Rudi Heitbaum <rudi@heitbaum.com>
Date: Wed, 22 May 2024 22:04:56 +1000
Subject: [PATCH] vclog: fix max realloc compiler error
Fixes
./vclog/vclog.c:211:34: error: argument 2 value '4294967288' exceeds maximum object size 2147483647 [-Werror=alloc-size-larger-than=]
211 | payload_buffer = realloc(payload_buffer, payload_buffer_size);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ./vclog/vclog.c:17:
../../toolchain/armv7ve-libreelec-linux-gnueabihf/sysroot/usr/include/stdlib.h:683:14: note: in a call to allocation function 'realloc' declared here
683 | extern void *realloc (void *__ptr, size_t __size)
| ^~~~~~~
---
vclog/vclog.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/vclog/vclog.c b/vclog/vclog.c
index 85e1366..24e2b1e 100644
--- a/vclog/vclog.c
+++ b/vclog/vclog.c
@@ -72,6 +72,7 @@ enum
};
#define MAX(x, y) (((x) > (y)) ? (x) : (y))
+#define MIN(x, y) (((x) < (y)) ? (x) : (y))
#define ARRAY_SIZE(_a) (sizeof(_a)/sizeof(_a[0]))
#define FBIODMACOPY _IOW('z', 0x22, struct fb_dmacopy)
@@ -207,7 +208,7 @@ int32_t main(int32_t argc, char *argv[])
if (payload_len > payload_buffer_size)
{
payload_buffer_size = MAX(payload_len, 100); // skip some churn
- payload_buffer = realloc(payload_buffer, payload_buffer_size);
+ payload_buffer = realloc(payload_buffer, MIN(INT32_MAX, payload_buffer_size));
if (!payload_buffer)
die("Out of memory");
}