Skip to content

bgpd: remove duplicate snprintf in FlowSpec redirect VRF display - #22272

Merged
mjstapp merged 1 commit into
FRRouting:masterfrom
guoguojia2021:fix/bgpd-ecommunity-dup-snprintf
Jun 9, 2026
Merged

bgpd: remove duplicate snprintf in FlowSpec redirect VRF display#22272
mjstapp merged 1 commit into
FRRouting:masterfrom
guoguojia2021:fix/bgpd-ecommunity-dup-snprintf

Conversation

@guoguojia2021

Copy link
Copy Markdown
Contributor

In ecommunity_ecom2str(), the ECOMMUNITY_REDIRECT_VRF display branch has an identical snprintf() call duplicated on consecutive lines. Both calls write "FS:redirect VRF %s" with the same buf argument into the same encbuf destination buffer.

The second call overwrites the first with identical content, producing the correct output by coincidence but wasting a snprintf() invocation on every FlowSpec redirect VRF extended community that is formatted for display (e.g., in show commands and logging).

Remove the duplicate snprintf() call, keeping the first instance.

In ecommunity_ecom2str(), the ECOMMUNITY_REDIRECT_VRF display branch
has an identical snprintf() call duplicated on consecutive lines.
Both calls write "FS:redirect VRF %s" with the same buf argument
into the same encbuf destination buffer.

The second call overwrites the first with identical content, producing
the correct output by coincidence but wasting a snprintf() invocation
on every FlowSpec redirect VRF extended community that is formatted
for display (e.g., in show commands and logging).

Remove the duplicate snprintf() call, keeping the first instance.

Signed-off-by: guozhongfeng.gzf <guozhongfeng.gzf@alibaba-inc.com>
@greptile-apps

greptile-apps Bot commented Jun 9, 2026

Copy link
Copy Markdown

Greptile Summary

Removes a duplicate snprintf() call in _ecommunity_ecom2str() within the ECOMMUNITY_REDIRECT_VRF display branch of bgpd/bgp_ecommunity.c. The two back-to-back calls were identical in format string, arguments, and destination buffer, so only the first is needed.

  • The duplicate snprintf(encbuf, sizeof(encbuf), \"FS:redirect VRF %s\", buf) call is removed; the remaining single call produces exactly the same output that was previously produced by the pair.
  • No logic change: the fix is purely cosmetic/efficiency-oriented and eliminates a wasted function invocation on every FlowSpec redirect VRF extended community formatted for display.

Confidence Score: 5/5

Safe to merge; the removed line was an exact duplicate of the line immediately above it and produced no observable behavior difference.

The change is a one-line deletion of a perfectly duplicate snprintf call. Both calls used the same format string, the same source buffer, and the same destination buffer, so the output of _ecommunity_ecom2str is byte-for-byte identical before and after the patch on every code path that passes through this branch.

No files require special attention.

Important Files Changed

Filename Overview
bgpd/bgp_ecommunity.c Removes one duplicate snprintf() call in the ECOMMUNITY_REDIRECT_VRF display branch; the retained call is identical to the removed one, so output is unchanged.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[_ecommunity_ecom2str] --> B{sub_type?}
    B -->|ECOMMUNITY_REDIRECT_VRF| C[ecommunity_rt_soo_str into buf]
    C --> D["snprintf(encbuf, 'FS:redirect VRF %s', buf)"]
    D -->|before fix: second identical call| E["snprintf(encbuf, 'FS:redirect VRF %s', buf) REMOVED"]
    D --> F[continue processing]
    E --> F
    B -->|other sub_types| G[other branches]
Loading

Reviews (1): Last reviewed commit: "bgpd: remove duplicate snprintf in FlowS..." | Re-trigger Greptile

@mjstapp
mjstapp merged commit e685b79 into FRRouting:master Jun 9, 2026
25 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