Skip to contentSkip to conversation

selftests/net: Ensure assert() triggers in psock_tpacket.c

PATCH Applied Wake Liu 2 participants 2 messages Aug 9, 2025 – Aug 12, 2025

Subsystems (3)
lore
Share & tools
lore

Wake Liu

author
#0 lore raw

PATCH v2 1/1 selftests/net: Ensure assert() triggers in psock_tpacket.c

The get_next_frame() function in psock_tpacket.c was missing a return statement in its default switch case, leading to a compiler warning.

This was caused by a bug_on(1) call, which is defined as an assert(), being compiled out because NDEBUG is defined during the build.

Instead of adding a return NULL; which would silently hide the error and could lead to crashes later, this change restores the original author's intent. By adding #undef NDEBUG before including <assert.h>, we ensure the assertion is active and will cause the test to abort if this unreachable code is ever executed.

---
 tools/testing/selftests/net/psock_tpacket.c | 1 +
 1 file changed, 1 insertion(+)
tools/testing/selftests/net/psock_tpacket.c +1 -0
index 0dd909e325d9..2938045c5cf9 100644
@@ -22,6 +22,7 @@
  *   - TPACKET_V3: RX_RING
  */
 
+#undef NDEBUG
 #include <stdio.h>
 #include <stdlib.h>
 #include <sys/types.h>
Signature · 1 line
2.50.1.703.g449372360f-goog
#1 lore raw
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 8 lines · On Sat, 9 Aug 2025 14:20:13 +0800 you wrote:

The get_next_frame() function in psock_tpacket.c was missing a return statement in its default switch case, leading to a compiler warning.

This was caused by a bug_on(1) call, which is defined as an assert(), being compiled out because NDEBUG is defined during the build.

[...]

Here is the summary with links:
- [v2] selftests/net: Ensure assert() triggers in psock_tpacket.c

    https://git.kernel.org/netdev/net-next/c/bc4c0a48bdad

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html