Skip to content

bind-mount: suppress unused end_tab warning when NDEBUG is set#750

Open
heitbaum wants to merge 1 commit into
containers:mainfrom
heitbaum:patch-1
Open

bind-mount: suppress unused end_tab warning when NDEBUG is set#750
heitbaum wants to merge 1 commit into
containers:mainfrom
heitbaum:patch-1

Conversation

@heitbaum

@heitbaum heitbaum commented May 5, 2026

Copy link
Copy Markdown

Silence -Wunused-but-set-variable on end_tab by moving the assignment directly into the assert expression.

Fixes:
../bind-mount.c: In function 'parse_mountinfo':
../bind-mount.c:237:14: warning: variable 'end_tab' set but not used [-Wunused-but-set-variable=]
237 | MountInfo *end_tab;
| ^~~~~~~

Silence -Wunused-but-set-variable on end_tab by moving the assignment directly into the assert expression.

Fixes:
../bind-mount.c: In function 'parse_mountinfo':
../bind-mount.c:237:14: warning: variable 'end_tab' set but not used [-Wunused-but-set-variable=]
  237 |   MountInfo *end_tab;
      |              ^~~~~~~

Signed-off-by: Rudi Heitbaum <rudi@heitbaum.com>

@charmander charmander left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will fail to call collect_mounts at all when NDEBUG is set.

@GalaxySnail

Copy link
Copy Markdown

A simple (void) end_tab; may be enough.

@smcv smcv left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If built with -DNDEBUG, the proposed change won't call collect_mounts() at all, but the whole point is that we want to call it for its side-effects (populating the table).

I'd prefer:

-  MountInfo *end_tab;
+  MountInfo *end_tab UNUSED /* if NDEBUG */;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants