Skip to content
This repository was archived by the owner on Feb 16, 2026. It is now read-only.

Add NO_CHECK_OBJ macro to neuter CHECK_OBJ#4435

Closed
nigoroll wants to merge 3 commits intovarnishcache:masterfrom
nigoroll:NO_CHECK_OBJ
Closed

Add NO_CHECK_OBJ macro to neuter CHECK_OBJ#4435
nigoroll wants to merge 3 commits intovarnishcache:masterfrom
nigoroll:NO_CHECK_OBJ

Conversation

@nigoroll
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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 subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants