qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 3/4] Add error checking for event_notifier_init.


From: Stefan Hajnoczi
Subject: Re: [Qemu-devel] [PATCH 3/4] Add error checking for event_notifier_init.
Date: Sun, 16 Oct 2016 17:58:55 +0100
User-agent: Mutt/1.7.0 (2016-08-17)

On Sun, Oct 16, 2016 at 12:50:58AM -0000, Shreya Shrivastava wrote:
> Add checks for negative return value to uses of event_notifier_init.
> Signed-off-by: Shreya Shrivastava <address@hidden>
> 
> ---
>  tests/test-aio.c | 59
> ++++++++++++++++++++++++++++----------------------------
>  1 file changed, 30 insertions(+), 29 deletions(-)
> 
> diff --git a/tests/test-aio.c b/tests/test-aio.c
> index 03aa846..49b99f6 100644
> --- a/tests/test-aio.c
> +++ b/tests/test-aio.c
> @@ -137,8 +137,8 @@ static void test_acquire(void)
>      AcquireTestData data;
> 
>      /* Dummy event notifier ensures aio_poll() will block */
> -    event_notifier_init(&notifier, false);
> -    set_event_notifier(ctx, &notifier, dummy_notifier_read);
> +    if (event_notifier_init(&notifier, false))
> +        set_event_notifier(ctx, &notifier, dummy_notifier_read);

Silently ignoring the error is not useful.

You could define a helper function:

static void check_event_notifier_init(EventNotifier *notifier)
{
    int ret = event_notifier_init(notifier, false);

    g_assert(ret == 0);
}

Then use the helper instead of calling event_notifier_init() directly.
That way the test case will fail loudly if event_notifier_int() failed.

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]