|WARNING| examples/l2fwd-event: fix memset of port statistics array
dpdklab at iol.unh.edu
dpdklab at iol.unh.edu
Wed Jul 29 13:10:45 CEST 2026
Test-Label: ai-code-review
Test-Status: WARNING
https://dpdk.org/patch/166995
_AI Code Review_
=== Patch Review: series.patch (via Claude) ===
Review date: 2026-07-29
# DPDK Patch Review
## Patch Summary
**File:** examples/l2fwd-event/main.c
**Change:** Fix memset call to zero entire port_stats array instead of just the first element.
---
## Review Findings
### **Errors: None**
### **Warnings: None**
### **Info**
**Info 1: Suggested memset parameter cleanup**
The fix changes `&rsrc->port_stats` to `rsrc->port_stats` (removing the `&`). While the fix is correct -- the array name decays to a pointer, so the `&` is redundant -- both forms produce the same result when passing an array to memset.
The new form `rsrc->port_stats` is clearer and more idiomatic when the intent is to pass the array itself.
---
## Analysis
### Correctness
The patch correctly fixes a serious bug where only the first element of the `port_stats` array was being zeroed. The original code:
```c
memset(&rsrc->port_stats, 0, sizeof(struct l2fwd_port_statistics));
```
cleared only `sizeof(struct l2fwd_port_statistics)` bytes (one element), leaving ports 1 through RTE_MAX_ETHPORTS-1 uninitialized.
The fix:
```c
memset(rsrc->port_stats, 0, sizeof(rsrc->port_stats));
```
correctly zeros the entire array by using `sizeof(rsrc->port_stats)`, which evaluates to `sizeof(struct l2fwd_port_statistics[RTE_MAX_ETHPORTS])`.
This was a real bug that could lead to undefined behavior when accessing statistics for ports beyond port 0.
### Style Compliance
- Proper indentation
- No trailing whitespace
- No forbidden tokens
- Follows DPDK coding style
### Process Compliance
- Fixes tag present and correct
- Cc: stable at dpdk.org included (appropriate for a bug fix)
- Signed-off-by present
- Targets example code (examples/), so release notes not required
---
## Conclusion
**This patch is correct and ready for merge.** It fixes a real correctness bug (uninitialized memory) that would cause incorrect statistics reporting for ports 1 and higher. The fix is minimal, clear, and follows DPDK coding standards.
More information about the test-report
mailing list