Skip to content
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

Merged
merged 1 commit into from May 20, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/libzfs/libzfs_diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ differ(void *arg)
if (err)
return ((void *)-1);
if (di->zerr) {
ASSERT(di->zerr == EINVAL);
ASSERT(di->zerr == EPIPE);
Copy link
Contributor

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.

Copy link
Author

@ghost ghost May 15, 2019

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;.

(void) snprintf(di->errbuf, sizeof (di->errbuf),
dgettext(TEXT_DOMAIN,
"Internal error: bad data from diff IOCTL"));
Expand Down