You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.6 KiB

  1. commit b9aac36d8d8d3bb05c785aa8f6630338d078f64a
  2. Author: Willy Tarreau <w@1wt.eu>
  3. Date: Sat Nov 20 19:17:38 2021 +0100
  4. BUILD: cli: clear a maybe-unused warning on some older compilers
  5. The SHOW_TOT() and SHOW_AVG() macros used in cli_io_handler_show_activity()
  6. produce a warning on gcc 4.7 on MIPS with threads disabled because the
  7. compiler doesn't know that global.nbthread is necessarily non-null, hence
  8. that at least one iteration is performed. Let's just change the loop for
  9. a do {} while () that lets the compiler know it's always initialized. It
  10. also has the tiny benefit of making the code shorter.
  11. (cherry picked from commit 97b5d07a3e5a33552327bac2e4c9c6a0496f7b5e)
  12. Signed-off-by: Willy Tarreau <w@1wt.eu>
  13. --- a/src/cli.c
  14. +++ b/src/cli.c
  15. @@ -1368,8 +1368,10 @@ static int cli_io_handler_show_activity(
  16. unsigned int _v[MAX_THREADS]; \
  17. unsigned int _tot; \
  18. const unsigned int _nbt = global.nbthread; \
  19. - for (_tot = t = 0; t < _nbt; t++) \
  20. + _tot = t = 0; \
  21. + do { \
  22. _tot += _v[t] = (x); \
  23. + } while (++t < _nbt); \
  24. if (_nbt == 1) { \
  25. chunk_appendf(&trash, " %u\n", _tot); \
  26. break; \
  27. @@ -1386,8 +1388,10 @@ static int cli_io_handler_show_activity(
  28. unsigned int _v[MAX_THREADS]; \
  29. unsigned int _tot; \
  30. const unsigned int _nbt = global.nbthread; \
  31. - for (_tot = t = 0; t < _nbt; t++) \
  32. + _tot = t = 0; \
  33. + do { \
  34. _tot += _v[t] = (x); \
  35. + } while (++t < _nbt); \
  36. if (_nbt == 1) { \
  37. chunk_appendf(&trash, " %u\n", _tot); \
  38. break; \