0002-Fix-different-compiling-issues.patch 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. From d3d179c3c39ec10ec636b325325ad8e18ae9542f Mon Sep 17 00:00:00 2001
  2. From: Horatiu Vultur <horatiu.vultur@microchip.com>
  3. Date: Tue, 1 Sep 2020 13:03:47 +0200
  4. Subject: [PATCH] Fix different compiling issues
  5. [Retrieved from:
  6. https://github.com/microchip-ung/easyframes/commit/d3d179c3c39ec10ec636b325325ad8e18ae9542f]
  7. Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
  8. ---
  9. src/ef-exec.c | 4 ++--
  10. src/ef-parse-bytes.c | 8 ++++++--
  11. src/ef.h | 4 ++--
  12. 3 files changed, 10 insertions(+), 6 deletions(-)
  13. diff --git a/src/ef-exec.c b/src/ef-exec.c
  14. index 3d184a0..824164e 100644
  15. --- a/src/ef-exec.c
  16. +++ b/src/ef-exec.c
  17. @@ -108,7 +108,7 @@ int ring_wait_for_init(tpacket_ring *ring) {
  18. int raw_socket(cmd_socket_t *cmd_socket) {
  19. - int s, res, val, ifidx;
  20. + int s, res, val, ifidx, i;
  21. struct sockaddr_ll sa = {};
  22. struct packet_mreq mr = {};
  23. @@ -194,7 +194,7 @@ int raw_socket(cmd_socket_t *cmd_socket) {
  24. //
  25. // TODO: This does not seem to be needed, if we uses a RX ring buffer
  26. // instead (atleast that seems to work for libpcap)
  27. - for (int i = 0; i < 10000; ++i) {
  28. + for (i = 0; i < 10000; ++i) {
  29. struct msghdr msg = { 0 };
  30. int res = recvmsg(s, &msg, MSG_DONTWAIT);
  31. if (res < 0)
  32. diff --git a/src/ef-parse-bytes.c b/src/ef-parse-bytes.c
  33. index 1dd590f..1785f45 100644
  34. --- a/src/ef-parse-bytes.c
  35. +++ b/src/ef-parse-bytes.c
  36. @@ -2,6 +2,7 @@
  37. #include <errno.h>
  38. #include <stdio.h>
  39. #include <stdlib.h>
  40. +#include <endian.h>
  41. #include <arpa/inet.h>
  42. struct start_with {
  43. @@ -212,7 +213,9 @@ buf_t *parse_bytes(const char *s, int bytes) {
  44. for (s = data_begin; *s; ++s) {
  45. int match_found = 0;
  46. for (i = 0; i < sizeof(has_chars)/sizeof(has_chars[0]); ++i) {
  47. - for (const char *set_i = has_chars[i].char_set; *set_i; ++set_i) {
  48. + const char *set_i;
  49. +
  50. + for (set_i = has_chars[i].char_set; *set_i; ++set_i) {
  51. if (*s == *set_i) {
  52. has_mask |= has_chars[i].mask;
  53. match_found = 1;
  54. @@ -313,6 +316,7 @@ buf_t *parse_bytes(const char *s, int bytes) {
  55. ((has_mask & ~(HAS_HEX_COL)) == 0) && (has_mask & HAS_COLON)) {
  56. // This will be treated as a mac-address
  57. uint8_t m[6] = {};
  58. + const char *x;
  59. // We want to be able to write something like this (like we RFC2373
  60. // specifies for IPv6):
  61. @@ -334,7 +338,7 @@ buf_t *parse_bytes(const char *s, int bytes) {
  62. //po("line: %d data_begin: %s\n", __LINE__, data_begin);
  63. - for (const char *x = data_begin; *x; ++x) {
  64. + for (x = data_begin; *x; ++x) {
  65. int colon = 0;
  66. int val = 0;
  67. diff --git a/src/ef.h b/src/ef.h
  68. index 8926c25..f4c1629 100644
  69. --- a/src/ef.h
  70. +++ b/src/ef.h
  71. @@ -59,8 +59,8 @@ void bl_check(buf_list_t *b);
  72. void bl_reset(buf_list_t *b);
  73. void bset_value(buf_t *b, uint8_t v);
  74. -inline void bl_init(buf_list_t *b) { bl_reset(b); }
  75. -inline void bl_destroy(buf_list_t *b) { bl_reset(b); }
  76. +static inline void bl_init(buf_list_t *b) { bl_reset(b); }
  77. +static inline void bl_destroy(buf_list_t *b) { bl_reset(b); }
  78. int bl_printf_append(buf_list_t *b, const char *format, ...)
  79. __attribute__ ((format (printf, 2, 3)));