Skip to content

Commit ab9b85b

Browse files
jukkarkartben
authored andcommitted
net: Build assert issue with llvm
Remove the build assert from NET_L3_REGISTER() macro as that is causing an issue with llvm. Add runtime check of the handler pointer value. subsys/net/l2/ethernet/arp.c:1044:1: error: static_assert expression is not an integral constant expression ETH_NET_L3_REGISTER(ARP, NET_ETH_PTYPE_ARP, arp_recv); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/zephyr/net/ethernet.h:1272:2: note: expanded from macro 'ETH_NET_L3_REGISTER' NET_L3_REGISTER(&NET_L2_GET_NAME(ETHERNET), name, ptype, handler) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/zephyr/net/net_core.h:190:2: note: expanded from macro 'NET_L3_REGISTER' BUILD_ASSERT((_handler) != NULL, "Handler is not defined") ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/zephyr/toolchain/gcc.h:87:51: note: expanded from macro 'BUILD_ASSERT' define BUILD_ASSERT(EXPR, MSG...) _Static_assert((EXPR), "" MSG) ^~~~~~ subsys/net/l2/ethernet/arp.c:1044:1: note: cast from 'void *' is not allowed in a constant expression include/zephyr/net/ethernet.h:1272:2: note: expanded from macro 'ETH_NET_L3_REGISTER' NET_L3_REGISTER(&NET_L2_GET_NAME(ETHERNET), name, ptype, handler) ^ include/zephyr/net/net_core.h:190:29: note: expanded from macro 'NET_L3_REGISTER' BUILD_ASSERT((_handler) != NULL, "Handler is not defined") ^ /usr/lib/llvm-14/lib/clang/14.0.0/include/stddef.h:89:16: note: expanded from macro 'NULL' define NULL ((void*)0) Signed-off-by: Jukka Rissanen <[email protected]>
1 parent 04205ae commit ab9b85b

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

include/zephyr/net/net_core.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,7 @@ struct net_l3_register {
186186
.handler = _handler, \
187187
.name = STRINGIFY(_name), \
188188
.l2 = _l2_type, \
189-
}; \
190-
BUILD_ASSERT((_handler) != NULL, "Handler is not defined")
189+
};
191190

192191
/* @endcond */
193192

subsys/net/l2/ethernet/ethernet.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,8 @@ static enum net_verdict ethernet_recv(struct net_if *iface,
353353
net_buf_pull(pkt->frags, hdr_len);
354354

355355
STRUCT_SECTION_FOREACH(net_l3_register, l3) {
356-
if (l3->ptype != type || l3->l2 != &NET_L2_GET_NAME(ETHERNET)) {
356+
if (l3->ptype != type || l3->l2 != &NET_L2_GET_NAME(ETHERNET) ||
357+
l3->handler == NULL) {
357358
continue;
358359
}
359360

0 commit comments

Comments
 (0)