0001-swupdate-core-bootloader.c-fix-build-without-reallocarray.patch 1.3 KB

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