From patchwork Fri Feb 23 07:51:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Su Hang X-Patchwork-Id: 10237001 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4A6CA602DC for ; Fri, 23 Feb 2018 07:52:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 40CE9293F6 for ; Fri, 23 Feb 2018 07:52:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 350EA29451; Fri, 23 Feb 2018 07:52:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E6985293F6 for ; Fri, 23 Feb 2018 07:52:37 +0000 (UTC) Received: from localhost ([::1]:42859 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ep89k-0000xe-6Y for patchwork-qemu-devel@patchwork.kernel.org; Fri, 23 Feb 2018 02:52:36 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60338) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ep88a-0000Dd-VM for qemu-devel@nongnu.org; Fri, 23 Feb 2018 02:51:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ep88Z-0004TZ-2C for qemu-devel@nongnu.org; Fri, 23 Feb 2018 02:51:25 -0500 Received: from smtp20.cstnet.cn ([159.226.251.20]:44751 helo=cstnet.cn) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ep88Y-0004Rt-3K for qemu-devel@nongnu.org; Fri, 23 Feb 2018 02:51:22 -0500 Received: from localhost.localdomain (unknown [61.148.244.3]) by APP-10 (Coremail) with SMTP id tACowACXnPT2x49abWOZBA--.12620S3; Fri, 23 Feb 2018 15:51:19 +0800 (CST) From: Su Hang To: thuth@redhat.com, stefanha@redhat.com Date: Fri, 23 Feb 2018 15:51:18 +0800 Message-Id: <1519372278-20644-1-git-send-email-suhang16@mails.ucas.ac.cn> X-Mailer: git-send-email 2.7.4 X-CM-TRANSID: tACowACXnPT2x49abWOZBA--.12620S3 X-Coremail-Antispam: 1UD129KBjvJXoW3KFWrAw18tr18Kr18tF4ktFb_yoWkGF1xpr 4UG34rAryUtayrJF4Iyanxuw1Ykr42kr1Iya4fC3Z7urnxA3y5tw4SgF1Ygrn5tw4jgr43 Xr4FqF4ruF12qrUanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvab7Iv0xC_Kw4lb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I2 0VC2zVCF04k26cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rw A2F7IY1VAKz4vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Jr0_JF4l84ACjcxK6xII jxv20xvEc7CjxVAFwI0_Jr0_Gr1l84ACjcxK6I8E87Iv67AKxVW8Jr0_Cr1UM28EF7xvwV C2z280aVCY1x0267AKxVW8Jr0_Cr1UM2vYz4IE04k24VAvwVAKI4IrM2AIxVAIcxkEcVAq 07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r106r 15McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vI r41lc2xSY4AK67AK6r4xMxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI 8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AK xVWUXVWUAwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI 8IcVCY1x0267AKxVWUJVW8JwCI42IY6xAIw20EY4v20xvaj40_JFI_Gr1lIxAIcVC2z280 aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVWUJVW8JbIYCTnIWIevJa73UjIFyT uYvjxUgVbkDUUUU X-CM-SenderInfo: pvxkt0rjrwqzpdlo2hpxfd2hldfou0/ X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 159.226.251.20 Subject: [Qemu-devel] [PATCH v3 2/3] util/uri.c: only remove `return`'s brackets X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-by: Thomas Huth --- util/uri.c | 160 ++++++++++++++++++++++++++++++------------------------------- 1 file changed, 80 insertions(+), 80 deletions(-) diff --git a/util/uri.c b/util/uri.c index 81f7a6841077..278e876ab8b1 100644 --- a/util/uri.c +++ b/util/uri.c @@ -212,11 +212,11 @@ static int rfc3986_parse_scheme(URI *uri, const char **str) const char *cur; if (str == NULL) - return (-1); + return -1; cur = *str; if (!ISA_ALPHA(cur)) - return (2); + return 2; cur++; while (ISA_ALPHA(cur) || ISA_DIGIT(cur) || (*cur == '+') || (*cur == '-') || (*cur == '.')) @@ -226,7 +226,7 @@ static int rfc3986_parse_scheme(URI *uri, const char **str) uri->scheme = g_strndup(*str, cur - *str); } *str = cur; - return (0); + return 0; } /** @@ -249,7 +249,7 @@ static int rfc3986_parse_fragment(URI *uri, const char **str) const char *cur; if (str == NULL) - return (-1); + return -1; cur = *str; @@ -265,7 +265,7 @@ static int rfc3986_parse_fragment(URI *uri, const char **str) uri->fragment = uri_string_unescape(*str, cur - *str, NULL); } *str = cur; - return (0); + return 0; } /** @@ -284,7 +284,7 @@ static int rfc3986_parse_query(URI *uri, const char **str) const char *cur; if (str == NULL) - return (-1); + return -1; cur = *str; @@ -296,7 +296,7 @@ static int rfc3986_parse_query(URI *uri, const char **str) uri->query = g_strndup(*str, cur - *str); } *str = cur; - return (0); + return 0; } /** @@ -362,9 +362,9 @@ static int rfc3986_parse_user_info(URI *uri, const char **str) uri->user = uri_string_unescape(*str, cur - *str, NULL); } *str = cur; - return (0); + return 0; } - return (1); + return 1; } /** @@ -386,7 +386,7 @@ static int rfc3986_parse_dec_octet(const char **str) const char *cur = *str; if (!(ISA_DIGIT(cur))) - return (1); + return 1; if (!ISA_DIGIT(cur + 1)) cur++; else if ((*cur != '0') && (ISA_DIGIT(cur + 1)) && (!ISA_DIGIT(cur + 2))) @@ -400,9 +400,9 @@ static int rfc3986_parse_dec_octet(const char **str) (*(cur + 1) <= '5')) cur += 3; else - return (1); + return 1; *str = cur; - return (0); + return 0; } /** * rfc3986_parse_host: @@ -433,7 +433,7 @@ static int rfc3986_parse_host(URI *uri, const char **str) while ((*cur != ']') && (*cur != 0)) cur++; if (*cur != ']') - return (1); + return 1; cur++; goto found; } @@ -479,7 +479,7 @@ found: uri->server = NULL; } *str = cur; - return (0); + return 0; } /** @@ -510,15 +510,15 @@ static int rfc3986_parse_authority(URI *uri, const char **str) cur++; ret = rfc3986_parse_host(uri, &cur); if (ret != 0) - return (ret); + return ret; if (*cur == ':') { cur++; ret = rfc3986_parse_port(uri, &cur); if (ret != 0) - return (ret); + return ret; } *str = cur; - return (0); + return 0; } /** @@ -544,13 +544,13 @@ static int rfc3986_parse_segment(const char **str, char forbid, int empty) cur = *str; if (!ISA_PCHAR(cur)) { if (empty) - return (0); - return (1); + return 0; + return 1; } while (ISA_PCHAR(cur) && (*cur != forbid)) NEXT(cur); *str = cur; - return (0); + return 0; } /** @@ -576,7 +576,7 @@ static int rfc3986_parse_path_ab_empty(URI *uri, const char **str) cur++; ret = rfc3986_parse_segment(&cur, 0, 1); if (ret != 0) - return (ret); + return ret; } if (uri != NULL) { g_free(uri->path); @@ -590,7 +590,7 @@ static int rfc3986_parse_path_ab_empty(URI *uri, const char **str) } } *str = cur; - return (0); + return 0; } /** @@ -613,7 +613,7 @@ static int rfc3986_parse_path_absolute(URI *uri, const char **str) cur = *str; if (*cur != '/') - return (1); + return 1; cur++; ret = rfc3986_parse_segment(&cur, 0, 0); if (ret == 0) { @@ -621,7 +621,7 @@ static int rfc3986_parse_path_absolute(URI *uri, const char **str) cur++; ret = rfc3986_parse_segment(&cur, 0, 1); if (ret != 0) - return (ret); + return ret; } } if (uri != NULL) { @@ -636,7 +636,7 @@ static int rfc3986_parse_path_absolute(URI *uri, const char **str) } } *str = cur; - return (0); + return 0; } /** @@ -660,12 +660,12 @@ static int rfc3986_parse_path_rootless(URI *uri, const char **str) ret = rfc3986_parse_segment(&cur, 0, 0); if (ret != 0) - return (ret); + return ret; while (*cur == '/') { cur++; ret = rfc3986_parse_segment(&cur, 0, 1); if (ret != 0) - return (ret); + return ret; } if (uri != NULL) { g_free(uri->path); @@ -679,7 +679,7 @@ static int rfc3986_parse_path_rootless(URI *uri, const char **str) } } *str = cur; - return (0); + return 0; } /** @@ -703,12 +703,12 @@ static int rfc3986_parse_path_no_scheme(URI *uri, const char **str) ret = rfc3986_parse_segment(&cur, ':', 0); if (ret != 0) - return (ret); + return ret; while (*cur == '/') { cur++; ret = rfc3986_parse_segment(&cur, 0, 1); if (ret != 0) - return (ret); + return ret; } if (uri != NULL) { g_free(uri->path); @@ -722,7 +722,7 @@ static int rfc3986_parse_path_no_scheme(URI *uri, const char **str) } } *str = cur; - return (0); + return 0; } /** @@ -751,20 +751,20 @@ static int rfc3986_parse_hier_part(URI *uri, const char **str) cur += 2; ret = rfc3986_parse_authority(uri, &cur); if (ret != 0) - return (ret); + return ret; ret = rfc3986_parse_path_ab_empty(uri, &cur); if (ret != 0) - return (ret); + return ret; *str = cur; - return (0); + return 0; } else if (*cur == '/') { ret = rfc3986_parse_path_absolute(uri, &cur); if (ret != 0) - return (ret); + return ret; } else if (ISA_PCHAR(cur)) { ret = rfc3986_parse_path_rootless(uri, &cur); if (ret != 0) - return (ret); + return ret; } else { /* path-empty is effectively empty */ if (uri != NULL) { @@ -773,7 +773,7 @@ static int rfc3986_parse_hier_part(URI *uri, const char **str) } } *str = cur; - return (0); + return 0; } /** @@ -800,18 +800,18 @@ static int rfc3986_parse_relative_ref(URI *uri, const char *str) str += 2; ret = rfc3986_parse_authority(uri, &str); if (ret != 0) - return (ret); + return ret; ret = rfc3986_parse_path_ab_empty(uri, &str); if (ret != 0) - return (ret); + return ret; } else if (*str == '/') { ret = rfc3986_parse_path_absolute(uri, &str); if (ret != 0) - return (ret); + return ret; } else if (ISA_PCHAR(str)) { ret = rfc3986_parse_path_no_scheme(uri, &str); if (ret != 0) - return (ret); + return ret; } else { /* path-empty is effectively empty */ if (uri != NULL) { @@ -824,19 +824,19 @@ static int rfc3986_parse_relative_ref(URI *uri, const char *str) str++; ret = rfc3986_parse_query(uri, &str); if (ret != 0) - return (ret); + return ret; } if (*str == '#') { str++; ret = rfc3986_parse_fragment(uri, &str); if (ret != 0) - return (ret); + return ret; } if (*str != 0) { uri_clean(uri); - return (1); + return 1; } - return (0); + return 0; } /** @@ -857,31 +857,31 @@ static int rfc3986_parse(URI *uri, const char *str) ret = rfc3986_parse_scheme(uri, &str); if (ret != 0) - return (ret); + return ret; if (*str != ':') { - return (1); + return 1; } str++; ret = rfc3986_parse_hier_part(uri, &str); if (ret != 0) - return (ret); + return ret; if (*str == '?') { str++; ret = rfc3986_parse_query(uri, &str); if (ret != 0) - return (ret); + return ret; } if (*str == '#') { str++; ret = rfc3986_parse_fragment(uri, &str); if (ret != 0) - return (ret); + return ret; } if (*str != 0) { uri_clean(uri); - return (1); + return 1; } - return (0); + return 0; } /** @@ -901,7 +901,7 @@ static int rfc3986_parse_uri_reference(URI *uri, const char *str) int ret; if (str == NULL) - return (-1); + return -1; uri_clean(uri); /* @@ -914,10 +914,10 @@ static int rfc3986_parse_uri_reference(URI *uri, const char *str) ret = rfc3986_parse_relative_ref(uri, str); if (ret != 0) { uri_clean(uri); - return (ret); + return ret; } } - return (0); + return 0; } /** @@ -936,14 +936,14 @@ URI *uri_parse(const char *str) int ret; if (str == NULL) - return (NULL); + return NULL; uri = uri_new(); ret = rfc3986_parse_uri_reference(uri, str); if (ret) { uri_free(uri); - return (NULL); + return NULL; } - return (uri); + return uri; } /** @@ -960,7 +960,7 @@ URI *uri_parse(const char *str) */ int uri_parse_into(URI *uri, const char *str) { - return (rfc3986_parse_uri_reference(uri, str)); + return rfc3986_parse_uri_reference(uri, str); } /** @@ -980,7 +980,7 @@ URI *uri_parse_raw(const char *str, int raw) int ret; if (str == NULL) - return (NULL); + return NULL; uri = uri_new(); if (raw) { uri->cleanup |= 2; @@ -988,9 +988,9 @@ URI *uri_parse_raw(const char *str, int raw) ret = uri_parse_into(uri, str); if (ret) { uri_free(uri); - return (NULL); + return NULL; } - return (uri); + return uri; } /************************************************************************ @@ -1011,7 +1011,7 @@ URI *uri_new(void) URI *ret; ret = g_new0(URI, 1); - return (ret); + return ret; } /** @@ -1028,7 +1028,7 @@ static char *realloc2n(char *ret, int *max) tmp = *max * 2; temp = g_realloc(ret, (tmp + 1)); *max = tmp; - return (temp); + return temp; } /** @@ -1048,7 +1048,7 @@ char *uri_to_string(URI *uri) int max; if (uri == NULL) - return (NULL); + return NULL; max = 80; ret = g_malloc(max + 1); @@ -1249,7 +1249,7 @@ char *uri_to_string(URI *uri) ret = temp; } ret[len] = 0; - return (ret); + return ret; } /** @@ -1315,7 +1315,7 @@ static int normalize_uri_path(char *path) char *cur, *out; if (path == NULL) - return (-1); + return -1; /* Skip all initial "/" chars. We want to get to the beginning of the * first non-empty segment. @@ -1324,7 +1324,7 @@ static int normalize_uri_path(char *path) while (cur[0] == '/') ++cur; if (cur[0] == '\0') - return (0); + return 0; /* Keep everything we've seen so far. */ out = cur; @@ -1372,7 +1372,7 @@ done_cd: while (cur[0] == '/') ++cur; if (cur[0] == '\0') - return (0); + return 0; /* * Analyze each segment in sequence for cases (e) and (f). @@ -1485,15 +1485,15 @@ done_cd: } } - return (0); + 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); + return 1; + return 0; } /** @@ -1516,11 +1516,11 @@ char *uri_string_unescape(const char *str, int len, char *target) const char *in; if (str == NULL) - return (NULL); + return NULL; if (len <= 0) len = strlen(str); if (len < 0) - return (NULL); + return NULL; if (target == NULL) { ret = g_malloc(len + 1); @@ -1553,7 +1553,7 @@ char *uri_string_unescape(const char *str, int len, char *target) } } *out = 0; - return (ret); + return ret; } /** @@ -1574,12 +1574,12 @@ char *uri_string_escape(const char *str, const char *list) int len, out; if (str == NULL) - return (NULL); + return NULL; if (str[0] == 0) - return (g_strdup(str)); + return g_strdup(str); len = strlen(str); if (!(len > 0)) - return (NULL); + return NULL; len += 20; ret = g_malloc(len); @@ -1612,7 +1612,7 @@ char *uri_string_escape(const char *str, const char *list) } } ret[out] = 0; - return (ret); + return ret; } /************************************************************************ @@ -1851,7 +1851,7 @@ done: uri_free(bas); if (res != NULL) uri_free(res); - return (val); + return val; } /**