0001-ws2811.c-fix-build-with-gcc-4.8.patch 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. From 8faa5c2fb2b04b4fb062255aa807abafc50bff66 Mon Sep 17 00:00:00 2001
  2. From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
  3. Date: Sat, 3 Apr 2021 10:27:20 +0200
  4. Subject: [PATCH] ws2811.c: fix build with gcc 4.8
  5. Fix the following build failure with gcc 4.8 (which has been added by
  6. commit 391f6e856d28510bd9ae4efd3a166da7f73613ab):
  7. lib/ws2811.c: In function 'ws2811_set_custom_gamma_factor':
  8. lib/ws2811.c:1289:5: error: 'for' loop initial declarations are only allowed in C99 mode
  9. for (int chan = 0; chan < RPI_PWM_CHANNELS; chan++)
  10. ^
  11. lib/ws2811.c:1289:5: note: use option -std=c99 or -std=gnu99 to compile your code
  12. lib/ws2811.c:1295:11: error: 'for' loop initial declarations are only allowed in C99 mode
  13. for(int counter = 0; counter < 256; counter++)
  14. ^
  15. Fixes:
  16. - http://autobuild.buildroot.org/results/3d037922484bfc45d0f985f87b38f20c5a4ab064
  17. Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
  18. [Retrieved from:
  19. https://github.com/jgarff/rpi_ws281x/commit/0814bae544f0184ab1600bc2660486874eef5970]
  20. ---
  21. ws2811.c | 5 +++--
  22. 1 file changed, 3 insertions(+), 2 deletions(-)
  23. diff --git a/ws2811.c b/ws2811.c
  24. index f5cdebd..6482796 100644
  25. --- a/lib/ws2811.c
  26. +++ b/lib/ws2811.c
  27. @@ -1286,13 +1286,14 @@ const char * ws2811_get_return_t_str(const ws2811_return_t state)
  28. void ws2811_set_custom_gamma_factor(ws2811_t *ws2811, double gamma_factor)
  29. {
  30. - for (int chan = 0; chan < RPI_PWM_CHANNELS; chan++)
  31. + int chan, counter;
  32. + for (chan = 0; chan < RPI_PWM_CHANNELS; chan++)
  33. {
  34. ws2811_channel_t *channel = &ws2811->channel[chan];
  35. if (channel->gamma)
  36. {
  37. - for(int counter = 0; counter < 256; counter++)
  38. + for(counter = 0; counter < 256; counter++)
  39. {
  40. channel->gamma[counter] = (gamma_factor > 0)? (int)(pow((float)counter / (float)255.00, gamma_factor) * 255.00 + 0.5) : counter;
  41. --
  42. 2.30.2