diff mbox series

package/swupdate: Add upstream patch to fix build with uclibc

Message ID 20220614161508.419275-1-ben.hutchings@mind.be
State Accepted
Headers show
Series package/swupdate: Add upstream patch to fix build with uclibc | expand

Commit Message

Ben Hutchings June 14, 2022, 4:15 p.m. UTC
Fix the following build failure with uclibc:

core/bootloader.c: In function 'register_bootloader':
core/bootloader.c:28:15: warning: implicit declaration of function 'reallocarray' [-Wimplicit-function-declaration]
   28 |  entry *tmp = reallocarray(available, num_available + 1, sizeof(entry));
      |               ^~~~~~~~~~~~
core/bootloader.c:28:15: warning: initialization of 'entry *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
[...]
.../arm-buildroot-linux-uclibcgnueabi/bin/ld: core/built-in.o: in function `register_bootloader':
(.text.register_bootloader+0x2c): undefined reference to `reallocarray'

Signed-off-by: Ben Hutchings <ben.hutchings@mind.be>
---
 ...der.c-fix-build-without-reallocarray.patch | 35 +++++++++++++++++++
 1 file changed, 35 insertions(+)
 create mode 100644 package/swupdate/0001-swupdate-core-bootloader.c-fix-build-without-reallocarray.patch

Comments

Thomas Petazzoni July 22, 2022, 9:05 p.m. UTC | #1
On Tue, 14 Jun 2022 18:15:09 +0200
Ben Hutchings <ben.hutchings@mind.be> wrote:

> Fix the following build failure with uclibc:
> 
> core/bootloader.c: In function 'register_bootloader':
> core/bootloader.c:28:15: warning: implicit declaration of function 'reallocarray' [-Wimplicit-function-declaration]
>    28 |  entry *tmp = reallocarray(available, num_available + 1, sizeof(entry));
>       |               ^~~~~~~~~~~~
> core/bootloader.c:28:15: warning: initialization of 'entry *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
> [...]
> .../arm-buildroot-linux-uclibcgnueabi/bin/ld: core/built-in.o: in function `register_bootloader':
> (.text.register_bootloader+0x2c): undefined reference to `reallocarray'
> 
> Signed-off-by: Ben Hutchings <ben.hutchings@mind.be>
> ---
>  ...der.c-fix-build-without-reallocarray.patch | 35 +++++++++++++++++++
>  1 file changed, 35 insertions(+)
>  create mode 100644 package/swupdate/0001-swupdate-core-bootloader.c-fix-build-without-reallocarray.patch

Thanks a lot, applied to master after adding a reference to an
autobuilder failure that this patch is fixing. Many thanks!

Thomas
Peter Korsgaard Aug. 11, 2022, 7:32 p.m. UTC | #2
>>>>> "Thomas" == Thomas Petazzoni via buildroot <buildroot@buildroot.org> writes:

 > On Tue, 14 Jun 2022 18:15:09 +0200
 > Ben Hutchings <ben.hutchings@mind.be> wrote:

 >> Fix the following build failure with uclibc:
 >> 
 >> core/bootloader.c: In function 'register_bootloader':
 >> core/bootloader.c:28:15: warning: implicit declaration of function 'reallocarray' [-Wimplicit-function-declaration]
 >> 28 |  entry *tmp = reallocarray(available, num_available + 1, sizeof(entry));
 >> |               ^~~~~~~~~~~~
 >> core/bootloader.c:28:15: warning: initialization of 'entry *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
 >> [...]
 >> .../arm-buildroot-linux-uclibcgnueabi/bin/ld: core/built-in.o: in function `register_bootloader':
 >> (.text.register_bootloader+0x2c): undefined reference to `reallocarray'
 >> 
 >> Signed-off-by: Ben Hutchings <ben.hutchings@mind.be>
 >> ---
 >> ...der.c-fix-build-without-reallocarray.patch | 35 +++++++++++++++++++
 >> 1 file changed, 35 insertions(+)
 >> create mode 100644 package/swupdate/0001-swupdate-core-bootloader.c-fix-build-without-reallocarray.patch

 > Thanks a lot, applied to master after adding a reference to an
 > autobuilder failure that this patch is fixing. Many thanks!

Committed to 2022.05.x, thanks.
diff mbox series

Patch

diff --git a/package/swupdate/0001-swupdate-core-bootloader.c-fix-build-without-reallocarray.patch b/package/swupdate/0001-swupdate-core-bootloader.c-fix-build-without-reallocarray.patch
new file mode 100644
index 0000000000..d90ae7906e
--- /dev/null
+++ b/package/swupdate/0001-swupdate-core-bootloader.c-fix-build-without-reallocarray.patch
@@ -0,0 +1,35 @@ 
+From f30c4771e93cad7e77d7f2add94327865d226553 Mon Sep 17 00:00:00 2001
+From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
+Date: Sun, 15 May 2022 14:53:35 +0200
+Subject: [PATCH] core/bootloader.c: fix build without reallocarray
+
+Use realloc instead of reallocarray to avoid the following build failure
+with uclibc raised since version 2022.05 and
+https://github.com/sbabic/swupdate/commit/b8897ed695e1cd954859142b14ec8546d2e7994a:
+
+microblaze-buildroot-linux-uclibc/bin/ld: core/built-in.o: in function `register_bootloader':
+(.text.register_bootloader+0x30): undefined reference to `reallocarray'
+
+Fixes:
+ - http://autobuild.buildroot.org/results/7208e8189b4a6f35aaa4ed7777ecdd37421a7c7f
+
+Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
+Backported from: f30c4771e93cad7e77d7f2add94327865d226553
+Signed-off-by: Ben Hutchings <ben.hutchings@mind.be>
+---
+ core/bootloader.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/core/bootloader.c b/core/bootloader.c
+index f34cb414..5694d43d 100644
+--- a/core/bootloader.c
++++ b/core/bootloader.c
+@@ -25,7 +25,7 @@ static unsigned int num_available = 0;
+ 
+ int register_bootloader(const char *name, bootloader *bl)
+ {
+-	entry *tmp = reallocarray(available, num_available + 1, sizeof(entry));
++	entry *tmp = realloc(available, (num_available + 1) * sizeof(entry));
+ 	if (!tmp) {
+ 		return -ENOMEM;
+ 	}