s390: Fix string comparison in bd_s390_zfcp_scsi_offline#1160
Conversation
📝 WalkthroughWalkthroughReplaced pointer equality checks with string content comparisons and added trimming of trailing newlines ( Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
⏰ 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)
🔇 Additional comments (3)
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. Comment |
There was a problem hiding this comment.
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
📒 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)
There was a problem hiding this comment.
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:
lineallocated bygetline()at loop start is never freedscsidevandscsidelare reassigned each iteration without per-iteration cleanup, leaking previous allocationsLogic 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:
- Free
lineafter the loop ends- Add per-iteration cleanup:
g_free(scsidev); g_free(scsidel);before loop end- 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
📒 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 fromhba_idbefore comparison.
getline()commonly includes the trailing\n; chompingfcphbasysfsavoids false mismatches later.
834-850: Good: strip trailing newline fromwwpnread from sysfs.This makes the subsequent WWPN match deterministic.
867-885: Good: strip trailing newline fromfcp_lunread from sysfs.Prevents spurious mismatches on the LUN comparison.
tbzatek
left a comment
There was a problem hiding this comment.
I can't believe the string comparison was done that way!
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.