Skip to content

Remove strerror in favor of decode_error#683

Merged
mkeeter merged 1 commit into
masterfrom
mkeeter/remove-strerror
May 28, 2026
Merged

Remove strerror in favor of decode_error#683
mkeeter merged 1 commit into
masterfrom
mkeeter/remove-strerror

Conversation

@mkeeter
Copy link
Copy Markdown
Contributor

@mkeeter mkeeter commented May 26, 2026

(staged on #682)

This is a small PR to consolidate IpcError decoding into a single place (IdolOperation::decode_error).

I don't try to preserve the exact error formatting; if you have opinions on what information would be useful, see #680 for where the new error type is introduced. I'd be surprised if anyone was parsing CLI output for exact strings here, but cc @adamlouis just in case.

@mkeeter mkeeter force-pushed the mkeeter/remove-strerror branch from b3c4cc3 to 310405b Compare May 26, 2026 20:06
@mkeeter mkeeter force-pushed the mkeeter/hiffy-call-method branch from 06762af to 9bef9ab Compare May 26, 2026 20:18
@mkeeter mkeeter force-pushed the mkeeter/remove-strerror branch 2 times, most recently from 3e9c3e6 to 8d5a5bc Compare May 27, 2026 17:18
@mkeeter mkeeter force-pushed the mkeeter/hiffy-call-method branch from 9bef9ab to 5004e39 Compare May 27, 2026 17:18
@mkeeter mkeeter force-pushed the mkeeter/hiffy-call-method branch from 5004e39 to 11943a3 Compare May 27, 2026 19:30
@mkeeter mkeeter force-pushed the mkeeter/remove-strerror branch from 8d5a5bc to 4e0d6fb Compare May 27, 2026 19:30
Comment on lines 166 to 168
if let Err(err) = results[rindex] {
bail!("failed to take dump: {}", op.strerror(err))
return Err(op.decode_error(err)).context("failed to take dump");
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit, take it or leave it: now that this is no longer using bail, i feel like it could be changed to something like

results[rindex].map_err(|err| op.decode_error(err).context("failed to take dump")?;

also: i was...quite struck...by the potential alternative interpretation of the string "failed to take dump". if this is not immediately obvious to you, you're probably better off that way!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

sooooo I considered writing it in that form, but vaguely decided against it for two reasons:

  • rustfmt wraps onto multiple lines, so it's not any shorter
  • Vague vibes: I feel like ? as a way to return an error – when you're not using the actual value – is a little less obvious than an explicit return. It's fine in a chain where the end result is used, but seems to sneaky when used as a one-character conditional return.

(I have no further comment on the text of the string 🙈)

Comment on lines 100 to +106
if let Err(err) = result {
bail!(
"failed to add segment at address {base:#x} for length \
{size}: {}",
op.strerror(*err),
);
return Err(op.decode_error(*err)).with_context(|| {
format!(
"failed to add segment at address {base:#x} \
for length {size}"
)
});
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

take it or leave it: this could ? now that it no longer uses bail!?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Same here, I'd rather be explicit versus result.map_err(...)?

@mkeeter mkeeter force-pushed the mkeeter/hiffy-call-method branch from 11943a3 to 6b30409 Compare May 27, 2026 21:01
@mkeeter mkeeter force-pushed the mkeeter/remove-strerror branch 2 times, most recently from 527e208 to b85e8e1 Compare May 27, 2026 21:30
@mkeeter mkeeter force-pushed the mkeeter/hiffy-call-method branch from 6b30409 to 1bdb2f7 Compare May 27, 2026 21:30
@mkeeter mkeeter force-pushed the mkeeter/remove-strerror branch from b85e8e1 to f1176b6 Compare May 28, 2026 12:37
@mkeeter mkeeter force-pushed the mkeeter/hiffy-call-method branch from 1bdb2f7 to bf11d08 Compare May 28, 2026 12:37
@mkeeter mkeeter force-pushed the mkeeter/remove-strerror branch from f1176b6 to df8c94d Compare May 28, 2026 13:56
@mkeeter mkeeter force-pushed the mkeeter/hiffy-call-method branch 2 times, most recently from 9b94c7a to f6196a5 Compare May 28, 2026 14:23
@mkeeter mkeeter force-pushed the mkeeter/remove-strerror branch 2 times, most recently from 824a6db to 675343f Compare May 28, 2026 15:31
@mkeeter mkeeter force-pushed the mkeeter/hiffy-call-method branch from f6196a5 to 40a3fb8 Compare May 28, 2026 15:31
@mkeeter mkeeter force-pushed the mkeeter/remove-strerror branch from 675343f to eae72e0 Compare May 28, 2026 16:00
@mkeeter mkeeter force-pushed the mkeeter/hiffy-call-method branch 2 times, most recently from 418aa09 to bc6d425 Compare May 28, 2026 17:39
@mkeeter mkeeter force-pushed the mkeeter/remove-strerror branch from eae72e0 to 6405216 Compare May 28, 2026 17:39
Base automatically changed from mkeeter/hiffy-call-method to master May 28, 2026 18:08
@mkeeter mkeeter force-pushed the mkeeter/remove-strerror branch from 6405216 to e6c0ea4 Compare May 28, 2026 18:09
@mkeeter mkeeter requested a review from Copilot May 28, 2026 18:22
@mkeeter mkeeter enabled auto-merge (squash) May 28, 2026 18:24
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Consolidates Idol IPC error decoding by removing IdolOperation::strerror and routing callers through the typed IdolOperation::decode_error path, so Idol error interpretation lives in one place.

Changes:

  • Removed IdolOperation::strerror from humility-idol in favor of IdolOperation::decode_error.
  • Updated humility-dump-agent to surface decoded Idol errors via anyhow::Context chains.
  • Updated cmd/pmbus to format errors via decode_error(...).to_string().

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
humility-idol/src/lib.rs Removes strerror API to centralize error decoding in decode_error.
humility-dump-agent/src/hiffy.rs Replaces strerror usage with typed decode + contextual error propagation.
cmd/pmbus/src/lib.rs Switches error-to-string formatting from strerror to decode_error.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

assert_eq!(out.len(), 1);
if let Err(err) = &out[0] {
bail!("failed to dump task region: {}", op.strerror(*err))
Err(op.decode_error(*err)).context("failed to dump task region")
@mkeeter mkeeter merged commit 38e3699 into master May 28, 2026
13 checks passed
@mkeeter mkeeter deleted the mkeeter/remove-strerror branch May 28, 2026 18:45
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.

4 participants