aboutsummaryrefslogtreecommitdiff
path: root/package/socketcand/0001-Fix-GCC10-build-failure.patch
blob: 057cd4065755cbb22525e19f1215e1b6b3d7de99 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
From ae0af080058a576d62c72ffc011d644d0b4dcb98 Mon Sep 17 00:00:00 2001
From: Yegor Yefremov <yegorslists@googlemail.com>
Date: Tue, 7 Jul 2020 19:39:41 +0200
Subject: [PATCH] Fix GCC10 build failure (#17)

GCC10 breaks on multiple definitions:

ld: /tmp/ccFiGYO7.o:(.bss+0x114): multiple definition of `tv'; /tmp/cc7f6J5h.o:(.bss+0x80): first defined here

Change the scope of the related variables.

Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>

[Retrieved from:
https://github.com/linux-can/socketcand/commit/ae0af080058a576d62c72ffc011d644d0b4dcb98]
Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
---
 socketcand.c  | 3 ++-
 state_bcm.c   | 4 ++--
 state_isotp.c | 2 +-
 state_raw.c   | 2 +-
 4 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/socketcand.c b/socketcand.c
index 8d84754..6125be9 100644
--- a/socketcand.c
+++ b/socketcand.c
@@ -102,7 +102,6 @@ socklen_t unaddrlen;
 struct sockaddr_un remote_unaddr;
 socklen_t remote_unaddrlen;
 char* interface_string;
-struct ifreq ifr, ifr_brd;
 
 int state_changed(char *buf, int current_state)
 {
@@ -666,6 +665,8 @@ int receive_command(int socket, char *buffer) {
 }
 
 void determine_adress() {
+	struct ifreq ifr, ifr_brd;
+
 	int probe_socket = socket(AF_INET, SOCK_DGRAM, 0);
 
 	if(probe_socket < 0) {
diff --git a/state_bcm.c b/state_bcm.c
index cfaa8ed..05a5f7c 100644
--- a/state_bcm.c
+++ b/state_bcm.c
@@ -28,8 +28,6 @@
 #define RXLEN 128
 
 int sc = -1;
-fd_set readfds;
-struct timeval tv;
 
 void state_bcm() {
 	int i, j, ret;
@@ -38,6 +36,7 @@ void state_bcm() {
 	struct ifreq ifr;
 	char rxmsg[RXLEN];
 	char buf[MAXLEN];
+	fd_set readfds;
 
 	struct {
 		struct bcm_msg_head msg_head;
@@ -91,6 +90,7 @@ void state_bcm() {
 	}
 
 	if (FD_ISSET(sc, &readfds)) {
+		struct timeval tv;
 
 		ret = recvfrom(sc, &msg, sizeof(msg), 0,
 			       (struct sockaddr*)&caddr, &caddrlen);
diff --git a/state_isotp.c b/state_isotp.c
index 5c671f9..e1b944b 100644
--- a/state_isotp.c
+++ b/state_isotp.c
@@ -25,7 +25,6 @@
 #include <linux/sockios.h>
 
 int si = -1;
-fd_set readfds;
 
 void state_isotp() {
 	int i, items, ret;
@@ -39,6 +38,7 @@ void state_isotp() {
 	char buf[MAXLEN]; /* inet commands to can */
 	unsigned char isobuf[ISOTPLEN+1]; /* binary buffer for isotp socket */
 	unsigned char tmp;
+	fd_set readfds;
 	
 	while(previous_state != STATE_ISOTP) {
 
diff --git a/state_raw.c b/state_raw.c
index e83e6ec..2c49975 100644
--- a/state_raw.c
+++ b/state_raw.c
@@ -25,7 +25,6 @@
 int raw_socket;
 struct ifreq ifr;
 struct sockaddr_can addr;
-fd_set readfds;
 struct msghdr msg;
 struct can_frame frame;
 struct iovec iov;
@@ -36,6 +35,7 @@ struct cmsghdr *cmsg;
 void state_raw() {
 	char buf[MAXLEN];
 	int i, ret, items;
+	fd_set readfds;
 
 	if(previous_state != STATE_RAW) {