[Qemu-devel] [PATCH RFC v3 for-2.9 04/11] rbd: Clean up after the previous commit

Markus Armbruster posted 11 patches 8 years, 10 months ago
There is a newer version of this series
[Qemu-devel] [PATCH RFC v3 for-2.9 04/11] rbd: Clean up after the previous commit
Posted by Markus Armbruster 8 years, 10 months ago
This code in qemu_rbd_parse_filename()

    found_str = qemu_rbd_next_tok(p, '\0', &p);
    p = found_str;

has no effect.  Drop it, and simplify qemu_rbd_next_tok().

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
 block/rbd.c | 24 +++++++++---------------
 1 file changed, 9 insertions(+), 15 deletions(-)

diff --git a/block/rbd.c b/block/rbd.c
index 0fea348..182a5a3 100644
--- a/block/rbd.c
+++ b/block/rbd.c
@@ -104,19 +104,17 @@ static char *qemu_rbd_next_tok(char *src, char delim, char **p)
 
     *p = NULL;
 
-    if (delim != '\0') {
-        for (end = src; *end; ++end) {
-            if (*end == delim) {
-                break;
-            }
-            if (*end == '\\' && end[1] != '\0') {
-                end++;
-            }
-        }
+    for (end = src; *end; ++end) {
         if (*end == delim) {
-            *p = end + 1;
-            *end = '\0';
+            break;
         }
+        if (*end == '\\' && end[1] != '\0') {
+            end++;
+        }
+    }
+    if (*end == delim) {
+        *p = end + 1;
+        *end = '\0';
     }
     return src;
 }
@@ -177,10 +175,6 @@ static void qemu_rbd_parse_filename(const char *filename, QDict *options,
         goto done;
     }
 
-    found_str = qemu_rbd_next_tok(p, '\0', &p);
-
-    p = found_str;
-
     /* The following are essentially all key/value pairs, and we treat
      * 'id' and 'conf' a bit special.  Key/value pairs may be in any order. */
     while (p) {
-- 
2.7.4


Re: [Qemu-devel] [PATCH RFC v3 for-2.9 04/11] rbd: Clean up after the previous commit
Posted by Max Reitz 8 years, 10 months ago
On 27.03.2017 15:26, Markus Armbruster wrote:
> This code in qemu_rbd_parse_filename()
> 
>     found_str = qemu_rbd_next_tok(p, '\0', &p);
>     p = found_str;
> 
> has no effect.  Drop it, and simplify qemu_rbd_next_tok().
> 
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> Reviewed-by: Eric Blake <eblake@redhat.com>
> ---
>  block/rbd.c | 24 +++++++++---------------
>  1 file changed, 9 insertions(+), 15 deletions(-)

Reviewed-by: Max Reitz <mreitz@redhat.com>

Re: [Qemu-devel] [PATCH RFC v3 for-2.9 04/11] rbd: Clean up after the previous commit
Posted by Jeff Cody 8 years, 10 months ago
On Mon, Mar 27, 2017 at 03:26:28PM +0200, Markus Armbruster wrote:
> This code in qemu_rbd_parse_filename()
> 
>     found_str = qemu_rbd_next_tok(p, '\0', &p);
>     p = found_str;
> 
> has no effect.  Drop it, and simplify qemu_rbd_next_tok().
> 
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> Reviewed-by: Eric Blake <eblake@redhat.com>

Reviewed-by: Jeff Cody <jcody@redhat.com>

> ---
>  block/rbd.c | 24 +++++++++---------------
>  1 file changed, 9 insertions(+), 15 deletions(-)
> 
> diff --git a/block/rbd.c b/block/rbd.c
> index 0fea348..182a5a3 100644
> --- a/block/rbd.c
> +++ b/block/rbd.c
> @@ -104,19 +104,17 @@ static char *qemu_rbd_next_tok(char *src, char delim, char **p)
>  
>      *p = NULL;
>  
> -    if (delim != '\0') {
> -        for (end = src; *end; ++end) {
> -            if (*end == delim) {
> -                break;
> -            }
> -            if (*end == '\\' && end[1] != '\0') {
> -                end++;
> -            }
> -        }
> +    for (end = src; *end; ++end) {
>          if (*end == delim) {
> -            *p = end + 1;
> -            *end = '\0';
> +            break;
>          }
> +        if (*end == '\\' && end[1] != '\0') {
> +            end++;
> +        }
> +    }
> +    if (*end == delim) {
> +        *p = end + 1;
> +        *end = '\0';
>      }
>      return src;
>  }
> @@ -177,10 +175,6 @@ static void qemu_rbd_parse_filename(const char *filename, QDict *options,
>          goto done;
>      }
>  
> -    found_str = qemu_rbd_next_tok(p, '\0', &p);
> -
> -    p = found_str;
> -
>      /* The following are essentially all key/value pairs, and we treat
>       * 'id' and 'conf' a bit special.  Key/value pairs may be in any order. */
>      while (p) {
> -- 
> 2.7.4
>