Skip to content

Conversation

@vojtechtrefny
Copy link
Member

@vojtechtrefny vojtechtrefny commented Jan 9, 2026

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of system-reported values to trim extraneous characters and correctly evaluate equality, reducing false mismatches and improving reliability of device detection and related operations.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 9, 2026

📝 Walkthrough

Walkthrough

Replaced pointer equality checks with string content comparisons and added trimming of trailing newlines (g_strchomp) after reading sysfs values for fcphbasysfs, fcpwwpnsysfs, and fcplunsysfs in the zfcp_scsi_offline flow.

Changes

Cohort / File(s) Summary
s390 zfcp sysfs handling
src/plugins/s390.c
Added g_strchomp calls to trim trailing newlines from fcphbasysfs, fcpwwpnsysfs, and fcplunsysfs; replaced pointer-equality checks with g_strcmp0(...) == 0 for comparisons against devno, wwpn, and lun.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: fixing string comparison in a specific function by replacing pointer equality checks with proper string comparison using g_strcmp0.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fa6b811 and 0e2157b.

📒 Files selected for processing (1)
  • src/plugins/s390.c
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (42)
  • GitHub Check: testing-farm:fedora-43-x86_64
  • GitHub Check: testing-farm:fedora-43-aarch64
  • GitHub Check: testing-farm:fedora-43-aarch64
  • GitHub Check: testing-farm:fedora-43-x86_64
  • GitHub Check: rpm-build:fedora-rawhide-aarch64
  • GitHub Check: rpm-build:fedora-rawhide-aarch64
  • GitHub Check: rpm-build:fedora-43-x86_64
  • GitHub Check: rpm-build:fedora-43-x86_64
  • GitHub Check: rpm-build:fedora-rawhide-x86_64
  • GitHub Check: rpm-build:fedora-43-ppc64le
  • GitHub Check: rpm-build:fedora-rawhide-ppc64le
  • GitHub Check: rpm-build:fedora-43-aarch64
  • GitHub Check: rpm-build:fedora-43-ppc64le
  • GitHub Check: rpm-build:fedora-rawhide-ppc64le
  • GitHub Check: rpm-build:fedora-43-aarch64
  • GitHub Check: rpm-build:fedora-rawhide-x86_64
  • GitHub Check: testing-farm:fedora-43-x86_64:revdeps_udisks
  • GitHub Check: testing-farm:fedora-43-x86_64:revdeps_blivet
  • GitHub Check: testing-farm:fedora-43-aarch64
  • GitHub Check: testing-farm:fedora-43-x86_64
  • GitHub Check: rpm-build:fedora-43-aarch64
  • GitHub Check: rpm-build:fedora-43-x86_64
  • GitHub Check: rpm-build:fedora-rawhide-x86_64
  • GitHub Check: rpm-build:fedora-43-ppc64le
  • GitHub Check: rpm-build:fedora-rawhide-ppc64le
  • GitHub Check: rpm-build:fedora-rawhide-aarch64
  • GitHub Check: compilation (clang-16)
  • GitHub Check: blivet-tests
  • GitHub Check: udisks-build
  • GitHub Check: Analyze (python)
  • GitHub Check: compilation (gcc-14)
  • GitHub Check: Analyze (cpp)
  • GitHub Check: compilation (clang-17)
  • GitHub Check: compilation (clang-14)
  • GitHub Check: compilation (clang-15)
  • GitHub Check: compilation (gcc-12)
  • GitHub Check: compilation (clang-18)
  • GitHub Check: compilation (gcc-10)
  • GitHub Check: compilation (gcc-11)
  • GitHub Check: compilation (gcc-13)
  • GitHub Check: symbols
  • GitHub Check: csmock
🔇 Additional comments (3)
src/plugins/s390.c (3)

803-818: Good: strip trailing newline from hba_id before comparison.

getline() commonly includes the trailing \n; chomping fcphbasysfs avoids false mismatches later.


834-850: Good: strip trailing newline from wwpn read from sysfs.

This makes the subsequent WWPN match deterministic.


867-885: Good: strip trailing newline from fcp_lun read from sysfs.

Prevents spurious mismatches on the LUN comparison.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In @src/plugins/s390.c:
- Line 886: The getline()-allocated strings fcphbasysfs, fcpwwpnsysfs and
fcplunsysfs retain trailing newlines which causes g_strcmp0 comparisons against
devno, wwpn and lun to fail; after each getline() that produces those three
variables (the same locations where fcphbasysfs/fcpwwpnsysfs/fcplunsysfs are
assigned) call g_strchomp() on the buffer to strip trailing whitespace before
any g_strcmp0() comparison (used in the SCSI deletion/matching logic and invoked
by callers such as bd_s390_zfcp_scsi_offline_from_dev). Ensure you add
g_strchomp(fcphbasysfs), g_strchomp(fcpwwpnsysfs) and g_strchomp(fcplunsysfs)
immediately after their respective getline() returns.
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1d15c5a and fa6b811.

