util/uri: Simplify the code, remove unused functions
v2 cover util/uri: Simplify the code, remove unused functions
The URI function uri_string_unescape() is pretty much the same as the function g_uri_unescape_segment() from the glib, so we can simplify our code here quite a bit.
While at it, I also noticed that there are many other unused functions in here which we likely can drop, too.
v2:
- Replace uri_string_unescape() with g_uri_unescape_segment(), so we can remove uri_string_unescape() completely now
Thomas Huth (4):
util/uri: Remove uri_string_unescape()
util/uri: Remove unused functions uri_resolve() and
uri_resolve_relative()
util/uri: Remove the uri_string_escape() function util/uri: Remove unused macros ISA_RESERVED() and ISA_GEN_DELIM()
include/qemu/uri.h | 4 - util/uri.c | 869 +-------------------------------------------- 2 files changed, 11 insertions(+), 862 deletions(-)
Signature · 1 line
2.43.0
PATCH v2 1/4 util/uri: Remove uri_string_unescape()
uri_string_unescape() basically does the same as the glib function g_uri_unescape_segment(). So we can get rid of our implementation completely by simply using the glib function instead.
--- include/qemu/uri.h | 1 - util/uri.c | 97 ++++++---------------------------------------- 2 files changed, 11 insertions(+), 87 deletions(-)
include/qemu/uri.h +0 -1
@@ -79,7 +79,6 @@ 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);void uri_free (URI *uri);/* Single web service query parameter 'name=value'. */
util/uri.c +11 -86
163 lines not on this page · raw message
Signature · 1 line
2.43.0
Re: [PATCH v2 1/4] util/uri: Remove uri_string_unescape()
Am 23.01.24 um 19:22 schrieb Thomas Huth:
Quoted 4 lines
uri_string_unescape()basically does the same as the glib functiong_uri_unescape_segment(). So we can get rid of our implementation completely by simply using the glib function instead.
Quoted 8 lines
Signed-off-by Thomas Huth <[email protected]>--- include/qemu/uri.h | 1 - util/uri.c | 97 ++++++---------------------------------------- 2 files changed, 11 insertions(+), 87 deletions(-)
Thank you, Thomas and Paolo.
PATCH v2 2/4 util/uri: Remove unused functions uri_resolve() and uri_resolve_relative()
In reply to Thomas HuthThese 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
@@ -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
PATCH v2 3/4 util/uri: Remove the uri_string_escape() function
In reply to Thomas HuthNow that uri_resolve_relative() has been removed, this function is not used in QEMU anymore - 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 | 70 ---------------------------------------------- 2 files changed, 71 deletions(-)
include/qemu/uri.h +0 -1
@@ -76,7 +76,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);void uri_free (URI *uri);/* Single web service query parameter 'name=value'. */
util/uri.c +0 -70
76 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH v2 4/4 util/uri: Remove unused macros ISA_RESERVED() and ISA_GEN_DELIM()
In reply to Thomas HuthThey are not used anywhere, so there's no need to keep them around.
Message-ID: <[email protected]>
--- util/uri.c | 13 ------------- 1 file changed, 13 deletions(-)
util/uri.c +0 -13
@@ -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
Quoted 6 lines · Thomas Huth
Thomas Huth (4):
util/uri: Removeuri_string_unescape()
util/uri: Remove unused functionsuri_resolve()and
uri_resolve_relative()
util/uri: Remove theuri_string_escape()function util/uri: Remove unused macrosISA_RESERVED()andISA_GEN_DELIM()
r~