Skip to content

bgpd,lib,zebra: use explicit casts in tracepoint definitions - #21438

Merged
riw777 merged 2 commits into
FRRouting:masterfrom
mjstapp:fix_tracepoint_gcc_14
Apr 2, 2026
Merged

bgpd,lib,zebra: use explicit casts in tracepoint definitions#21438
riw777 merged 2 commits into
FRRouting:masterfrom
mjstapp:fix_tracepoint_gcc_14

Conversation

@mjstapp

@mjstapp mjstapp commented Apr 1, 2026

Copy link
Copy Markdown
Contributor

gcc 14 doesn't like some of the implicit casting in the tracepoint macros: cast pointers in tracepoint arguments to intptr_t explicitly to keep compilers happy. Also fix a bug in a bgp tracepoint.

prefix.macip_addr.eth_tag used as a pointer, but actually an int.

Signed-off-by: Mark Stapp <mjs@cisco.com>
@greptile-apps

greptile-apps Bot commented Apr 1, 2026

Copy link
Copy Markdown

Greptile Summary

This PR adds explicit (intptr_t) casts to tracepoint macro arguments across bgpd, lib, and zebra to silence GCC 14 warnings about implicit pointer-to-integer conversions. It also fixes a real bug in bgpd/bgp_trace.h where eth_tag was passed as a pointer (&pfx->prefix.macip_addr.eth_tag) instead of a value (pfx->prefix.macip_addr.eth_tag) to ctf_integer.

Key changes:

  • bgpd/bgp_trace.h: Explicit cast for attr pointer in process_update; bug fix removing the erroneous & from eth_tag in evpn_mac_ip_zsend β€” without this fix the tracepoint would log the field's memory address as the EVPN ethernet tag instead of its actual value.
  • lib/libfrr_trace.h: All void * / struct-pointer arguments in hash, memory, list, route-table, and thread-scheduler tracepoints cast explicitly. The struct event ** dereference uses the idiomatic two-step (intptr_t)(void*) cast, which is correct per C standard aliasing rules.
  • zebra/zebra_trace.h: Pointer arguments for netlink command and Netlink message header tracepoints cast explicitly across eight repetitive tracepoint definitions.

Confidence Score: 5/5

Safe to merge β€” all changes are mechanical explicit casts plus one genuine bug fix in a tracepoint.

All modifications are straightforward pointer-to-intptr_t casts required by GCC 14's stricter implicit-conversion rules. The only behavioral change is the eth_tag bug fix in bgpd/bgp_trace.h, which is clearly correct (removing the erroneous address-of operator). No logic paths, data structures, or protocol handling are affected β€” tracepoints are no-ops unless LTTng is enabled. No remaining P0/P1 issues.

No files require special attention.

Important Files Changed

Filename Overview
bgpd/bgp_trace.h Two fixes: explicit (intptr_t) cast for attr pointer, and a genuine bug fix removing the erroneous address-of operator from the eth_tag field in evpn_mac_ip_zsend.
lib/libfrr_trace.h All pointer-to-integer tracepoint arguments wrapped in explicit (intptr_t) casts; struct event ** dereference cast via (intptr_t)(void*) to comply with C aliasing rules.
zebra/zebra_trace.h All header and netlink_cmd struct-pointer arguments cast explicitly to intptr_t across eight repetitive tracepoint definitions.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Tracepoint macro invoked\ne.g. ctf_integer_hex] --> B{Argument type}
    B -->|void* / struct ptr| C["Before: implicit ptrβ†’intptr_t\n⚠ GCC 14 warning"]
    B -->|void* / struct ptr| D["After: explicit (intptr_t) cast\nβœ… No warning"]
    B -->|struct event **| E["After: (intptr_t)(void*)(*thread_ptr)\nβœ… Correct aliasing"]
    B -->|uint32_t field eth_tag bug| F["Before: &field (address)\nπŸ› Wrong value logged"]
    F --> G["After: field (value)\nβœ… Correct eth_tag logged"]
    D --> H[LTTng tracepoint recorded]
    E --> H
    G --> H
Loading

Reviews (1): Last reviewed commit: "bgpd,lib,zebra: cast pointers to intptr_..." | Re-trigger Greptile

Cast pointers in tracepoint arguments to intptr_t explicitly
to keep compilers happy.

Signed-off-by: Mark Stapp <mjs@cisco.com>
@mjstapp
mjstapp force-pushed the fix_tracepoint_gcc_14 branch from b0b4531 to 689d29b Compare April 1, 2026 15:10
@mjstapp

mjstapp commented Apr 1, 2026

Copy link
Copy Markdown
Contributor Author

fixed a checkpatch warning

@riw777 riw777 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good

@riw777
riw777 merged commit 7d94895 into FRRouting:master Apr 2, 2026
27 of 28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants