]>
Commit | Line | Data |
---|---|---|
1 | use proper looping code rather than labels/gotos as some versions of | |
2 | gcc may miscompile the code. | |
3 | ||
4 | Signed-off-by: Robert Moss <robmoss@gentoo.org> | |
5 | Signed-off-by: Mike Frysinger <robmoss@gentoo.org> | |
6 | ||
7 | diff --git a/tracepath.c b/tracepath.c | |
8 | index c3f6f74..7ff85a2 100644 | |
9 | --- a/tracepath.c | |
10 | +++ b/tracepath.c | |
11 | @@ -77,7 +77,7 @@ int recverr(int fd, int ttl) | |
12 | int progress = -1; | |
13 | int broken_router; | |
14 | ||
15 | -restart: | |
16 | + while (1) { | |
17 | memset(&rcvbuf, -1, sizeof(rcvbuf)); | |
18 | iov.iov_base = &rcvbuf; | |
19 | iov.iov_len = sizeof(rcvbuf); | |
20 | @@ -94,7 +94,7 @@ restart: | |
21 | if (res < 0) { | |
22 | if (errno == EAGAIN) | |
23 | return progress; | |
24 | - goto restart; | |
25 | + continue; | |
26 | } | |
27 | ||
28 | progress = mtu; | |
29 | @@ -217,7 +217,7 @@ restart: | |
30 | perror("NET ERROR"); | |
31 | return 0; | |
32 | } | |
33 | - goto restart; | |
34 | + } | |
35 | } | |
36 | ||
37 | int probe_ttl(int fd, int ttl) | |
38 | @@ -228,7 +228,6 @@ int probe_ttl(int fd, int ttl) | |
39 | ||
40 | memset(sndbuf,0,mtu); | |
41 | ||
42 | -restart: | |
43 | for (i=0; i<10; i++) { | |
44 | int res; | |
45 | ||
46 | @@ -244,7 +243,8 @@ restart: | |
47 | if (res==0) | |
48 | return 0; | |
49 | if (res > 0) | |
50 | - goto restart; | |
51 | + i = 0; | |
52 | + continue; | |
53 | } | |
54 | hisptr = (hisptr + 1)&63; | |
55 | ||
56 | diff --git a/tracepath6.c b/tracepath6.c | |
57 | index 23d6a8c..6d2a95b 100644 | |
58 | --- a/tracepath6.c | |
59 | +++ b/tracepath6.c | |
60 | @@ -71,7 +71,7 @@ int recverr(int fd, int ttl) | |
61 | int progress = -1; | |
62 | int broken_router; | |
63 | ||
64 | -restart: | |
65 | + while (1) { | |
66 | memset(&rcvbuf, -1, sizeof(rcvbuf)); | |
67 | iov.iov_base = &rcvbuf; | |
68 | iov.iov_len = sizeof(rcvbuf); | |
69 | @@ -88,7 +88,7 @@ restart: | |
70 | if (res < 0) { | |
71 | if (errno == EAGAIN) | |
72 | return progress; | |
73 | - goto restart; | |
74 | + continue; | |
75 | } | |
76 | ||
77 | progress = 2; | |
78 | @@ -233,34 +233,29 @@ restart: | |
79 | perror("NET ERROR"); | |
80 | return 0; | |
81 | } | |
82 | - goto restart; | |
83 | + } | |
84 | } | |
85 | ||
86 | int probe_ttl(int fd, int ttl) | |
87 | { | |
88 | - int i; | |
89 | + int i=0, res; | |
90 | char sndbuf[mtu]; | |
91 | struct probehdr *hdr = (struct probehdr*)sndbuf; | |
92 | ||
93 | -restart: | |
94 | - | |
95 | - for (i=0; i<10; i++) { | |
96 | - int res; | |
97 | - | |
98 | - hdr->ttl = ttl; | |
99 | - gettimeofday(&hdr->tv, NULL); | |
100 | - if (send(fd, sndbuf, mtu-overhead, 0) > 0) | |
101 | - break; | |
102 | - res = recverr(fd, ttl); | |
103 | - if (res==0) | |
104 | - return 0; | |
105 | - if (res > 0) | |
106 | - goto restart; | |
107 | - } | |
108 | - | |
109 | - if (i<10) { | |
110 | - int res; | |
111 | - | |
112 | + while (i<10) { | |
113 | + for (i=0; i<10; i++) { | |
114 | + hdr->ttl = ttl; | |
115 | + gettimeofday(&hdr->tv, NULL); | |
116 | + if (send(fd, sndbuf, mtu-overhead, 0) > 0) | |
117 | + break; | |
118 | + res = recverr(fd, ttl); | |
119 | + if (res==0) | |
120 | + return 0; | |
121 | + if (res > 0) { | |
122 | + i = 0; | |
123 | + continue; | |
124 | + } | |
125 | + } | |
126 | data_wait(fd); | |
127 | if (recv(fd, sndbuf, sizeof(sndbuf), MSG_DONTWAIT) > 0) { | |
128 | printf("%2d?: reply received 8)\n", ttl); | |
129 | @@ -268,7 +263,7 @@ restart: | |
130 | } | |
131 | res = recverr(fd, ttl); | |
132 | if (res == 1) | |
133 | - goto restart; | |
134 | + continue; | |
135 | return res; | |
136 | } | |
137 |