-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix wrong assertion in libzfs diff error handling #8743
Conversation
In compare(), all error cases set the error code to EPIPE, so when an error is set, the correct assertion to make is that the error is EPIPE, not EINVAL. Signed-off-by: Ryan Moeller <[email protected]>
Codecov Report
@@ Coverage Diff @@
## master #8743 +/- ##
==========================================
- Coverage 78.97% 78.74% -0.24%
==========================================
Files 381 381
Lines 117797 117797
==========================================
- Hits 93034 92760 -274
- Misses 24763 25037 +274
Continue to review full report at Codecov.
|
@@ -478,7 +478,7 @@ differ(void *arg) | |||
if (err) | |||
return ((void *)-1); | |||
if (di->zerr) { | |||
ASSERT(di->zerr == EINVAL); | |||
ASSERT(di->zerr == EPIPE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, the updated code looks right and I'm OK with it as is. But I wonder if it wouldn't be better to instead remove the ASSERT and update the error message to log the di->err
. This way it's still useful even in non-debug builds.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer the ASSERT since it informs the reader that any other value here would be a programming error, not a conceivable run-time error. The value of di->zerr
will only ever be EPIPE in this context, and the assertion serves to document that fact. The purpose of this special case is to give a more relevant internal error message in the context of differ()
. Any other possible non-zero value of di->zerr
should result in err
being set as well, and is therefore covered by the preceding if (err) return -1;
.
In compare(), all error cases set the error code to EPIPE, so when an error is set, the correct assertion to make is that the error is EPIPE, not EINVAL. Reviewed-by: Richard Elling <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Ryan Moeller <[email protected]> Closes openzfs#8743
In compare(), all error cases set the error code to EPIPE, so when an error is set, the correct assertion to make is that the error is EPIPE, not EINVAL. Reviewed-by: Richard Elling <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Ryan Moeller <[email protected]> Closes openzfs#8743
Motivation and Context
During testing of the ZoL port to FreeBSD, this mishandled error case was discovered. It should be fixed for correctness.
Description
In differ(), all error cases set the error code to EPIPE, so when an error is set, the correct assertion to make is that the error is EPIPE, not EINVAL.
How Has This Been Tested?
I have run ZTS against this change.
Types of changes
Checklist:
Signed-off-by
.