2
1

0002-shared-util.c-assert_cc-can-only-be-used-inside-func.patch 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. From 7cd698eb31059012305d8bb7516577c8cd383e32 Mon Sep 17 00:00:00 2001
  2. From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
  3. Date: Sat, 3 Jun 2017 16:52:37 +0200
  4. Subject: [PATCH] shared/util.c: assert_cc() can only be used inside functions
  5. shared/macro.h has two versions of assert_cc, one that uses gcc
  6. _Static_assert(), which requires recent enough gcc versions, and one
  7. that uses a fake array to trigger a build error. The latter can only
  8. work inside functions, so assert_cc() should only be used inside
  9. functions.
  10. Fixes the following build failure when building kmod with old gcc
  11. versions such as gcc 4.3.x:
  12. shared/util.c:52: error: expected identifier or '(' before 'do'
  13. shared/util.c:52: error: expected identifier or '(' before 'while'
  14. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
  15. ---
  16. shared/util.c | 6 ++++--
  17. 1 file changed, 4 insertions(+), 2 deletions(-)
  18. diff --git a/shared/util.c b/shared/util.c
  19. index 9de080a..fd2028d 100644
  20. --- a/shared/util.c
  21. +++ b/shared/util.c
  22. @@ -49,8 +49,6 @@ static const struct kmod_ext {
  23. { }
  24. };
  25. -assert_cc(EAGAIN == EWOULDBLOCK);
  26. -
  27. /* string handling functions and memory allocations */
  28. /* ************************************************************************ */
  29. @@ -201,6 +199,8 @@ ssize_t read_str_safe(int fd, char *buf, size_t buflen)
  30. size_t todo = buflen - 1;
  31. size_t done = 0;
  32. + assert_cc(EAGAIN == EWOULDBLOCK);
  33. +
  34. do {
  35. ssize_t r = read(fd, buf + done, todo);
  36. @@ -226,6 +226,8 @@ ssize_t write_str_safe(int fd, const char *buf, size_t buflen)
  37. size_t todo = buflen;
  38. size_t done = 0;
  39. + assert_cc(EAGAIN == EWOULDBLOCK);
  40. +
  41. do {
  42. ssize_t r = write(fd, buf + done, todo);
  43. --
  44. 2.7.4