qemu-devel
[Top][All Lists]
Advanced

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

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


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

Hi Connor,

On Wed, Apr 21, 2021 at 04:15:42PM -0500, Connor Kuehl wrote:
On 4/21/21 6:04 AM, Stefano Garzarella wrote:
+static char *qemu_rbd_strchr(char *src, char delim)
+{
+    char *p;
+
+    for (p = src; *p; ++p) {
+        if (*p == delim) {
+            return p;
+        }
+        if (*p == '\\' && p[1] != '\0') {
+            ++p;
+        }
+    }
+
+    return NULL;
+}
+

IIUC this is similar to the code used in qemu_rbd_next_tok().
To avoid code duplication can we use this new function inside it?

Hi Stefano! Good catch. I think you're right. I've incorporated your
suggestion into my next revision. The only thing I changed was the
if-statement from:

        if (end && *end == delim) {

to:

        if (end) {

Since qemu_rbd_strchr() will only ever return a non-NULL pointer if it
was able to find 'delim'.

Yeah, definitely better :-)

Thanks,
Stefano




reply via email to

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