diff mbox

[v4] error: passing a negative value to an os_errno is wrong

Message ID 1415776088-4708-1-git-send-email-syeon.hwang@samsung.com
State New
Headers show

Commit Message

SeokYeon Hwang Nov. 12, 2014, 7:08 a.m. UTC
Added 'assert(os_errno >= 0)' in 'error_set_errno()'.

Signed-off-by: SeokYeon Hwang <syeon.hwang@samsung.com>
---
 util/error.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Markus Armbruster Nov. 12, 2014, 7:35 a.m. UTC | #1
SeokYeon Hwang <syeon.hwang@samsung.com> writes:

> Added 'assert(os_errno >= 0)' in 'error_set_errno()'.
>
> Signed-off-by: SeokYeon Hwang <syeon.hwang@samsung.com>
> ---
>  util/error.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/util/error.c b/util/error.c
> index 2ace0d8..6c9d995 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);
>  
>      err = g_malloc0(sizeof(*err));

Too risky for 2.2 at this stage, but fine for 2.3.

Reviewed-by: Markus Armbruster <armbru@redhat.com>
Max Reitz Nov. 12, 2014, 8:30 a.m. UTC | #2
On 2014-11-12 at 08:08, SeokYeon Hwang wrote:
> Added 'assert(os_errno >= 0)' in 'error_set_errno()'.
>
> Signed-off-by: SeokYeon Hwang <syeon.hwang@samsung.com>
> ---
>   util/error.c | 1 +
>   1 file changed, 1 insertion(+)
>
> diff --git a/util/error.c b/util/error.c
> index 2ace0d8..6c9d995 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);
>   
>       err = g_malloc0(sizeof(*err));
>   

Reviewed-by: Max Reitz <mreitz@redhat.com>
diff mbox

Patch

diff --git a/util/error.c b/util/error.c
index 2ace0d8..6c9d995 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);
 
     err = g_malloc0(sizeof(*err));