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: should early return when disassembled text is null #17

Merged
merged 1 commit into from
Mar 15, 2021
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
8 changes: 6 additions & 2 deletions src/assembler/compiled.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,19 @@ impl Assembler for CompiledAssembler {

match res {
shared::SpirvResult::Success => {
if text.is_null() && !options.print {
return Err(crate::error::Error {
if text.is_null() {
if !options.print {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this line make it strange to report an error while printing, should we accept null text as empty string for all success case?

Copy link
Contributor Author

@CurryPseudo CurryPseudo Mar 16, 2021

Choose a reason for hiding this comment

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

If print option is off, then text should not be null and error should be reported.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This line here will not report error while printing, it is !options.print

Copy link
Contributor

Choose a reason for hiding this comment

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

Whatever print or not, if ret is Success, there should be no error.

return Err(crate::error::Error {
inner: shared::SpirvResult::InternalError,
diagnostic: Some(
"spirv disassemble indicated success but did not return valid text"
.to_owned()
.into(),
),
});
} else {
return Ok(String::default());
}
}

// Sanity check the text first
Expand Down