qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Levente Kurusa <lkurusa@redhat.com>
To: zhanghailiang <zhang.zhanghailiang@huawei.com>
Cc: kwolf@redhat.com, alex@alex.org.uk, mst@redhat.com,
	luonengjun@huawei.com,
	peter huangpeng <peter.huangpeng@huawei.com>,
	qemu-devel@nongnu.org, stefanha@redhat.com, pbonzini@redhat.com,
	lcapitulino@redhat.com, alex bennee <alex.bennee@linaro.org>
Subject: Re: [Qemu-devel] [PATCH v2 4/4] ivshmem: check the value returned by	fstat()
Date: Wed, 6 Aug 2014 08:30:55 -0400 (EDT)	[thread overview]
Message-ID: <889919637.11247423.1407328255674.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: <1407305758-13108-5-git-send-email-zhang.zhanghailiang@huawei.com>

> The function fstat() may fail, so check its return value.
> 
> Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
> ---
>  hw/misc/ivshmem.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c
> index 768e528..5d939d2 100644
> --- a/hw/misc/ivshmem.c
> +++ b/hw/misc/ivshmem.c
> @@ -324,7 +324,11 @@ static int check_shm_size(IVShmemState *s, int fd) {
>  
>      struct stat buf;
>  
> -    fstat(fd, &buf);
> +    if (fstat(fd, &buf) < 0) {
> +        fprintf(stderr, "ivshmem: exiting for fstat fd '%d' failed: %s\n",
> +                fd, strerror(errno));

exiting for fstat?

I would go with something like this:

"ivshmem: exiting: fstat on fd %d failed: %s"

... or something among the lines.

Thanks!
Levente Kurusa

  reply	other threads:[~2014-08-06 12:31 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-06  6:15 [Qemu-devel] [PATCH v2 0/4] fix several bugs about use-after-free and an api abuse zhanghailiang
2014-08-06  6:15 ` [Qemu-devel] [PATCH v2 1/4] l2cap: fix access freed memory zhanghailiang
2014-08-06  6:15 ` [Qemu-devel] [PATCH v2 2/4] monitor: " zhanghailiang
2014-08-06  6:15 ` [Qemu-devel] [PATCH v2 3/4] virtio-blk: fix reference a pointer which might be freed zhanghailiang
2014-08-06  6:15 ` [Qemu-devel] [PATCH v2 4/4] ivshmem: check the value returned by fstat() zhanghailiang
2014-08-06 12:30   ` Levente Kurusa [this message]
2014-08-07  1:50     ` zhanghailiang

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=889919637.11247423.1407328255674.JavaMail.zimbra@redhat.com \
    --to=lkurusa@redhat.com \
    --cc=alex.bennee@linaro.org \
    --cc=alex@alex.org.uk \
    --cc=kwolf@redhat.com \
    --cc=lcapitulino@redhat.com \
    --cc=luonengjun@huawei.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.huangpeng@huawei.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    --cc=zhang.zhanghailiang@huawei.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).