[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v4 1/5] net: Clarify early exit condition
From: |
Eric Blake |
Subject: |
Re: [PATCH v4 1/5] net: Clarify early exit condition |
Date: |
Tue, 19 Jan 2021 10:08:03 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 |
On 1/13/21 10:54 PM, Vladimir Sementsov-Ogievskiy wrote:
> 14.01.2021 01:10, Eric Blake wrote:
>> On first glance, the loop in qmp_query_rx_filter() has early return
>> paths that could leak any allocation of filter_list from a previous
>> iteration. But on closer inspection, it is obvious that all of the
>> early exits are guarded by has_name, and that the bulk of the loop
>> body can be executed at most once if the user is filtering by name,
>> thus, any early exit coincides with an empty list. Add asserts to
>> make this obvious.
>
> A bit simpler (for me :) observation:
>
> But on closer inspection, it is obvious that all of the early exits are
> guarded by has_name, and in case when has_name is true we leave the loop
s/in case//
> (by break) immediately after allocation and assigning filter_list for
> the first time.
Replacing my wording with this touched-up sentence is fine with me, if
Markus would like to tweak the queued commit to incorporate it.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
- [PATCH v4 0/5] Common macros for QAPI list growth, Eric Blake, 2021/01/13
- [PATCH v4 3/5] qapi: Introduce QAPI_LIST_APPEND, Eric Blake, 2021/01/13
- [PATCH v4 1/5] net: Clarify early exit condition, Eric Blake, 2021/01/13
- [PATCH v4 2/5] qapi: A couple more QAPI_LIST_PREPEND() stragglers, Eric Blake, 2021/01/13
- [PATCH v4 4/5] qapi: Use QAPI_LIST_APPEND in trivial cases, Eric Blake, 2021/01/13
- [PATCH v4 5/5] qapi: More complex uses of QAPI_LIST_APPEND, Eric Blake, 2021/01/13
- Re: [PATCH v4 0/5] Common macros for QAPI list growth, Markus Armbruster, 2021/01/14