Skip to content

Conversation

@nigoroll
Copy link
Member

@nigoroll nigoroll commented Jan 5, 2026

The CHECK_OBJ*() macros are great, and no-one could ever want to live without them, but they have one disadvantage: They prevent compiler warnings about unused variables.

So, for this purpose only, we add NO_CHECK_OBJ to discover more unused variables:

$ make CFLAGS='-DNO_CHECK_OBJ -Wall -Werror'
...
cache/cache_gzip.c:420:17: error: variable 'wrk' set but not used [-Werror,-Wunused-but-set-variable]
        struct worker *wrk;

The CHECK_OBJ*() macros are great, and no-one could ever want to live without
them, but they have one disadvantage: They prevent compiler warnings about
unused variables.

So, for this purpose only, we add NO_CHECK_OBJ to discover more unused
variables:

$ make CFLAGS='-DNO_CHECK_OBJ -Wall -Werror'
...
cache/cache_gzip.c:420:17: error: variable 'wrk' set but not used [-Werror,-Wunused-but-set-variable]
        struct worker *wrk;
found using -DNO_CHECK_OBJ
found using -DNO_CHECK_OBJ
nigoroll added a commit to vtest/VTest2 that referenced this pull request Jan 5, 2026
@asadsa92
Copy link
Contributor

asadsa92 commented Jan 5, 2026

Nice, maybe controversial, but did you try to omit asserts, AN(), AZ(), etc., to see if we got some dead code only accessed by our defensive code style? I.e.,

$ make CFLAGS="-DNDEBUG -Wall -Werror"
[...]
vbm_test.c:46:16: error: variable 'obits' set but not used [-Werror,-Wunused-but-set-variable]
        VBITMAP_TYPE    *obits;
                         ^

@nigoroll
Copy link
Member Author

nigoroll commented Jan 7, 2026

@asadsa92 -DNDEBUG and -DWITHOUT_ASSERTS are other options to maybe check periodically, yes.

bugwash was -1 on merging this, but we might want to polish the CHECK_OBJ()s to make the intention clear.

@nigoroll nigoroll closed this in 9f36c2e Jan 7, 2026
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.

2 participants