numfmt: report warnings with show_error! #16854
this no longer includes the utility name, no?
<!-- __CODSPEED_PERFORMANCE_REPORT_COMMENT__ -->
Merging this PR will improve performance by 17.59%
<details>
<summary><b>2 warnings, 1 note</b></summary>
:warning: 125 benchmarks are dominated by system calls
> System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.
> Learn more about system calls
> See affected benchmarks
:warning: 1 benchmark with a significant change ran on different hardware
> Its base and head results were measured on machines with a different CPU, core count or memory, so the change might not come from the code. Run base and head on the same runner type.
> Learn more about Macro Runners
> See affected benchmarks
:information_source: 1 benchmark has no flamegraph
> The flamegraph wasn't generated: most of the time was spent in runtime internals, which would leave nothing useful to analyze.
> See affected benchmarks
</details>
⚡ 1 improved benchmark ✅ 414 untouched benchmarks ⏩ 70 skipped benchmarks[^skipped]
Performance Changes
| | Mode | Benchmark | BASE | HEAD | Efficiency |
| --- | ---- | --------- | ------ | ------ | ---------- |
| ⚡ | Memory | [` cp_recursive_deep_tree[(120, 4)] ](https://app.codspeed.io/uutils/coreutils/branches/Abak2006%3Anumfmt-stderr-write-error?uri=src%2Fuu%2Fcp%2Fbenches%2Fcp_bench.rs%3A%3Acp_recursive_deep_tree%255B%28120%252C%25204%29%255D&runnerMode=Memory&utm_source=github&utm_medium=comment-v2&utm_content=benchmark) | 789 KB | 671 KB | +17.59% |
[!TIP]
Curious why performance improved? Comment @codspeedbot explain why performance improved` on this PR, or directly use the CodSpeed MCP with your agent.
---
<sub>Comparing <code>Abak2006:numfmt-stderr-write-error</code> (b42709a) with <code>main</code> (9ed1dfc)</sub>
<a href="https://app.codspeed.io/uutils/coreutils/branches/Abak2006%3Anumfmt-stderr-write-error?utm_source=github&utm_medium=comment-v2&utm_content=button">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://codspeed.io/pr-report/open-in-codspeed-dark.svg">
<source media="(prefers-color-scheme: light)" srcset="https://codspeed.io/pr-report/open-in-codspeed-light.svg">
<img alt="Open in CodSpeed" src="https://codspeed.io/pr-report/open-in-codspeed-light.svg" width="169" height="32">
</picture>
</a>
[^skipped]: 70 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.
show_error goes through print_diagnostic, which adds the util name, so it still prints "numfmt: ...". The existing warn and debug tests check for that prefix and they pass.
xtqqczze
Abak2006
Part of #16646. Depends on #16853. This branch includes that commit, so please review only the last commit.
numfmt printed its
--debugwarnings and--invalid=warnmessages with its ownlet _ = writeln!(stderr(), "numfmt: ...")calls, which ignore write errors. Sonumfmt --debug 42 2>/dev/fullexited 0, while GNU exits 1.These calls now use
show_error!, which prints the samenumfmt: <message>line throughprint_diagnostic(). With #16853, that sets exit code 1 when the write fails. Output on stdout is unchanged, and normal runs still exit 0.Tests:
test_warning_write_error_sets_exit_codetotest_numfmt.rs, covering--debugand--invalid=warn.cargo test -p uu_numfmtand thetest_numfmtintegration tests pass;cargo fmt --checkand clippy are clean.