|WARNING| [v2] fbarray: check file lock downgrade failure

dpdklab at iol.unh.edu dpdklab at iol.unh.edu
Tue Sep 29 08:51:42 CEST 2026


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

_AI Code Review_

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

# DPDK Patch Review

## Summary

This patch adds error checking for a file lock downgrade operation in `rte_fbarray_destroy()`. The changes are correct and improve error handling. No errors found.

---

## Warnings

### 1. Explicit errno comparison missing

**File:** `lib/eal/common/eal_common_fbarray.c`  
**Line:** `if (unlink(path)) {`

The condition should explicitly compare against zero or -1 per DPDK style guidelines.

**Suggested fix:**
```c
if (unlink(path) != 0) {
```

**Why it matters:** DPDK coding standards require explicit comparison for system call return values rather than relying on truthiness.

### 2. Explicit rte_errno comparison missing

**File:** `lib/eal/common/eal_common_fbarray.c`  
**Line:** `if (eal_file_lock(fd, EAL_FLOCK_SHARED, EAL_FLOCK_RETURN) != 0)`

While this line correctly compares against 0, the subsequent use of `rte_errno` in the error message assumes it was set. Consider verifying this is the intended behavior.

**Current code:**
```c
if (eal_file_lock(fd, EAL_FLOCK_SHARED, EAL_FLOCK_RETURN) != 0)
    EAL_LOG(DEBUG, "Cannot restore fbarray shared lock: %s",
        rte_strerror(rte_errno));
```

**Note:** This is acceptable if `eal_file_lock()` is guaranteed to set `rte_errno` on failure. If there's any uncertainty about whether `rte_errno` is set by `eal_file_lock()`, it would be safer to use `errno` directly or save it first.

---

## Info

### Error preservation pattern

The pattern of saving `errno` immediately after a failed system call is correct and follows best practices:

```c
const int unlink_errno = errno;
```

This prevents subsequent calls from overwriting the original error before it can be reported to the caller. The restoration at the end (`rte_errno = unlink_errno;`) ensures the primary failure reason is preserved.

### Lock downgrade error handling

The addition of error checking on the lock downgrade operation is an improvement. The original code silently ignored failures, which could leave the system in an inconsistent state. Logging the failure provides visibility for debugging.

---

## Positive Observations

1. **Correct errno handling:** The patch properly saves errno immediately after `unlink()` fails
2. **Error propagation:** The primary error (`unlink_errno`) is correctly restored to `rte_errno` before returning
3. **Appropriate logging:** Both the unlink failure and lock downgrade failure are logged at DEBUG level
4. **No resource leaks:** The error path correctly falls through to the cleanup code via `goto out`
5. **Fixes tag present:** Appropriate reference to the commit that introduced the unchecked operation
6. **Cc: stable:** Correctly marked for backport

---

## Final Assessment

The patch is **functionally correct** with only minor style suggestions. The errno preservation logic is sound, and the addition of error checking addresses the issue identified by static analysis without introducing new problems.


More information about the test-report mailing list