1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-09 13:46:08 +02:00
git/trace2
Ævar Arnfjörð Bjarmason 4e0a64a713 trace2: refactor to avoid gcc warning under -O3
Refactor tr2_dst_try_uds_connect() to avoid a gcc warning[1] that
appears under -O3 (but not -O2). This makes the build pass under
DEVELOPER=1 without needing a DEVOPTS=no-error.

This can be reproduced with GCC Debian 8.3.0-6, but not e.g. with
clang 7.0.1-8+deb10u2. We've had this warning since
ee4512ed48 (trace2: create new combined trace facility, 2019-02-22).

As noted in [2] this warning happens because the compiler doesn't
assume that errno must be non-zero after a failed syscall.

Let's work around by using the well-established "saved_errno" pattern,
along with returning -1 ourselves instead of "errno". The caller can
thus rely on our "errno" on failure.

See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61846 for a related
bug report against GCC.

1.

    trace2/tr2_dst.c: In function ‘tr2_dst_get_trace_fd.part.5’:
    trace2/tr2_dst.c:296:10: warning: ‘fd’ may be used uninitialized in this function [-Wmaybe-uninitialized]
      dst->fd = fd;
      ~~~~~~~~^~~~
    trace2/tr2_dst.c:229:6: note: ‘fd’ was declared here
      int fd;
          ^~
2. https://lore.kernel.org/git/20200404142131.GA679473@coredump.intra.peff.net/

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-05-21 06:56:11 +09:00
..
tr2_cfg.c trace2: use system/global config for default trace2 settings 2019-04-16 13:37:06 +09:00
tr2_cfg.h
tr2_cmd_name.c trace2: rename environment variables to GIT_TRACE2* 2019-05-28 10:20:34 -07:00
tr2_cmd_name.h
tr2_dst.c trace2: refactor to avoid gcc warning under -O3 2021-05-21 06:56:11 +09:00
tr2_dst.h trace2: use system/global config for default trace2 settings 2019-04-16 13:37:06 +09:00
tr2_sid.c trace2: rename environment variables to GIT_TRACE2* 2019-05-28 10:20:34 -07:00
tr2_sid.h
tr2_sysenv.c trace2: rename environment variables to GIT_TRACE2* 2019-05-28 10:20:34 -07:00
tr2_sysenv.h trace2: rename environment variables to GIT_TRACE2* 2019-05-28 10:20:34 -07:00
tr2_tbuf.c trace2: make SIDs more unique 2019-04-16 13:37:07 +09:00
tr2_tbuf.h trace2: make SIDs more unique 2019-04-16 13:37:07 +09:00
tr2_tgt.h trace2: add absolute elapsed time to start event 2019-04-16 13:37:06 +09:00
tr2_tgt_event.c Merge branch 'jh/trace2-sid-fix' 2019-05-13 23:50:31 +09:00
tr2_tgt_normal.c Merge branch 'jh/trace2-sid-fix' 2019-05-13 23:50:31 +09:00
tr2_tgt_perf.c Merge branch 'jh/trace2-sid-fix' 2019-05-13 23:50:31 +09:00
tr2_tls.c Merge branch 'jh/trace2' 2019-05-30 10:50:45 -07:00
tr2_tls.h trace2: refactor setting process starting time 2019-04-16 13:37:06 +09:00