📒 Files selected for processing (1)
  • src/plugins/s390.c
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (42)
  • GitHub Check: testing-farm:fedora-43-aarch64
  • GitHub Check: testing-farm:fedora-43-aarch64
  • GitHub Check: testing-farm:fedora-43-x86_64
  • GitHub Check: testing-farm:fedora-43-x86_64
  • GitHub Check: rpm-build:fedora-43-aarch64
  • GitHub Check: rpm-build:fedora-rawhide-aarch64
  • GitHub Check: rpm-build:fedora-43-x86_64
  • GitHub Check: rpm-build:fedora-43-x86_64
  • GitHub Check: rpm-build:fedora-rawhide-x86_64
  • GitHub Check: rpm-build:fedora-43-ppc64le
  • GitHub Check: rpm-build:fedora-43-ppc64le
  • GitHub Check: rpm-build:fedora-43-aarch64
  • GitHub Check: rpm-build:fedora-rawhide-aarch64
  • GitHub Check: rpm-build:fedora-rawhide-x86_64
  • GitHub Check: rpm-build:fedora-rawhide-ppc64le
  • GitHub Check: rpm-build:fedora-rawhide-ppc64le
  • GitHub Check: testing-farm:fedora-43-x86_64:revdeps_udisks
  • GitHub Check: testing-farm:fedora-43-x86_64:revdeps_blivet
  • GitHub Check: testing-farm:fedora-43-x86_64
  • GitHub Check: testing-farm:fedora-43-aarch64
  • GitHub Check: rpm-build:fedora-rawhide-ppc64le
  • GitHub Check: rpm-build:fedora-rawhide-x86_64
  • GitHub Check: rpm-build:fedora-43-x86_64
  • GitHub Check: rpm-build:fedora-rawhide-aarch64
  • GitHub Check: rpm-build:fedora-43-aarch64
  • GitHub Check: rpm-build:fedora-43-ppc64le
  • GitHub Check: compilation (clang-16)
  • GitHub Check: compilation (gcc-10)
  • GitHub Check: compilation (gcc-11)
  • GitHub Check: compilation (gcc-12)
  • GitHub Check: compilation (clang-14)
  • GitHub Check: compilation (clang-18)
  • GitHub Check: compilation (clang-17)
  • GitHub Check: compilation (clang-15)
  • GitHub Check: compilation (gcc-13)
  • GitHub Check: compilation (gcc-14)
  • GitHub Check: csmock
  • GitHub Check: symbols
  • GitHub Check: Analyze (cpp)
  • GitHub Check: udisks-build
  • GitHub Check: blivet-tests
  • GitHub Check: Analyze (python)

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/plugins/s390.c (1)

775-927: Fix is correct; critical memory leaks and logic error need addressing.

The g_strcmp0() comparison fix is correct for string content equality. However, the function has serious issues:

Memory leaks:

  • line allocated by getline() at loop start is never freed
  • scsidev and scsidel are reassigned each iteration without per-iteration cleanup, leaking previous allocations

Logic error: The function always returns TRUE (line 228) even when no matching device is found. This violates the docstring contract ("Returns: whether a LUN was successfully removed") and makes the caller's success check at line 112 meaningless.

Required fixes:

  1. Free line after the loop ends
  2. Add per-iteration cleanup: g_free(scsidev); g_free(scsidel); before loop end
  3. Track whether a device was actually deleted and either return that status or at minimum log a warning if no match found
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fa6b811 and 0e2157b.

📒 Files selected for processing (1)
  • src/plugins/s390.c
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (42)
  • GitHub Check: testing-farm:fedora-43-x86_64
  • GitHub Check: testing-farm:fedora-43-aarch64
  • GitHub Check: testing-farm:fedora-43-aarch64
  • GitHub Check: testing-farm:fedora-43-x86_64
  • GitHub Check: rpm-build:fedora-rawhide-aarch64
  • GitHub Check: rpm-build:fedora-rawhide-aarch64
  • GitHub Check: rpm-build:fedora-43-x86_64
  • GitHub Check: rpm-build:fedora-43-x86_64
  • GitHub Check: rpm-build:fedora-rawhide-x86_64
  • GitHub Check: rpm-build:fedora-43-ppc64le
  • GitHub Check: rpm-build:fedora-rawhide-ppc64le
  • GitHub Check: rpm-build:fedora-43-aarch64
  • GitHub Check: rpm-build:fedora-43-ppc64le
  • GitHub Check: rpm-build:fedora-rawhide-ppc64le
  • GitHub Check: rpm-build:fedora-43-aarch64
  • GitHub Check: rpm-build:fedora-rawhide-x86_64
  • GitHub Check: testing-farm:fedora-43-x86_64:revdeps_udisks
  • GitHub Check: testing-farm:fedora-43-x86_64:revdeps_blivet
  • GitHub Check: testing-farm:fedora-43-aarch64
  • GitHub Check: testing-farm:fedora-43-x86_64
  • GitHub Check: rpm-build:fedora-43-aarch64
  • GitHub Check: rpm-build:fedora-43-x86_64
  • GitHub Check: rpm-build:fedora-rawhide-x86_64
  • GitHub Check: rpm-build:fedora-43-ppc64le
  • GitHub Check: rpm-build:fedora-rawhide-ppc64le
  • GitHub Check: rpm-build:fedora-rawhide-aarch64
  • GitHub Check: compilation (clang-16)
  • GitHub Check: blivet-tests
  • GitHub Check: udisks-build
  • GitHub Check: Analyze (python)
  • GitHub Check: compilation (gcc-14)
  • GitHub Check: Analyze (cpp)
  • GitHub Check: compilation (clang-17)
  • GitHub Check: compilation (clang-14)
  • GitHub Check: compilation (clang-15)
  • GitHub Check: compilation (gcc-12)
  • GitHub Check: compilation (clang-18)
  • GitHub Check: compilation (gcc-10)
  • GitHub Check: compilation (gcc-11)
  • GitHub Check: compilation (gcc-13)
  • GitHub Check: symbols
  • GitHub Check: csmock
🔇 Additional comments (3)
src/plugins/s390.c (3)

803-818: Good: strip trailing newline from hba_id before comparison.

getline() commonly includes the trailing \n; chomping fcphbasysfs avoids false mismatches later.


834-850: Good: strip trailing newline from wwpn read from sysfs.

This makes the subsequent WWPN match deterministic.


867-885: Good: strip trailing newline from fcp_lun read from sysfs.

Prevents spurious mismatches on the LUN comparison.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant