Skip to content

Commit ac21586

Browse files
committed
Merge branch 'ab/trace2-squelch-gcc-warning'
Workaround compiler warnings. * ab/trace2-squelch-gcc-warning: trace2: refactor to avoid gcc warning under -O3
2 parents 8e444e6 + 4e0a64a commit ac21586

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

trace2/tr2_dst.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -204,15 +204,16 @@ static int tr2_dst_try_uds_connect(const char *path, int sock_type, int *out_fd)
204204

205205
fd = socket(AF_UNIX, sock_type, 0);
206206
if (fd == -1)
207-
return errno;
207+
return -1;
208208

209209
sa.sun_family = AF_UNIX;
210210
strlcpy(sa.sun_path, path, sizeof(sa.sun_path));
211211

212212
if (connect(fd, (struct sockaddr *)&sa, sizeof(sa)) == -1) {
213-
int e = errno;
213+
int saved_errno = errno;
214214
close(fd);
215-
return e;
215+
errno = saved_errno;
216+
return -1;
216217
}
217218

218219
*out_fd = fd;
@@ -227,7 +228,6 @@ static int tr2_dst_try_unix_domain_socket(struct tr2_dst *dst,
227228
{
228229
unsigned int uds_try = 0;
229230
int fd;
230-
int e;
231231
const char *path = NULL;
232232

233233
/*
@@ -271,23 +271,21 @@ static int tr2_dst_try_unix_domain_socket(struct tr2_dst *dst,
271271
}
272272

273273
if (uds_try & TR2_DST_UDS_TRY_STREAM) {
274-
e = tr2_dst_try_uds_connect(path, SOCK_STREAM, &fd);
275-
if (!e)
274+
if (!tr2_dst_try_uds_connect(path, SOCK_STREAM, &fd))
276275
goto connected;
277-
if (e != EPROTOTYPE)
276+
if (errno != EPROTOTYPE)
278277
goto error;
279278
}
280279
if (uds_try & TR2_DST_UDS_TRY_DGRAM) {
281-
e = tr2_dst_try_uds_connect(path, SOCK_DGRAM, &fd);
282-
if (!e)
280+
if (!tr2_dst_try_uds_connect(path, SOCK_DGRAM, &fd))
283281
goto connected;
284282
}
285283

286284
error:
287285
if (tr2_dst_want_warning())
288286
warning("trace2: could not connect to socket '%s' for '%s' tracing: %s",
289287
path, tr2_sysenv_display_name(dst->sysenv_var),
290-
strerror(e));
288+
strerror(errno));
291289

292290
tr2_dst_trace_disable(dst);
293291
return 0;

0 commit comments

Comments
 (0)