diff options
author | Junio C Hamano <gitster@pobox.com> | 2021-06-14 13:33:28 +0900 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2021-06-14 13:33:28 +0900 |
commit | ac2158649dee9dc0644aefc0be5d25d54f63ad90 (patch) | |
tree | 1459e39560e19df5df414ff91183af8a503e4a4c /trace2 | |
parent | Merge branch 'so/log-m-implies-p' (diff) | |
parent | trace2: refactor to avoid gcc warning under -O3 (diff) | |
download | tgif-ac2158649dee9dc0644aefc0be5d25d54f63ad90.tar.xz |
Merge branch 'ab/trace2-squelch-gcc-warning'
Workaround compiler warnings.
* ab/trace2-squelch-gcc-warning:
trace2: refactor to avoid gcc warning under -O3
Diffstat (limited to 'trace2')
-rw-r--r-- | trace2/tr2_dst.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/trace2/tr2_dst.c b/trace2/tr2_dst.c index ae052a07fe..bda283e7f4 100644 --- a/trace2/tr2_dst.c +++ b/trace2/tr2_dst.c @@ -204,15 +204,16 @@ static int tr2_dst_try_uds_connect(const char *path, int sock_type, int *out_fd) fd = socket(AF_UNIX, sock_type, 0); if (fd == -1) - return errno; + return -1; sa.sun_family = AF_UNIX; strlcpy(sa.sun_path, path, sizeof(sa.sun_path)); if (connect(fd, (struct sockaddr *)&sa, sizeof(sa)) == -1) { - int e = errno; + int saved_errno = errno; close(fd); - return e; + errno = saved_errno; + return -1; } *out_fd = fd; @@ -227,7 +228,6 @@ static int tr2_dst_try_unix_domain_socket(struct tr2_dst *dst, { unsigned int uds_try = 0; int fd; - int e; const char *path = NULL; /* @@ -271,15 +271,13 @@ static int tr2_dst_try_unix_domain_socket(struct tr2_dst *dst, } if (uds_try & TR2_DST_UDS_TRY_STREAM) { - e = tr2_dst_try_uds_connect(path, SOCK_STREAM, &fd); - if (!e) + if (!tr2_dst_try_uds_connect(path, SOCK_STREAM, &fd)) goto connected; - if (e != EPROTOTYPE) + if (errno != EPROTOTYPE) goto error; } if (uds_try & TR2_DST_UDS_TRY_DGRAM) { - e = tr2_dst_try_uds_connect(path, SOCK_DGRAM, &fd); - if (!e) + if (!tr2_dst_try_uds_connect(path, SOCK_DGRAM, &fd)) goto connected; } @@ -287,7 +285,7 @@ error: if (tr2_dst_want_warning()) warning("trace2: could not connect to socket '%s' for '%s' tracing: %s", path, tr2_sysenv_display_name(dst->sysenv_var), - strerror(e)); + strerror(errno)); tr2_dst_trace_disable(dst); return 0; |