Received: from eggs.gnu.org ([2001:4830:134:3::10]:43960) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xnhxw-0004xK-Aq for qemu-devel@nongnu.org; Mon, 10 Nov 2014 00:56:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xnhxp-0006dO-O3 for qemu-devel@nongnu.org; Mon, 10 Nov 2014 00:56:40 -0500 Received: from mailout3.samsung.com ([203.254.224.33]:19755) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xnhxp-0006bF-Dg for qemu-devel@nongnu.org; Mon, 10 Nov 2014 00:56:33 -0500 Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NET000JN7670820@mailout3.samsung.com> for qemu-devel@nongnu.org; Mon, 10 Nov 2014 14:56:31 +0900 (KST) From: SeokYeon Hwang References: <1415327095-29770-1-git-send-email-syeon.hwang@samsung.com> <20141107051111.GA7704@air.redhat.com> <87lhnnfof4.fsf@blackfin.pond.sub.org> In-reply-to: <87lhnnfof4.fsf@blackfin.pond.sub.org> Date: Mon, 10 Nov 2014 14:56:39 +0900 Message-id: <011b01cffcab$18bf9690$4a3ec3b0$@samsung.com> MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7bit Content-language: ko Subject: Re: [Qemu-devel] [PATCH v2] error: passing a negative value to an os_errno is wrong List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: 'Markus Armbruster' , 'Amos Kong' Cc: paolo.bonzini@gmail.com, qemu-devel@nongnu.org, mreitz@redhat.com > -----Original Message----- > From: Markus Armbruster [mailto:armbru@redhat.com] > Sent: Friday, November 07, 2014 4:41 PM > To: Amos Kong > Cc: SeokYeon Hwang; mreitz@redhat.com; paolo.bonzini@gmail.com; qemu- > devel@nongnu.org > Subject: Re: [Qemu-devel] [PATCH v2] error: passing a negative value to an > os_errno is wrong > > Amos Kong writes: > > > On Fri, Nov 07, 2014 at 11:24:55AM +0900, SeokYeon Hwang wrote: > >> Added 'assert(os_errno > 0)' in 'error_set_errno()'. > >> Fixed errno since it passes wrong value to 'error_set_errno()'. > >> > >> Signed-off-by: SeokYeon Hwang > >> --- > >> hw/pci/pcie.c | 2 +- > >> util/error.c | 1 + > >> 2 files changed, 2 insertions(+), 1 deletion(-) > >> > >> diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c index 58455bd..2902f7d > >> 100644 > >> --- a/hw/pci/pcie.c > >> +++ b/hw/pci/pcie.c > >> @@ -229,7 +229,7 @@ static void pcie_cap_slot_hotplug_common(PCIDevice > *hotplug_dev, > >> /* the slot is electromechanically locked. > >> * This error is propagated up to qdev and then to HMP/QMP. > >> */ > >> - error_setg_errno(errp, -EBUSY, "slot is electromechanically > locked"); > >> + error_setg_errno(errp, EBUSY, "slot is electromechanically > >> + locked"); > >> } > >> } > >> > >> diff --git a/util/error.c b/util/error.c index 2ace0d8..4ce22cc > >> 100644 > >> --- a/util/error.c > >> +++ b/util/error.c > >> @@ -62,6 +62,7 @@ void error_set_errno(Error **errp, int os_errno, > ErrorClass err_class, > >> return; > >> } > >> assert(*errp == NULL); > >> + assert(os_errno > 0); > > > > strerror(0) will return string 'Success', do we need to reserve zero > here? > > > > assert(os_errno >= 0); > > Yes, because... > > >> err = g_malloc0(sizeof(*err)); > >> > va_start(ap, fmt); > msg1 = g_strdup_vprintf(fmt, ap); > ---> if (os_errno != 0) { > err->msg = g_strdup_printf("%s: %s", msg1, strerror(os_errno)); > g_free(msg1); > } else { > err->msg = msg1; > } > > Please fix. You're right. I posted patch v3. Thank you for your advice.