[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v2] error: passing a negative value to an os_err
From: |
Amos Kong |
Subject: |
Re: [Qemu-devel] [PATCH v2] error: passing a negative value to an os_errno is wrong |
Date: |
Fri, 7 Nov 2014 13:11:11 +0800 |
User-agent: |
Mutt/1.5.23 (2014-03-12) |
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 <address@hidden>
> ---
> 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);
>
> err = g_malloc0(sizeof(*err));
>
> --
> 2.1.0
>
--
Amos.
signature.asc
Description: Digital signature