|SUCCESS| examples/l2fwd-event: fix memset of port statistics array

dpdklab at iol.unh.edu dpdklab at iol.unh.edu
Wed Jul 29 13:05:44 CEST 2026


Test-Label: ai-code-review
Test-Status: SUCCESS
https://dpdk.org/patch/166995

_AI Code Review_

=== Patch Review: series.patch (via Claude) ===
Review date: 2026-07-29

# DPDK Patch Review

## Patch Summary
Fixes a memset bug in examples/l2fwd-event where only the first element of a port statistics array was being zeroed instead of the entire array.

---

## Review Findings

### **Errors**

None.

---

### **Warnings**

None.

---

### **Info**

**1. Alternative approach - designated initializer**

The patch correctly fixes the memset size bug. However, consider using a designated initializer at declaration time instead of memset, which is safer and clearer:

```c
/* Current approach after patch */
memset(rsrc->port_stats, 0, sizeof(rsrc->port_stats));

/* Alternative - designated initializer (preferred for new code) */
struct l2fwd_port_statistics port_stats[RTE_MAX_ETHPORTS] = {0};
```

This eliminates the need for an explicit memset call and makes the zero-initialization explicit at the point of declaration. However, since this is existing code in the examples directory and the memset fix is correct, this is merely a suggestion for consideration in future patches, not a requirement for this fix.

**2. Patch scope is appropriate**

The fix is minimal, targeted, and correct. The patch properly:
- Fixes the bug by zeroing the entire array
- Uses `sizeof(rsrc->port_stats)` which is robust against future array size changes
- Includes appropriate Fixes tag and Cc: stable for backporting

---

## Summary

The patch is **correct and ready for merge**. It fixes a real bug where only the first port's statistics were initialized, leaving the remaining ports with garbage data. The fix uses the proper `sizeof` pattern that will remain correct regardless of array size changes.


More information about the test-report mailing list