0001-src-schedule.c-fix-build-with-gcc-4.8.patch 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. From 3ccbb67c71aa13b9a37a58363d37a18b8fdbf300 Mon Sep 17 00:00:00 2001
  2. From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
  3. Date: Thu, 29 Oct 2020 13:36:00 +0100
  4. Subject: [PATCH] src/schedule.c: fix build with gcc 4.8
  5. Fix the following build failure with gcc 4.8:
  6. schedule.c:19:2: error: 'for' loop initial declarations are only allowed in C99 mode
  7. for (int i = 0; i < 4; ++i) {
  8. ^
  9. schedule.c:19:2: note: use option -std=c99 or -std=gnu99 to compile your code
  10. schedule.c: In function 'pms2_read_block':
  11. schedule.c:39:2: error: 'for' loop initial declarations are only allowed in C99 mode
  12. for (int i = 0; i < 4; ++i) {
  13. ^
  14. Fixes:
  15. - http://autobuild.buildroot.org/results/079f1454121d38a83c49529c0f6cc8ed61fd5abb
  16. Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
  17. [Upstream status:
  18. https://sourceforge.net/p/sispmctl/git/merge-requests/1]
  19. ---
  20. src/schedule.c | 6 ++++--
  21. 1 file changed, 4 insertions(+), 2 deletions(-)
  22. diff --git a/src/schedule.c b/src/schedule.c
  23. index 4dd908d..1725421 100644
  24. --- a/src/schedule.c
  25. +++ b/src/schedule.c
  26. @@ -15,8 +15,9 @@
  27. static unsigned char
  28. *pms2_write_block(uint8_t action, uint32_t time, unsigned char *ptr)
  29. {
  30. + int i;
  31. *ptr++ = action;
  32. - for (int i = 0; i < 4; ++i) {
  33. + for (i = 0; i < 4; ++i) {
  34. *ptr++ = (uint8_t)time;
  35. time >>= 8;
  36. }
  37. @@ -34,9 +35,10 @@ static unsigned char
  38. static const unsigned char
  39. *pms2_read_block(uint8_t *action, uint32_t *time, const unsigned char *ptr)
  40. {
  41. + int i;
  42. *action = *ptr++;
  43. *time = 0;
  44. - for (int i = 0; i < 4; ++i) {
  45. + for (i = 0; i < 4; ++i) {
  46. *time >>= 8;
  47. *time += (uint32_t)*ptr++ << 24;
  48. }
  49. --
  50. 2.28.0