Skip to content

Fix strip.py handling of #else after #ifndef __UNIT_TEST__ - #25

Closed
randomizedcoder wants to merge 1 commit into
mainfrom
fix/strip-ifndef-unit-test-else
Closed

randomizedcoder wants to merge 1 commit into
mainfrom
fix/strip-ifndef-unit-test-else

Conversation

@randomizedcoder

Copy link
Copy Markdown
Owner

make net-next writes stripped files that don't compile in a kernel tree:

net/homa/homa_tx_pool.c:95:5: error: redefinition of 'homa_tx_pool_mem_nid'

util/strip.py treats #else /* __UNIT_TEST__ */ as "start keeping lines". That is right after #ifdef __UNIT_TEST__, but after #ifndef __UNIT_TEST__ (only homa_tx_pool_mem_nid uses that form with an #else) it keeps both branches, the real function and the unit-test stub.

Fix: #else switches between keeping and dropping lines.

Checked:

  • strip.py output for every homa*.[ch], before and after: the only difference is the stub's three lines in homa_tx_pool.c.
  • With this and the sk_memcg fix (the other in-tree build break), the stripped files build in a 7.3 tree as net/homa (defconfig + HOMA=m, W=1; gcc + sparse, clang, i386) with no warnings, and the stub's checkpatch "open brace" error goes away.

No test, since it's a script fix.

🤖 Generated with Claude Code

strip.py treated "#else /* __UNIT_TEST__ */" as the start of code to
keep, which is right after "#ifdef __UNIT_TEST__" but wrong after
"#ifndef __UNIT_TEST__". As a result, "make net-next" kept both
definitions of homa_tx_pool_mem_nid in homa_tx_pool.c, so the stripped
files failed to compile ("redefinition of 'homa_tx_pool_mem_nid'").
Make #else switch between keeping and dropping lines instead. No other
stripped file changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@randomizedcoder

Copy link
Copy Markdown
Owner Author

Duplicate of upstream PlatformLab#134, which makes the same fix; closing in favour of it.

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.

1 participant