qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH v4 2/2] block/rbd: Add an escape-aware strchr helper


From: Stefano Garzarella
Subject: Re: [PATCH v4 2/2] block/rbd: Add an escape-aware strchr helper
Date: Thu, 22 Apr 2021 09:12:32 +0200

On Wed, Apr 21, 2021 at 04:23:43PM -0500, Connor Kuehl wrote:
Sometimes the parser needs to further split a token it has collected
from the token input stream. Right now, it does a cursory check to see
if the relevant characters appear in the token to determine if it should
break it down further.

However, qemu_rbd_next_tok() will escape characters as it removes tokens
from the token stream and plain strchr() won't. This can make the
initial strchr() check slightly misleading since it implies
qemu_rbd_next_tok() will find the token and split on it, except the
reality is that qemu_rbd_next_tok() will pass over it if it is escaped.

Use a custom strchr to avoid mixing escaped and unescaped string
operations. Furthermore, this code is identical to how
qemu_rbd_next_tok() seeks its next token, so incorporate this custom
strchr into the body of that function to reduce duplication.

Reported-by: Han Han <hhan@redhat.com>
Fixes: https://bugzilla.redhat.com/1873913
Signed-off-by: Connor Kuehl <ckuehl@redhat.com>
---
v3 -> v4:
 * Replace qemu_rbd_next_tok() seek loop with qemu_rbd_strchr() since
   they're identical

block/rbd.c                | 32 +++++++++++++++++++++-----------
tests/qemu-iotests/231     |  4 ++++
tests/qemu-iotests/231.out |  3 +++
3 files changed, 28 insertions(+), 11 deletions(-)

Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>




reply via email to

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