Daniel P. BerrangĂ© <[email protected]> writes:

> On Wed, Sep 10, 2025 at 01:05:40PM +0200, Markus Armbruster wrote:
>> Daniel P. BerrangĂ© <[email protected]> writes:
>> > On Fri, Aug 08, 2025 at 11:30:32AM +0200, Markus Armbruster wrote:
>> >
>> > I don't see 'warnings' as something directly actionable for a user.
>> > Rather they are messages that I would want to see included in a log
>> > file that a user attaches to a bug report if they find some behavioural
>> > problem. If the user understands the warning great, but that isn't a
>> > requirement.
>> >
>> > IOW, while informative warnings is of course better than not, as long
>> > as the warning message contains sufficient info for the maintainer to
>> > understand what happened the minimum quality bar is satisfied IMHO.
>> 
>> That's a low quality bar indeed.  Here's mine:
>> 
>> 1. A warning should make perfectly clear whether this is a bug that
>> should be reported, or an issue with usage, resources, etc. that can be
>> ignored, but may help understand future trouble, if any (typically an
>> ordinary error that wasn't fully handled).  Our errors make bug
>> vs. ordinary error clear.
>> 
>> 2. A warning of the former kind (bug) should provide information
>> developers need to start debugging.  For errors, we give them a core
>> dump, source file and line number.  For warnings, we currently give them
>> grep and warm wishes.
>
> Don't understate the value of "grep"  :-)
>
> It is my #1 tool when I see a string mentioned in bug report, whether
> that's from error_report or warn_report.
>
> What annoys/frustrates me is when the message (whether an eror or
> warning) lacks the technical details of exactly what failed.
>
> ie if the message doesn't substitute in either the errno value, or the
> strerror string, or equivalent, then it massively reduces the chances
> of diagnosis unless the bug is easily reproducible.

True.

>> 3. A warning of the latter kind (not a bug) should at least try to
>> provide hints that help users diagnose and correct / work around what's
>> wrong.  "warning: failed to WSAEventSelect()" doesn't.  "warning:
>> trouble initializing slirp for user mode networking" might.
>
> I agree that the latter is more informative for users, though for
> developers it might be worse as such a generic message may provide
> cover for several different low level problems. 

My two example messages are differently generic :)

The first tells a user nothing, and a developer which function failed.
It doesn't tell what failed.  If we're lucky, only one thing can fail
this way, so finding it is easy enough.  Are we feeling lucky?

The second tells both of them what failed, but doesn't tell the
developer how exactly it failed.

> Neither help me diagnose the problem though if I see them in a bug
> report though, because neither include the "WSAGetLastError()" value
> (or its string equivalent).
>
> Probably we deserve both.

No objection at all as long as the message remains useful to the users.
Remember, this kind of warning is for users first, developers second.
Warnings about bugs are the other way round.

>                           In the case of "Error" objects, we have
> error_prepend so code can do
>
>   error_setg(errp, "failed to WSAEventSelect: %s", WSAGetLastError())
>
> and then the caller one or more levels up the stack can do
>
>   error_prepend(errp, "unable to initialize slirp user mode networking")
>
> which becomes useful when we see the final error_report() or equiv.
>
> We don't have an error_prepend concept for warnings 

I'm not following.  error_prepend() doesn't care how the error it
modifies will be consumed.  The following should just work:

    error_setg(errp, "failed to WSAEventSelect: %s", WSAGetLastError())
    ... up the stack some ...
    error_prepend(errp, "unable to initialize slirp user mode networking")
    ... up the stack some more ...
    warn_report_err(err);

We even have a convenience function to warn with prepended text:

    error_setg(errp, "failed to WSAEventSelect: %s", WSAGetLastError())
    ... up the stack some ...
    warn_reportf_err(err, "unable to initialize slirp user mode networking: ")


Reply via email to