From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51936) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XFCrl-0001YU-6N for qemu-devel@nongnu.org; Wed, 06 Aug 2014 21:51:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XFCrg-0006Xw-Cf for qemu-devel@nongnu.org; Wed, 06 Aug 2014 21:51:41 -0400 Received: from szxga02-in.huawei.com ([119.145.14.65]:39027) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XFCrf-0006Wn-Qg for qemu-devel@nongnu.org; Wed, 06 Aug 2014 21:51:36 -0400 Message-ID: <53E2DB73.50200@huawei.com> Date: Thu, 7 Aug 2014 09:50:43 +0800 From: zhanghailiang MIME-Version: 1.0 References: <1407305758-13108-1-git-send-email-zhang.zhanghailiang@huawei.com> <1407305758-13108-5-git-send-email-zhang.zhanghailiang@huawei.com> <889919637.11247423.1407328255674.JavaMail.zimbra@redhat.com> In-Reply-To: <889919637.11247423.1407328255674.JavaMail.zimbra@redhat.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v2 4/4] ivshmem: check the value returned by fstat() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Levente Kurusa Cc: kwolf@redhat.com, alex@alex.org.uk, mst@redhat.com, luonengjun@huawei.com, peter huangpeng , qemu-devel@nongnu.org, stefanha@redhat.com, pbonzini@redhat.com, lcapitulino@redhat.com, alex bennee On 2014/8/6 20:30, Levente Kurusa wrote: >> The function fstat() may fail, so check its return value. >> >> Signed-off-by: zhanghailiang >> --- >> 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. Hmmm, this is more clear, i will change it.Thanks!