Skip to contentSkip to conversation

util/uri: Simplify the code, remove unused functions

PATCH Superseded Thomas Huth 5 participants 18 messages Jan 22, 2024 – Jan 23, 2024

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover util/uri: Simplify the code, remove unused functions

The URI function uri_string_unescape() has some overlap with functions from the glib, so we can simplify our code here quite a bit. While at it, I also noticed that there are many unused functions in here which we likely can drop nowadays (it's better to use the functions from glib anyway).

Thomas Huth (5):
util/uri: Remove the unused "target" argument from
uri_string_unescape()
util/uri: Simplify uri_string_unescape()
util/uri: Remove the uri_string_escape() function util/uri: Remove unused functions uri_resolve() and
uri_resolve_relative()
util/uri: Remove unused macros ISA_RESERVED() and ISA_GEN_DELIM()

 include/qemu/uri.h |   5 +-
 util/uri.c         | 843 +--------------------------------------------
 2 files changed, 16 insertions(+), 832 deletions(-)
Signature · 1 line
2.43.0
#1 lore raw

PATCH 1/5 util/uri: Remove the unused "target" argument from uri_string_unescape()

All callers pass NULL as target, so we can simplify the code by dropping this parameter.

---
 include/qemu/uri.h |  2 +-
 util/uri.c         | 32 ++++++++++++++------------------
 2 files changed, 15 insertions(+), 19 deletions(-)
include/qemu/uri.h +1 -1
index 1855b764f2..aa54b6f251 100644
@@ -79,7 +79,7 @@ URI *uri_parse_raw(const char *str, int raw);
 int uri_parse_into(URI *uri, const char *str);
 char *uri_to_string(URI *uri);
 char *uri_string_escape(const char *str, const char *list);
-char *uri_string_unescape(const char *str, int len, char *target);
+char *uri_string_unescape(const char *str, int len);
 void uri_free(URI *uri);
 
 /* Single web service query parameter 'name=value'. */
util/uri.c +14 -18
index dcb3305236..33b6c7214e 100644
@@ -267,7 +267,7 @@ static int rfc3986_parse_fragment(URI *uri, const char **str)
         if (uri->cleanup & 2) {
             uri->fragment = g_strndup(*str, cur - *str);
         } else {
-            uri->fragment = uri_string_unescape(*str, cur - *str, NULL);
+            uri->fragment = uri_string_unescape(*str, cur - *str);
         }
     }
     *str = cur;
@@ -368,7 +368,7 @@ static int rfc3986_parse_user_info(URI *uri, const char **str)
             if (uri->cleanup & 2) {
                 uri->user = g_strndup(*str, cur - *str);
             } else {
-                uri->user = uri_string_unescape(*str, cur - *str, NULL);
+                uri->user = uri_string_unescape(*str, cur - *str);
             }
         }
         *str = cur;
