|SUCCESS| [v2] fib6: fix sign conversion of tbl8 indexes

dpdklab at iol.unh.edu dpdklab at iol.unh.edu
Wed Oct 21 21:36:58 CEST 2026


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

_AI Code Review_

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

# DPDK Patch Review

## ERRORS

None identified.

## WARNINGS

None identified.

## INFO

**Integer overflow prevention in shift operations:**

The patch correctly addresses integer overflow in left shift operations at lines 332 and 363:

```c
/* Before (line 329 in original): */
write_to_dp(tbl_ptr, (idx << 1) | TRIE_EXT_ENT, dp->nh_sz, 1);

/* After (line 332): */
write_to_dp(tbl_ptr, ((uint64_t)tbl8_idx << 1) | TRIE_EXT_ENT, dp->nh_sz, 1);

/* Before (line 362 in original): */
val = (tbl8_idx << 1)|TRIE_EXT_ENT;

/* After (line 363): */
val = ((uint64_t)tbl8_idx << 1) | TRIE_EXT_ENT;
```

This correctly prevents the narrow `int` result from being shifted in 32-bit width before widening to `uint64_t`, which matches the guideline requirement: "Integer multiply without widening cast losing upper bits (16x16, 32x32, etc.)" and the related shift pattern.

**Sign extension bug fix:**

The patch correctly fixes a sign extension issue where `int idx` was being implicitly converted to `uint64_t` when passed to `get_tbl_val_by_idx()` and `get_tbl_p_by_idx()`. When the table index reaches 2^31, the high bit set in the `int` causes sign extension during the implicit conversion to `uint64_t`, producing incorrect negative indices. The fix uses `uint32_t` for `idx` and `prev_idx`, eliminating the sign extension.

**Variable separation for error handling:**

The introduction of a separate `tbl8_idx` variable (line 321) to hold the signed return value from `tbl8_alloc()` is the correct pattern for distinguishing error returns (negative) from valid indices (non-negative). The subsequent cast to `uint32_t` when assigning to `prev_idx` (line 334) is safe because the error case has already been handled.

Review-Result: CLEAN


More information about the test-report mailing list