aboutsummaryrefslogtreecommitdiff
path: root/util/uri.c
AgeCommit message (Collapse)AuthorFilesLines
2018-06-29cutils: Provide strchrnulKeno Fischer1-4/+2
strchrnul is a GNU extension and thus unavailable on a number of targets. In the review for a commit removing strchrnul from 9p, I was asked to create a qemu_strchrnul helper to factor out this functionality. Do so, and use it in a number of other places in the code base that inlined the replacement pattern in a place where strchrnul could be used. Signed-off-by: Keno Fischer <keno@juliacomputing.com> Acked-by: Greg Kurz <groug@kaod.org> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Greg Kurz <groug@kaod.org>
2018-05-20Remove unnecessary variables for function return valueLaurent Vivier1-4/+1
Re-run Coccinelle script scripts/coccinelle/return_directly.cocci Signed-off-by: Laurent Vivier <lvivier@redhat.com> ppc part Acked-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2018-03-05util/uri.c: wrap single statement blocks with braces {}Su Hang1-169/+294
For this patch, using curly braces to wrap `if` `while` `else` statements, which only hold single statement. For example: ''' if (cond) statement; ''' to ''' if (cond) { statement; } ''' And using tricks that compare the disassemblies before and after code changes, to make sure code logic isn't changed: ''' git checkout master make util/uri.o strip util/uri.o objdump -Drx util/uri.o > /tmp/uri-master.txt git checkout cleanupbranch make util/uri.o strip util/uri.o objdump -Drx util/uri.o > /tmp/uri-cleanup.txt Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2018-03-05util/uri.c: remove brackets that wrap `return` statement's content.Su Hang1-80/+80
only remove brackets that wrap `return` statements' content. use `perl -pi -e "s/return \((.*?)\);/return \1;/g" util/uri.c` to remove pattern like this: "return (1);" Signed-off-by: Su Hang <suhang16@mails.ucas.ac.cn> Reviewed-by: Thomas Huth <thuth@redhat.com> Message-id: 1519533358-13759-3-git-send-email-suhang16@mails.ucas.ac.cn Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2018-03-05util/uri.c: Coding style check, Only whitespace involvedSu Hang1-733/+735
Using `clang-format -i util/uri.c` first, then change back few code manually, to make sure only whitespace involved. Signed-off-by: Su Hang <suhang16@mails.ucas.ac.cn> Reviewed-by: Thomas Huth <thuth@redhat.com> Message-id: 1519533358-13759-2-git-send-email-suhang16@mails.ucas.ac.cn Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2017-01-24Fix documentation and some comments (article, grammar)Stefan Weil1-2/+2
Signed-off-by: Stefan Weil <sw@weilnetz.de> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2016-06-07all: Remove unnecessary glib.h includesPeter Maydell1-1/+0
Remove glib.h includes, as it is provided by osdep.h. This commit was created with scripts/clean-includes. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Eric Blake <eblake@redhat.com> Tested-by: Eric Blake <eblake@redhat.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2016-02-04util: Clean up includesPeter Maydell1-2/+1
Clean up includes so that osdep.h is included first and headers which it implies are not included manually. This commit was created with scripts/clean-includes. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Message-id: 1454089805-5470-6-git-send-email-peter.maydell@linaro.org
2015-03-18util/uri: Add overflow check to rfc3986_parse_portMax Reitz1-10/+14
And while at it, replace tabs by eight spaces in this function. Signed-off-by: Max Reitz <mreitz@redhat.com> Message-Id: <1424887718-10800-2-git-send-email-mreitz@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2015-02-10util/uri: URI member path can be null, compare more carfullyMarkus Armbruster1-1/+2
uri_resolve_relative() calls strcmp(bas->path, ref->path). However, either argument could be null! Evidence: the code checks for null after the comparison. Spotted by Coverity. I suspect this was screwed up when we stole the code from libxml2. There the conditional reads xmlStrEqual((xmlChar *)bas->path, (xmlChar *)ref->path) with int xmlStrEqual(const xmlChar *str1, const xmlChar *str2) { if (str1 == str2) return(1); if (str1 == NULL) return(0); if (str2 == NULL) return(0); do { if (*str1++ != *str2) return(0); } while (*str2++); return(1); } Fix by replicating libxml2's logic faithfully. Cc: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2015-02-10util/uri: realloc2n() can't fail, drop dead error handlingMarkus Armbruster1-22/+0
Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2015-02-10util/uri: uri_new() can't fail, drop dead error handlingMarkus Armbruster1-25/+11
Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2014-12-10util: Fuse g_malloc(); memset() into g_new0()Markus Armbruster1-2/+1
Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Fam Zheng <famz@redhat.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2014-12-10util: Drop superfluous conditionals around g_free()Markus Armbruster1-26/+22
Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Fam Zheng <famz@redhat.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2014-12-10Drop superfluous conditionals around g_strdup()Markus Armbruster1-26/+17
Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Fam Zheng <famz@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2013-05-12clean unnecessary code: don't check g_strdup arg for NULLDong Xu Wang1-1/+1
Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2013-01-12build: move libqemuutil.a components to util/Paolo Bonzini1-0/+2249
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>