qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH 08/13] qapi: Assert output visitors see only valid enum value


From: Eric Blake
Subject: Re: [PATCH 08/13] qapi: Assert output visitors see only valid enum values
Date: Thu, 23 Apr 2020 12:56:17 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0

On 4/23/20 11:00 AM, Markus Armbruster wrote:
output_type_enum() fails when *obj is not a valid value of the enum
type.  Should not happen.  Drop the check, along with its unit tests.
qapi_enum_lookup()'s assertion still guards.

Signed-off-by: Markus Armbruster <address@hidden>
---
  qapi/qapi-visit-core.c              |  9 -------
  tests/test-qobject-output-visitor.c | 39 -----------------------------
  tests/test-string-output-visitor.c  | 19 --------------
  3 files changed, 67 deletions(-)

Nice cleanup.

The commit message implies adding an assertion; but in reality, the change is deleting dead code (because we already have the assertion in place). Maybe it's worth updating the subject?

Reviewed-by: Eric Blake <address@hidden>

-    /*
-     * TODO why is this an error, not an assertion?  If assertion:
-     * delete, and rely on qapi_enum_lookup()
-     */
-    if (value < 0 || value >= lookup->size) {
-        error_setg(errp, QERR_INVALID_PARAMETER, name ? name : "null");
-        return;
-    }

The comment being deleted is what points out the assertion that already exists.


--
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org




reply via email to

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