|WARNING| fib6: fix signedness in common root build

dpdklab at iol.unh.edu dpdklab at iol.unh.edu
Thu Oct 22 10:35:58 CEST 2026


Test-Label: ai-code-review
Test-Status: WARNING
https://dpdk.org/patch/171826

_AI Code Review_

=== Patch Review: series.patch (via Claude) ===
Review date: 2026-10-22

# DPDK Patch Review

## ERRORS

### 1. Integer multiply without widening cast (line 341)

**Line 341:**
```c
*tbl = get_tbl_p_by_idx(cur_tbl,
	(uint64_t)prev_idx * TRIE_TBL8_GRP_NUM_ENT, dp->nh_sz);
```

**Issue:** The multiplication `(uint64_t)prev_idx * TRIE_TBL8_GRP_NUM_ENT` widens `prev_idx` to 64 bits, but if `TRIE_TBL8_GRP_NUM_ENT` is a 32-bit constant, the multiplication still happens at 32-bit width before implicit promotion to 64 bits for the function argument. The upper bits of the result could be lost.

**Fix:** Ensure `TRIE_TBL8_GRP_NUM_ENT` is also widened:
```c
*tbl = get_tbl_p_by_idx(cur_tbl,
	(uint64_t)prev_idx * (uint64_t)TRIE_TBL8_GRP_NUM_ENT, dp->nh_sz);
```

**NOTE:** This is an Error if `TRIE_TBL8_GRP_NUM_ENT` is defined as a plain integer constant or `uint32_t`. If it is already defined as `UINT64_C(...)` or `ULL` suffix, this cast is redundant but harmless. The patch's cast of only `prev_idx` is insufficient to prevent 32x32 overflow when both operands are 32-bit.

---

## WARNINGS

None identified.

---

## INFO

### Correctness improvement

The patch correctly addresses a sign-extension bug where `get_idx()` returns `uint32_t` but was stored in `int`. When bit 31 was set, the value became negative and sign-extended to 64 bits, producing a bogus pointer offset. The fix properly separates:
- `idx` and `prev_idx` as `uint32_t` for unsigned index values
- `tbl8_idx` as `int` for the signed error-code-or-index return from `tbl8_alloc()`

The widening cast at line 332 (`(uint64_t)tbl8_idx << 1`) correctly prevents overflow of the left shift.

The patch addresses a real bug and the approach is sound, pending verification of the multiplication at line 341.

---

Review-Result: ERROR


More information about the test-report mailing list