install: fix simplify conditional expressions and improve error handling#11274
install: fix simplify conditional expressions and improve error handling#11274mattsu2020 wants to merge 1 commit intouutils:mainfrom
Conversation
Refactor several conditional blocks to use let-else statements for cleaner code flow. Simplify error handling in file removal operations by combining conditions. Update backup file handling to use more concise conditional logic. These changes improve code readability while maintaining the same functionality.
|
GNU testsuite comparison: |
|
It looks like these changes simply fix a few instances of |
| if !b.unprivileged && group_id != to_meta.gid() { | ||
| return true; | ||
| } | ||
| if let Some(group_id) = b.group_id |
There was a problem hiding this comment.
I think this is a change in behavior
There was a problem hiding this comment.
Good catch!
Yes, you are right, it's a change in behavior. The current implementation never returns true if group_id == to_meta.gid() whereas the proposed change might return true in such a case (depending on what needs_copy_for_ownership(to, &to_meta) returns).
There was a problem hiding this comment.
I think we can't make any assumptions of correctness with AI generated PRs; we have to verify everything. In particular changes that "simplify conditional expressions" are high-risk.
There was a problem hiding this comment.
@cakebaker In this case there actually are conditions that can be made much more clear, I've submitted #11280.
Since the remaining changes are purely |
Refactor several conditional blocks to use let-else statements for cleaner code flow. Simplify error handling in file removal operations by combining conditions. Update backup file handling to use more concise conditional logic. These changes improve code readability while maintaining the same functionality.