All of lore.kernel.org
 help / color / mirror / Atom feed
From: Fabien Chouteau <chouteau@adacore.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: qemu-trivial@nongnu.org, kwolf@redhat.com, qemu-devel@nongnu.org,
	Stefan Hajnoczi <stefanha@redhat.com>
Subject: Re: [Qemu-trivial] [Qemu-devel] [PATCH] get_tmp_filename: add explicit error message
Date: Mon, 04 Feb 2013 14:33:18 +0100	[thread overview]
Message-ID: <510FB89E.1080504@adacore.com> (raw)
In-Reply-To: <87obg0s1wf.fsf@blackfin.pond.sub.org>

On 02/04/2013 01:24 PM, Markus Armbruster wrote:
> Fabien Chouteau <chouteau@adacore.com> writes:
> 
>> On 02/04/2013 11:34 AM, Markus Armbruster wrote:
>>
>> Why? The caller doesn't know the difference between Windows/Linux
>> implementation. And the error handling would have to be duplicated.
> 
> The function's (implied) contract is to return an error code without
> printing anything.  If you want to change the contract to include
> reporting the error, you need to implement it both for both arms of the
> #ifdef.  You also have to demonstrate that all callers are happy with
> the change of contract.
> 
> Regardless, printing to stderr is wrong.  The function can be called on
> behalf of a monitor command, and then the error needs to be printed to
> the correct monitor.  error_report() can do that for you, and more.
> 

Alright, so I will use error_report() and do it for both Linux and Windows.

>> It's not the first time I add error output in Windows code. Specially in
>> block/, when there's an error, the only thing you get is: "operation not
>> permitted". It's not very helpful and you have to dig in the code to
>> find which function failed.
> 
> Good error reporting is hard.  Knowledge about the error and its context
> gets lost as you move up the call chain.  Knowledge about how to report
> errors gets lost as you move down.
> 

You're right, and in my opinion, no error reporting is the worst case.

-- 
Fabien Chouteau


  reply	other threads:[~2013-02-04 13:33 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-01 17:13 [Qemu-trivial] [PATCH] get_tmp_filename: add explicit error message Fabien Chouteau
2013-02-04  8:39 ` Stefan Hajnoczi
2013-02-04 10:34   ` [Qemu-trivial] [Qemu-devel] " Markus Armbruster
2013-02-04 11:27     ` Fabien Chouteau
2013-02-04 12:24       ` Markus Armbruster
2013-02-04 13:33         ` Fabien Chouteau [this message]
2013-02-04 13:48           ` Andreas Färber

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=510FB89E.1080504@adacore.com \
    --to=chouteau@adacore.com \
    --cc=armbru@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.