@@ -496,7 +496,7 @@ found:
             if (uri->cleanup & 2) {
                 uri->server = g_strndup(host, cur - host);
             } else {
-                uri->server = uri_string_unescape(host, cur - host, NULL);
+                uri->server = uri_string_unescape(host, cur - host);
             }
         } else {
             uri->server = NULL;
@@ -614,7 +614,7 @@ static int rfc3986_parse_path_ab_empty(URI *uri, const char **str)
             if (uri->cleanup & 2) {
                 uri->path = g_strndup(*str, cur - *str);
             } else {
-                uri->path = uri_string_unescape(*str, cur - *str, NULL);
+                uri->path = uri_string_unescape(*str, cur - *str);
             }
         } else {
             uri->path = NULL;
@@ -663,7 +663,7 @@ static int rfc3986_parse_path_absolute(URI *uri, const char **str)
             if (uri->cleanup & 2) {
                 uri->path = g_strndup(*str, cur - *str);
             } else {
-                uri->path = uri_string_unescape(*str, cur - *str, NULL);
+                uri->path = uri_string_unescape(*str, cur - *str);
             }
         } else {
             uri->path = NULL;
@@ -709,7 +709,7 @@ static int rfc3986_parse_path_rootless(URI *uri, const char **str)
             if (uri->cleanup & 2) {
                 uri->path = g_strndup(*str, cur - *str);
             } else {
-                uri->path = uri_string_unescape(*str, cur - *str, NULL);
+                uri->path = uri_string_unescape(*str, cur - *str);
             }
         } else {
             uri->path = NULL;
@@ -755,7 +755,7 @@ static int rfc3986_parse_path_no_scheme(URI *uri, const char **str)
             if (uri->cleanup & 2) {
                 uri->path = g_strndup(*str, cur - *str);
             } else {
-                uri->path = uri_string_unescape(*str, cur - *str, NULL);
+                uri->path = uri_string_unescape(*str, cur - *str);
             }
         } else {
             uri->path = NULL;
@@ -1574,7 +1574,6 @@ static int is_hex(char c)
  * uri_string_unescape:
  * @str:  the string to unescape
  * @len:   the length in bytes to unescape (or <= 0 to indicate full string)
- * @target:  optional destination buffer
  *
  * Unescaping routine, but does not check that the string is an URI. The
  * output is a direct unsigned char translation of %XX values (no encoding)
@@ -1584,7 +1583,7 @@ static int is_hex(char c)
  * Returns a copy of the string, but unescaped, will return NULL only in case
  * of error
  */
-char *uri_string_unescape(const char *str, int len, char *target)
+char *uri_string_unescape(const char *str, int len)
 {
     char *ret, *out;
     const char *in;
@@ -1599,11 +1598,8 @@ char *uri_string_unescape(const char *str, int len, char *target)
         return NULL;
     }
 
-    if (target == NULL) {
-        ret = g_malloc(len + 1);
-    } else {
-        ret = target;
-    }
+    ret = g_malloc(len + 1);
+
     in = str;
     out = ret;
     while (len > 0) {
@@ -2274,14 +2270,14 @@ struct QueryParams *query_params_parse(const char *query)
          * and consistent with CGI.pm we assume value is "".
          */
         else if (!eq) {
-            name = uri_string_unescape(query, end - query, NULL);
+            name = uri_string_unescape(query, end - query);
             value = NULL;
         }
         /* Or if we have "name=" here (works around annoying
          * problem when calling uri_string_unescape with len = 0).
          */
         else if (eq + 1 == end) {
-            name = uri_string_unescape(query, eq - query, NULL);
+            name = uri_string_unescape(query, eq - query);
             value = g_new0(char, 1);
         }
         /* If the '=' character is at the beginning then we have
@@ -2293,8 +2289,8 @@ struct QueryParams *query_params_parse(const char *query)
 
         /* Otherwise it's "name=value". */
         else {
-            name = uri_string_unescape(query, eq - query, NULL);
-            value = uri_string_unescape(eq + 1, end - (eq + 1), NULL);
+            name = uri_string_unescape(query, eq - query);
+            value = uri_string_unescape(eq + 1, end - (eq + 1));
         }
 
         /* Append to the parameter set. */
Signature · 1 line
2.43.0
Reviewed-by Stefan Weil on v1 1/5
#2 lore raw

Re: [PATCH 1/5] util/uri: Remove the unused "target" argument from uri_string_unescape()

Am 22.01.24 um 20:17 schrieb Thomas Huth:

Quoted 8 lines

All callers pass NULL as target, so we can simplify the code by dropping this parameter.

---
  include/qemu/uri.h |  2 +-
  util/uri.c         | 32 ++++++++++++++------------------
  2 files changed, 15 insertions(+), 19 deletions(-)
Reviewed-by on v1 1/5
#3 lore raw

Re: [PATCH 1/5] util/uri: Remove the unused "target" argument from uri_string_unescape()

In reply to Thomas Huth
Quoted 8 lines · Thomas Huth

All callers pass NULL as target, so we can simplify the code by dropping this parameter.

---
  include/qemu/uri.h |  2 +-
  util/uri.c         | 32 ++++++++++++++------------------
  2 files changed, 15 insertions(+), 19 deletions(-)
#4 lore raw

PATCH 2/5 util/uri: Simplify uri_string_unescape()

In reply to Thomas Huth

uri_string_unescape() basically does the same as the glib function g_uri_unescape_string(), with just an additional length parameter. So we can simplify this function a lot by limiting the length with g_strndup() first and then by calling g_uri_unescape_string() instead of walking through the string manually.

---
 util/uri.c | 49 +++----------------------------------------------
 1 file changed, 3 insertions(+), 46 deletions(-)
util/uri.c +3 -46
index 33b6c7214e..2a75f535ba 100644
@@ -1561,15 +1561,6 @@ done_cd:
     return 0;
 }
 
-static int is_hex(char c)
-{
-    if (((c >= '0') && (c <= '9')) || ((c >= 'a') && (c <= 'f')) ||
-        ((c >= 'A') && (c <= 'F'))) {
-        return 1;
-    }
-    return 0;
-}
-
 /**
  * uri_string_unescape:
  * @str:  the string to unescape
@@ -1585,8 +1576,7 @@ static int is_hex(char c)
  */
 char *uri_string_unescape(const char *str, int len)
 {
-    char *ret, *out;
-    const char *in;
+    g_autofree char *lstr = NULL;
 
     if (str == NULL) {
         return NULL;
@@ -1594,42 +1584,9 @@ char *uri_string_unescape(const char *str, int len)
     if (len <= 0) {
         len = strlen(str);
     }
-    if (len < 0) {
-        return NULL;
-    }
-
-    ret = g_malloc(len + 1);
+    lstr = g_strndup(str, len);
 
-    in = str;
-    out = ret;
-    while (len > 0) {
-        if ((len > 2) && (*in == '%') && (is_hex(in[1])) && (is_hex(in[2]))) {
-            in++;
-            if ((*in >= '0') && (*in <= '9')) {
-                *out = (*in - '0');
-            } else if ((*in >= 'a') && (*in <= 'f')) {
-                *out = (*in - 'a') + 10;
-            } else if ((*in >= 'A') && (*in <= 'F')) {
-                *out = (*in - 'A') + 10;
-            }
-            in++;
-            if ((*in >= '0') && (*in <= '9')) {
-                *out = *out * 16 + (*in - '0');
-            } else if ((*in >= 'a') && (*in <= 'f')) {
-                *out = *out * 16 + (*in - 'a') + 10;
-            } else if ((*in >= 'A') && (*in <= 'F')) {
-                *out = *out * 16 + (*in - 'A') + 10;
-            }
-            in++;
-            len -= 3;
-            out++;
-        } else {
-            *out++ = *in++;
-            len--;
-        }
-    }
-    *out = 0;
-    return ret;
+    return g_uri_unescape_string(lstr, NULL);
 }
 
 /**
Signature · 1 line
2.43.0
Reviewed-by Stefan Weil on v1 2/5
#5 lore raw

Re: [PATCH 2/5] util/uri: Simplify uri_string_unescape()

Am 22.01.24 um 20:17 schrieb Thomas Huth:

Quoted 7 lines

uri_string_unescape() basically does the same as the glib function g_uri_unescape_string(), with just an additional length parameter. So we can simplify this function a lot by limiting the length with g_strndup() first and then by calling g_uri_unescape_string() instead of walking through the string manually.

Can my e-mail address be replaced by another one ([email protected])?

Quoted 26 lines
---
  util/uri.c | 49 +++----------------------------------------------
  1 file changed, 3 insertions(+), 46 deletions(-)
util/uri.c +0 -9
index 33b6c7214e..2a75f535ba 100644
@@ -1561,15 +1561,6 @@ done_cd:
      return 0;
  }
 
-static int is_hex(char c)
-{
-    if (((c >= '0') && (c <= '9')) || ((c >= 'a') && (c <= 'f')) ||
-        ((c >= 'A') && (c <= 'F'))) {
-        return 1;
-    }
-    return 0;
-}
-
  /**
   * uri_string_unescape:
   * @str:  the string to unescape

util/uri.c static int is_hex(char c) · line 1579

Quoted 6 lines
util/uri.c +1 -2
@@ -1585,8 +1576,7 @@ static int is_hex(char c)
   */
  char *uri_string_unescape(const char *str, int len)
  {
-    char *ret, *out;
-    const char *in;
+    g_autofree char *lstr = NULL;

Is it necessary to assign NULL? It does not look so.

Quoted 38 lines
util/uri.c +1 -29
      if (str == NULL) {
          return NULL;
@@ -1594,42 +1584,9 @@ char *uri_string_unescape(const char *str, int len)
      if (len <= 0) {
          len = strlen(str);
      }
-    if (len < 0) {
-        return NULL;
-    }
-
-    ret = g_malloc(len + 1);
+    lstr = g_strndup(str, len);
 
-    in = str;
-    out = ret;
-    while (len > 0) {
-        if ((len > 2) && (*in == '%') && (is_hex(in[1])) && (is_hex(in[2]))) {
-            in++;
-            if ((*in >= '0') && (*in <= '9')) {
-                *out = (*in - '0');
-            } else if ((*in >= 'a') && (*in <= 'f')) {
-                *out = (*in - 'a') + 10;
-            } else if ((*in >= 'A') && (*in <= 'F')) {
-                *out = (*in - 'A') + 10;
-            }
-            in++;
-            if ((*in >= '0') && (*in <= '9')) {
-                *out = *out * 16 + (*in - '0');
-            } else if ((*in >= 'a') && (*in <= 'f')) {
-                *out = *out * 16 + (*in - 'a') + 10;
-            } else if ((*in >= 'A') && (*in <= 'F')) {
-                *out = *out * 16 + (*in - 'A') + 10;
-            }
-            in++;
-            len -= 3;
-            out++;
-        } else {

util/uri.c char *uri_string_unescape(const char *str, int len) · line 1592

Quoted 10 lines
util/uri.c +1 -6
-            *out++ = *in++;
-            len--;
-        }
-    }
-    *out = 0;
-    return ret;
+    return g_uri_unescape_string(lstr, NULL);
  }
 
  /**

Thank you.

#6 lore raw

Re: [PATCH 2/5] util/uri: Simplify uri_string_unescape()

Quoted 11 lines · Stefan Weil

Am 22.01.24 um 20:17 schrieb Thomas Huth:

Quoted 7 lines

uri_string_unescape() basically does the same as the glib function g_uri_unescape_string(), with just an additional length parameter. So we can simplify this function a lot by limiting the length with g_strndup() first and then by calling g_uri_unescape_string() instead of walking through the string manually.

Can my e-mail address be replaced by another one ([email protected])?

Sure! ... not sure where I copy-n-pasted the other one from ... sorry for that.

Quoted 10 lines

util/uri.c static int is_hex(char c) · line 1579

Quoted 7 lines
util/uri.c +1 -2
@@ -1585,8 +1576,7 @@ static int is_hex(char c)
   */
  char *uri_string_unescape(const char *str, int len)
  {
-    char *ret, *out;
-    const char *in;
+    g_autofree char *lstr = NULL;

Is it necessary to assign NULL? It does not look so.

Yes, it's necessary for the early "return NULL" statement below. Since it's an g_autofree variable, it must either be set to a valid allocated buffer or NULL before returning.

Quoted 47 lines
Quoted 47 lines
util/uri.c +2 -35
      if (str == NULL) {
          return NULL;
@@ -1594,42 +1584,9 @@ char *uri_string_unescape(const char *str, int len)
      if (len <= 0) {
          len = strlen(str);
      }
-    if (len < 0) {
-        return NULL;
-    }
-
-    ret = g_malloc(len + 1);
+    lstr = g_strndup(str, len);
 
-    in = str;
-    out = ret;
-    while (len > 0) {
-        if ((len > 2) && (*in == '%') && (is_hex(in[1])) && (is_hex(in[2]))) {
-            in++;
-            if ((*in >= '0') && (*in <= '9')) {
-                *out = (*in - '0');
-            } else if ((*in >= 'a') && (*in <= 'f')) {
-                *out = (*in - 'a') + 10;
-            } else if ((*in >= 'A') && (*in <= 'F')) {
-                *out = (*in - 'A') + 10;
-            }
-            in++;
-            if ((*in >= '0') && (*in <= '9')) {
-                *out = *out * 16 + (*in - '0');
-            } else if ((*in >= 'a') && (*in <= 'f')) {
-                *out = *out * 16 + (*in - 'a') + 10;
-            } else if ((*in >= 'A') && (*in <= 'F')) {
-                *out = *out * 16 + (*in - 'A') + 10;
-            }
-            in++;
-            len -= 3;
-            out++;
-        } else {
-            *out++ = *in++;
-            len--;
-        }
-    }
-    *out = 0;
-    return ret;
+    return g_uri_unescape_string(lstr, NULL);
  }
 
Quoted 6 lines

Review char *uri_string_unescape(const char *str, int len) · line 1592

Quoted 1 line
(quoted diff) +0 -0
  /**

Thank you.

Thanks!

Thomas

#7 lore raw

Re: [PATCH 2/5] util/uri: Simplify uri_string_unescape()

In reply to Thomas Huth

Il lun 22 gen 2024, 20:18 Thomas Huth <[email protected]> ha scritto:

Quoted 3 lines

uri_string_unescape() basically does the same as the glib function g_uri_unescape_string(), with just an additional length parameter.

You can replace it altogether with g_uri_unescape_segment.

Paolo

So we can simplify this function a lot by limiting the length with

Quoted 89 lines

g_strndup() first and then by calling g_uri_unescape_string() instead of walking through the string manually.

---
 util/uri.c | 49 +++----------------------------------------------
 1 file changed, 3 insertions(+), 46 deletions(-)
util/uri.c +3 -46
index 33b6c7214e..2a75f535ba 100644
@@ -1561,15 +1561,6 @@ done_cd:
     return 0;
 }
 
-static int is_hex(char c)
-{
-    if (((c >= '0') && (c <= '9')) || ((c >= 'a') && (c <= 'f')) ||
-        ((c >= 'A') && (c <= 'F'))) {
-        return 1;
-    }
-    return 0;
-}
-
 /**
  * uri_string_unescape:
  * @str:  the string to unescape
@@ -1585,8 +1576,7 @@ static int is_hex(char c)
  */
 char *uri_string_unescape(const char *str, int len)
 {
-    char *ret, *out;
-    const char *in;
+    g_autofree char *lstr = NULL;
 
     if (str == NULL) {
         return NULL;
@@ -1594,42 +1584,9 @@ char *uri_string_unescape(const char *str, int len)
     if (len <= 0) {
         len = strlen(str);
     }
-    if (len < 0) {
-        return NULL;
-    }
-
-    ret = g_malloc(len + 1);
+    lstr = g_strndup(str, len);
 
-    in = str;
-    out = ret;
-    while (len > 0) {
-        if ((len > 2) && (*in == '%') && (is_hex(in[1])) &&
 (is_hex(in[2]))) {
-            in++;
-            if ((*in >= '0') && (*in <= '9')) {
-                *out = (*in - '0');
-            } else if ((*in >= 'a') && (*in <= 'f')) {
-                *out = (*in - 'a') + 10;
-            } else if ((*in >= 'A') && (*in <= 'F')) {
-                *out = (*in - 'A') + 10;
-            }
-            in++;
-            if ((*in >= '0') && (*in <= '9')) {
-                *out = *out * 16 + (*in - '0');
-            } else if ((*in >= 'a') && (*in <= 'f')) {
-                *out = *out * 16 + (*in - 'a') + 10;
-            } else if ((*in >= 'A') && (*in <= 'F')) {
-                *out = *out * 16 + (*in - 'A') + 10;
-            }
-            in++;
-            len -= 3;
-            out++;
-        } else {
-            *out++ = *in++;
-            len--;
-        }
-    }
-    *out = 0;
-    return ret;
+    return g_uri_unescape_string(lstr, NULL);
 }
 

/**
--
2.43.0

#8 lore raw

Re: [PATCH 2/5] util/uri: Simplify uri_string_unescape()

Quoted 9 lines · Paolo Bonzini

Il lun 22 gen 2024, 20:18 Thomas Huth <[email protected] <mailto:[email protected]>> ha scritto:

uri_string_unescape() basically does the same as the glib function g_uri_unescape_string(), with just an additional length parameter.

You can replace it altogether with g_uri_unescape_segment.

Oh, nice, I indeed missed that while looking at the glib docs! Thanks, I'll give it a try...

Thomas

#9 lore raw

PATCH 3/5 util/uri: Remove the uri_string_escape() function

In reply to Thomas Huth

It is not used in QEMU - and if somebody needs this functionality, they can simply use g_uri_escape_string() from the glib instead.

---
 include/qemu/uri.h |  1 -
 util/uri.c         | 64 ----------------------------------------------
 2 files changed, 65 deletions(-)
include/qemu/uri.h +0 -1
index aa54b6f251..c1734d28c3 100644
@@ -78,7 +78,6 @@ URI *uri_parse(const char *str);
 URI *uri_parse_raw(const char *str, int raw);
 int uri_parse_into(URI *uri, const char *str);
 char *uri_to_string(URI *uri);
-char *uri_string_escape(const char *str, const char *list);
 char *uri_string_unescape(const char *str, int len);
 void uri_free(URI *uri);
 
util/uri.c +0 -64

70 lines not on this page · raw message

Signature · 1 line
2.43.0
Reviewed-by Stefan Weil on v1 3/5
#10 lore raw

Re: [PATCH 3/5] util/uri: Remove the uri_string_escape() function

Am 22.01.24 um 20:17 schrieb Thomas Huth:

Quoted 8 lines

It is not used in QEMU - and if somebody needs this functionality, they can simply use g_uri_escape_string() from the glib instead.

---
  include/qemu/uri.h |  1 -
  util/uri.c         | 64 ----------------------------------------------
  2 files changed, 65 deletions(-)

The removed function is used in util/uri.c, so this patch breaks the compilation.

That can be fixed by applying patch 4 before this one.

With that re-ordering you may add my signature:

#11 lore raw

Re: [PATCH 3/5] util/uri: Remove the uri_string_escape() function

Quoted 12 lines · Stefan Weil

Am 22.01.24 um 20:17 schrieb Thomas Huth:

Quoted 8 lines

It is not used in QEMU - and if somebody needs this functionality, they can simply use g_uri_escape_string() from the glib instead.

---
  include/qemu/uri.h |  1 -
  util/uri.c         | 64 ----------------------------------------------

  2 files changed, 65 deletions(-)
Quoted 7 lines

The removed function is used in util/uri.c, so this patch breaks the compilation.

That can be fixed by applying patch 4 before this one.

With that re-ordering you may add my signature:

D'oh, I originally developed the patches the other way round indeed, but then thought it would be nicer for review this way and swapped the order without checking :-( ... I'll swap it back again.

Thanks!

Thomas

#12 lore raw

PATCH 4/5 util/uri: Remove unused functions uri_resolve() and uri_resolve_relative()

In reply to Thomas Huth

These rather complex functions have never been used since they've been introduced in 2012, so looks like they are not really useful for QEMU. And since the static normalize_uri_path() function is also only used by uri_resolve(), we can remove that function now, too.

---
 include/qemu/uri.h |   2 -
 util/uri.c         | 689 ---------------------------------------------
 2 files changed, 691 deletions(-)
include/qemu/uri.h +0 -2
index c1734d28c3..93538b7578 100644
@@ -72,8 +72,6 @@ typedef struct URI {
 } URI;
 
 URI *uri_new(void);
-char *uri_resolve(const char *URI, const char *base);
-char *uri_resolve_relative(const char *URI, const char *base);
 URI *uri_parse(const char *str);
 URI *uri_parse_raw(const char *str, int raw);
 int uri_parse_into(URI *uri, const char *str);
util/uri.c +0 -689

701 lines not on this page · raw message

Signature · 1 line
2.43.0
Reviewed-by Stefan Weil on v1 4/5
#13 lore raw

Re: [PATCH 4/5] util/uri: Remove unused functions uri_resolve() and uri_resolve_relative()

Am 22.01.24 um 20:17 schrieb Thomas Huth:

Quoted 11 lines

These rather complex functions have never been used since they've been introduced in 2012, so looks like they are not really useful for QEMU. And since the static normalize_uri_path() function is also only used by uri_resolve(), we can remove that function now, too.

---
  include/qemu/uri.h |   2 -
  util/uri.c         | 689 ---------------------------------------------
  2 files changed, 691 deletions(-)

This patch should be applied before patch 3 (so switch the order of the patches 3 and 4). With this change:

#14 lore raw

PATCH 5/5 util/uri: Remove unused macros ISA_RESERVED() and ISA_GEN_DELIM()

In reply to Thomas Huth

They are not used anywhere, so there's no need to keep them around.

---
 util/uri.c | 13 -------------
 1 file changed, 13 deletions(-)
util/uri.c +0 -13
index 5f5ca79792..2deab91da3 100644
@@ -163,19 +163,6 @@ static void uri_clean(URI *uri);
      ((*(p) == '+')) || ((*(p) == ',')) || ((*(p) == ';')) ||                  \
      ((*(p) == '=')) || ((*(p) == '\'')))
 
-/*
- *    gen-delims    = ":" / "/" / "?" / "#" / "[" / "]" / "@"
- */
-#define ISA_GEN_DELIM(p)                                                       \
-    (((*(p) == ':')) || ((*(p) == '/')) || ((*(p) == '?')) ||                  \
-     ((*(p) == '#')) || ((*(p) == '[')) || ((*(p) == ']')) ||                  \
-     ((*(p) == '@')))
-
-/*
- *    reserved      = gen-delims / sub-delims
- */
-#define ISA_RESERVED(p) (ISA_GEN_DELIM(p) || (ISA_SUB_DELIM(p)))
-
 /*
  *    unreserved    = ALPHA / DIGIT / "-" / "." / "_" / "~"
  */
Signature · 1 line
2.43.0
Reviewed-by Stefan Weil on v1 5/5
#15 lore raw

Re: [PATCH 5/5] util/uri: Remove unused macros ISA_RESERVED() and ISA_GEN_DELIM()

Am 22.01.24 um 20:17 schrieb Thomas Huth:

Quoted 7 lines

They are not used anywhere, so there's no need to keep them around.

---
  util/uri.c | 13 -------------
  1 file changed, 13 deletions(-)
Reviewed-by on v1 5/5
#16 lore raw

Re: [PATCH 5/5] util/uri: Remove unused macros ISA_RESERVED() and ISA_GEN_DELIM()

In reply to Thomas Huth
Quoted 6 lines · Thomas Huth

They are not used anywhere, so there's no need to keep them around.

---
  util/uri.c | 13 -------------
  1 file changed, 13 deletions(-)

(could be reordered as patch 1 to clarify it is not
an effect of the uri_string_foo() cleanups)

Reviewed-by on the v1 series
#17 lore raw
In reply to Thomas Huth
Quoted 15 lines · Thomas Huth

The URI function uri_string_unescape() has some overlap with functions from the glib, so we can simplify our code here quite a bit. While at it, I also noticed that there are many unused functions in here which we likely can drop nowadays (it's better to use the functions from glib anyway).

Thomas Huth (5):
util/uri: Remove the unused "target" argument from
uri_string_unescape()
util/uri: Simplify uri_string_unescape()
util/uri: Remove the uri_string_escape() function util/uri: Remove unused functions uri_resolve() and
uri_resolve_relative()
util/uri: Remove unused macros ISA_RESERVED() and ISA_GEN_DELIM()

Quoted 3 lines
 include/qemu/uri.h |   5 +-
 util/uri.c         | 843 +--------------------------------------------
 2 files changed, 16 insertions(+), 832 deletions(-)

With regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|