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 12:27:05 +0100 [thread overview]
Message-ID: <510F9B09.7030804@adacore.com> (raw)
In-Reply-To: <87k3qov047.fsf@blackfin.pond.sub.org>
On 02/04/2013 11:34 AM, Markus Armbruster wrote:
> Stefan Hajnoczi <stefanha@redhat.com> writes:
>
>> On Fri, Feb 01, 2013 at 06:13:51PM +0100, Fabien Chouteau wrote:
>>>
>>> Signed-off-by: Fabien Chouteau <chouteau@adacore.com>
>>> ---
>>> block.c | 13 ++++++++++---
>>> 1 file changed, 10 insertions(+), 3 deletions(-)
>>
>> Hi Fabien,
>> Please always CC qemu-devel@nongnu.org. All patches must be on
>> qemu-devel so that the community can review them - not everyone
>> subscribes to qemu-trivial.
>>
>> Thanks,
>> Stefan
>>
>>> diff --git a/block.c b/block.c
>>> index ba67c0d..3bf8eda 100644
>>> --- a/block.c
>>> +++ b/block.c
>>> @@ -428,9 +428,16 @@ int get_tmp_filename(char *filename, int size)
>>> /* GetTempFileName requires that its output buffer (4th param)
>>> have length MAX_PATH or greater. */
>>> assert(size >= MAX_PATH);
>>> - return (GetTempPath(MAX_PATH, temp_dir)
>>> - && GetTempFileName(temp_dir, "qem", 0, filename)
>>> - ? 0 : -GetLastError());
>>> + if (GetTempPath(MAX_PATH, temp_dir) == 0) {
>>> + fprintf(stderr, "GetTempPath() error: %d\n", GetLastError());
>>> + return -GetLastError();
>>> + }
>>> + if (GetTempFileName(temp_dir, "qem", 0, filename) == 0) {
>>> + fprintf(stderr, "GetTempFileName(%s) error: %d\n", temp_dir,
>>> + GetLastError());
>>> + return -GetLastError();
>>> + }
>>> + return 0;
>>> #else
>>> int fd;
>>> const char *tmpdir;
>
> get_tmp_filename() is not supposed to print to stderr, that's the
> caller's job.
>
Why? The caller doesn't know the difference between Windows/Linux
implementation. And the error handling would have to be duplicated.
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.
--
Fabien Chouteau
next prev parent reply other threads:[~2013-02-04 11:27 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 [this message]
2013-02-04 12:24 ` Markus Armbruster
2013-02-04 13:33 ` Fabien Chouteau
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=510F9B09.7030804@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.