Bug 479117 - coregrind/m_debuginfo/readelf.c:1977: variable set but not used
Summary: coregrind/m_debuginfo/readelf.c:1977: variable set but not used
Status: RESOLVED FIXED
Alias: None
Product: valgrind
Classification: Developer tools
Component: general (other bugs)
Version First Reported In: unspecified
Platform: Compiled Sources Linux
: NOR minor
Target Milestone: ---
Assignee: Julian Seward
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-12-28 12:16 UTC by dcb314
Modified: 2023-12-29 08:59 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description dcb314 2023-12-28 12:16:10 UTC
A build of today's git head produces this:

m_debuginfo/readelf.c:1977:12: warning: variable ‘has_nonempty_rw’ set but not used [-Wunused-but-set-variable]

A quick check on the variable:

$ grep has_nonempty_rw coregrind/m_debuginfo/readelf.c
      Bool has_nonempty_rw = False;
            has_nonempty_rw = True;
$ 

Maybe some development work in progress or a candidate for deletion.
Comment 1 Paul Floyd 2023-12-29 08:59:27 UTC
I saw this on buildbot and fixed it soon after

commit 671b1082e33659926d4fff42767cdffb48ec103c
Author: Paul Floyd <pjfloyd@wanadoo.fr>
Date:   Thu Dec 28 12:08:40 2023 +0100

    Fix unused variable warning

On macOS I see that mach-o binaries can be produced without a RW segment. The code assumed that there was always one (or more). The trigger for reading debuginfo and redirs is that the "right" number of RX and RW segments have been seen. Since the RW condition was wrong the trigger condition was not met.

Now that the RW segment count is correct I had to remove all that asserts that there are at least 1 RW segment.

In this case I put back the assert but modified it with the extra condition that di->fsm.rw_map_count can be zero.