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