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

hiffy: differentiate dead codes from error codes #472

Merged
merged 3 commits into from
Apr 10, 2024

Conversation

hawkw
Copy link
Member

@hawkw hawkw commented Apr 9, 2024

When invoking an IPC using humility-hiffy, the result is represented as a u32. Calling code typically will then attempt to turn that u32 back into the IPC interface's error code. However, if the server task that Hiffy called into has died, the u32 will instead be a dead code, which cannot be translated into a named error code using the Idol interface (or similar). Therefore, this branch updates humility hiffy to return an IpcError enum instead, which is either an error code or a dead code. This forces callers to differentiate between these cases, and not print out random integers when the server task has died.

@hawkw hawkw requested review from cbiffle and mkeeter April 9, 2024 18:01
When invoking an IPC using `humility-hiffy`, the result is represented
as a `u32`. Calling code typically will then attempt to turn that `u32`
back into the IPC interface's error code. However, if the server task
that Hiffy called into has died, the `u32` will instead be a dead code,
which cannot be translated into a named error code using the Idol
interface (or similar). Therefore, this branch updates `humility hiffy`
to return an `IpcError` enum instead, which is either an error code or a
dead code. This forces callers to differentiate between these cases, and
not print out random integers when the server task has died.
Copy link
Contributor

@bcantrill bcantrill left a comment

Choose a reason for hiding this comment

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

Looks good -- please bump the micro version as well!

@@ -2274,12 +2274,13 @@ fn rendmp(context: &mut ExecutionContext) -> Result<()> {
}
};

let word_result = |result: &Result<Vec<u8>, u32>, what| -> Result<u32> {
let word_result = |result: &Result<Vec<u8>, IpcError>,
what|
Copy link
Contributor

Choose a reason for hiding this comment

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

...are you okay, rustfmt?

Copy link
Member Author

Choose a reason for hiding this comment

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

what|

cmd/validate/src/lib.rs Outdated Show resolved Hide resolved
humility-hiffy/src/lib.rs Outdated Show resolved Hide resolved
humility-hiffy/src/lib.rs Outdated Show resolved Hide resolved
@hawkw hawkw enabled auto-merge (squash) April 10, 2024 20:40
@hawkw hawkw merged commit df09cf8 into master Apr 10, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants