bgpd: remove duplicate snprintf in FlowSpec redirect VRF display - #22272
Conversation
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 SummaryRemoves a duplicate
Confidence Score: 5/5Safe 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
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]
Reviews (1): Last reviewed commit: "bgpd: remove duplicate snprintf in FlowS..." | Re-trigger Greptile |
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.