|WARNING| [v2,17/17] net/virtio: replace strncpy with strlcpy

dpdklab at iol.unh.edu dpdklab at iol.unh.edu
Wed Jun 24 16:09:19 CEST 2026


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

_AI Code Review_

=== Patch Review: series.patch (via Claude) ===
Review date: 2026-06-24

# DPDK Patch Review

## Summary
Reviewing 17 patches that replace `strncpy()` with `strlcpy()` across multiple DPDK components. These are straightforward mechanical changes to use a safer string copy function that guarantees null-termination.

---

## Patch 01/17: common/cnxk: replace strncpy with strlcpy

**File:** `drivers/common/cnxk/roc_model.c`

### Findings

**Errors:** None

**Warnings:** None

**Info:** 
- All four replacements correctly adjust the size parameter: `strncpy(..., SIZE - 1)` becomes `strlcpy(..., SIZE)`, which is correct since `strlcpy()` takes the full buffer size including room for the null terminator.

---

## Patch 02/17: common/mlx5: replace strncpy with strlcpy

**File:** `drivers/common/mlx5/linux/mlx5_common_os.c`

### Findings

**Errors:** None

**Warnings:** None

**Info:**
- Single replacement using `IF_NAMESIZE` is correct. The constant already includes space for the null terminator.

---

## Patch 03/17: crypto/mvsam: replace strncpy with strlcpy

**File:** `drivers/crypto/mvsam/rte_mrvl_pmd.c`

### Findings

**Errors:** None

**Warnings:** None

**Info:**
- Replacement uses `RTE_CRYPTODEV_NAME_MAX_LEN` directly, which is correct.

---

## Patch 04/17: crypto/scheduler: replace strncpy with strlcpy

**File:** `drivers/crypto/scheduler/scheduler_pmd.c`

### Findings

**Errors:** None

**Warnings:** None

**Info:**
- Both replacements correctly adjust from `SIZE - 1` to `SIZE`.

---

## Patch 05/17: event/cnxk: replace strncpy with strlcpy

**File:** `drivers/event/cnxk/cnxk_eventdev_stats.c`

### Findings

**Errors:** None

**Warnings:** None

**Info:**
- Replacement uses `sizeof(xstats_names[i].name)`, which is correct.

---

## Patch 06/17: net/ark: replace strncpy with strlcpy

**File:** `drivers/net/ark/ark_ethdev.c`

### Findings

**Errors:** None

**Warnings:** None

**Info:**
- Single replacement in `process_file_args()` is correct.

---

## Patch 07/17: net/bnx2x: replace strncpy with strlcpy

**Files:** 
- `drivers/net/bnx2x/bnx2x.c`
- `drivers/net/bnx2x/bnx2x_vfpf.c`

### Findings

**Errors:** None

**Warnings:** None

**Info:**
- Both replacements correctly adjust the size parameter.

---

## Patch 08/17: net/cnxk: replace strncpy with strlcpy

**Files:**
- `drivers/net/cnxk/cnxk_eswitch.c`
- `drivers/net/cnxk/cnxk_rep_msg.c`

### Findings

**Errors:** None

**Warnings:** None

**Info:**
- Both replacements correctly adjust from `sizeof(...) - 1` to `sizeof(...)`.

---

## Patch 09/17: net/dpaa: replace strncpy with strlcpy

**File:** `drivers/net/dpaa/dpaa_ethdev.c`

### Findings

**Errors:** None

**Warnings:** None

**Info:**
- Replacement uses `IFNAMSIZ` directly, which is correct.

---

## Patch 10/17: net/ionic: replace strncpy with strlcpy

**File:** `drivers/net/ionic/ionic_main.c`

### Findings

**Errors:** None

**Warnings:** None

**Info:**
- Replacement correctly adjusts from `sizeof(...) - 1` to `sizeof(...)`.

---

## Patch 11/17: net/mlx4: replace strncpy with strlcpy

**File:** `drivers/net/mlx4/mlx4_ethdev.c`

### Findings

**Errors:** None

**Warnings:** None

**Info:**
- Replacement uses `sizeof(*ifname)`, which is correct.

---

## Patch 12/17: net/mlx5: replace strncpy with strlcpy

**Files:**
- `drivers/net/mlx5/mlx5.c`
- `drivers/net/mlx5/windows/mlx5_ethdev_os.c`

### Findings

**Errors:** None

**Warnings:** None

**Info:**
- All three replacements correctly adjust the size parameter.

---

## Patch 13/17: net/nfp: replace strncpy with strlcpy

**File:** `drivers/net/nfp/nfpcore/nfp_resource.c`

### Findings

**Errors:** None

**Warnings:** None

**Info:**
- Replacement uses `sizeof(res->name)`, which is correct.

---

## Patch 14/17: net/qede: replace strncpy with strlcpy

**File:** `drivers/net/qede/qede_ethdev.c`

### Findings

**Errors:** None

**Warnings:** None

**Info:**
- Single replacement is correct.

---

## Patch 15/17: net/softnic: replace strncpy with strlcpy

**File:** `drivers/net/softnic/conn.c`

### Findings

**Errors:** None

**Warnings:** None

**Info:**
- Both replacements correctly adjust from `CONN_*_LEN_MAX` to `CONN_*_LEN_MAX + 1`. 
- The patch adds `#include <rte_string_fns.h>`, which is appropriate for accessing `strlcpy()`.

---

## Patch 16/17: net/vhost: replace strncpy with strlcpy

**File:** `drivers/net/vhost/rte_eth_vhost.c`

### Findings

**Errors:** None

**Warnings:** None

**Info:**
- Replacement uses `RTE_ETH_XSTATS_NAME_SIZE`, which is correct.

---

## Patch 17/17: net/virtio: replace strncpy with strlcpy

**File:** `drivers/net/virtio/virtio_user/vhost_kernel_tap.c`

### Findings

**Errors:** None

**Warnings:** None

**Info:**
- Replacement correctly adjusts from `IFNAMSIZ - 1` to `IFNAMSIZ`.

---

## Overall Assessment

All 17 patches are correct mechanical replacements of `strncpy()` with `strlcpy()`. Each replacement:
1. Uses the correct buffer size (adjusting from `size - 1` to `size` where appropriate)
2. Maintains the same functional behavior while guaranteeing null-termination
3. Follows DPDK coding standards

**No issues found.** All patches are ready for merge.


More information about the test-report mailing list