From nobody Thu Dec 18 13:37:51 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1520242986688811.2937428107971; Mon, 5 Mar 2018 01:43:06 -0800 (PST) Received: from localhost ([::1]:48159 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1esme4-0007RW-Vc for importer@patchew.org; Mon, 05 Mar 2018 04:43:01 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49050) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1esmbc-0005di-9c for qemu-devel@nongnu.org; Mon, 05 Mar 2018 04:40:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1esmba-00065b-Hu for qemu-devel@nongnu.org; Mon, 05 Mar 2018 04:40:28 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:33770 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1esmbV-0005zb-Cv; Mon, 05 Mar 2018 04:40:21 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EC780402314E; Mon, 5 Mar 2018 09:40:20 +0000 (UTC) Received: from localhost (ovpn-116-254.ams2.redhat.com [10.36.116.254]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2C2BFAFD58; Mon, 5 Mar 2018 09:40:18 +0000 (UTC) From: Stefan Hajnoczi To: Date: Mon, 5 Mar 2018 09:40:02 +0000 Message-Id: <20180305094006.21446-3-stefanha@redhat.com> In-Reply-To: <20180305094006.21446-1-stefanha@redhat.com> References: <20180305094006.21446-1-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Mon, 05 Mar 2018 09:40:21 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Mon, 05 Mar 2018 09:40:21 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'stefanha@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 2/6] util/uri.c: remove brackets that wrap `return` statement's content. 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: Peter Maydell , Su Hang , Stefan Hajnoczi , qemu-block@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Su Hang 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 Message-id: 1519533358-13759-3-git-send-email-suhang16@mails.ucas.ac.cn Signed-off-by: Stefan Hajnoczi --- util/uri.c | 160 ++++++++++++++++++++++++++++++---------------------------= ---- 1 file changed, 80 insertions(+), 80 deletions(-) diff --git a/util/uri.c b/util/uri.c index cf09f41735..bb2576cf21 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; =20 if (str =3D=3D NULL) - return (-1); + return -1; =20 cur =3D *str; if (!ISA_ALPHA(cur)) - return (2); + return 2; cur++; while (ISA_ALPHA(cur) || ISA_DIGIT(cur) || (*cur =3D=3D '+') || (*cur = =3D=3D '-') || (*cur =3D=3D '.')) @@ -226,7 +226,7 @@ static int rfc3986_parse_scheme(URI *uri, const char **= str) uri->scheme =3D g_strndup(*str, cur - *str); } *str =3D cur; - return (0); + return 0; } =20 /** @@ -249,7 +249,7 @@ static int rfc3986_parse_fragment(URI *uri, const char = **str) const char *cur; =20 if (str =3D=3D NULL) - return (-1); + return -1; =20 cur =3D *str; =20 @@ -265,7 +265,7 @@ static int rfc3986_parse_fragment(URI *uri, const char = **str) uri->fragment =3D uri_string_unescape(*str, cur - *str, NULL); } *str =3D cur; - return (0); + return 0; } =20 /** @@ -284,7 +284,7 @@ static int rfc3986_parse_query(URI *uri, const char **s= tr) const char *cur; =20 if (str =3D=3D NULL) - return (-1); + return -1; =20 cur =3D *str; =20 @@ -296,7 +296,7 @@ static int rfc3986_parse_query(URI *uri, const char **s= tr) uri->query =3D g_strndup(*str, cur - *str); } *str =3D cur; - return (0); + return 0; } =20 /** @@ -362,9 +362,9 @@ static int rfc3986_parse_user_info(URI *uri, const char= **str) uri->user =3D uri_string_unescape(*str, cur - *str, NULL); } *str =3D cur; - return (0); + return 0; } - return (1); + return 1; } =20 /** @@ -386,7 +386,7 @@ static int rfc3986_parse_dec_octet(const char **str) const char *cur =3D *str; =20 if (!(ISA_DIGIT(cur))) - return (1); + return 1; if (!ISA_DIGIT(cur + 1)) cur++; else if ((*cur !=3D '0') && (ISA_DIGIT(cur + 1)) && (!ISA_DIGIT(cur + = 2))) @@ -400,9 +400,9 @@ static int rfc3986_parse_dec_octet(const char **str) (*(cur + 1) <=3D '5')) cur +=3D 3; else - return (1); + return 1; *str =3D cur; - return (0); + return 0; } /** * rfc3986_parse_host: @@ -433,7 +433,7 @@ static int rfc3986_parse_host(URI *uri, const char **st= r) while ((*cur !=3D ']') && (*cur !=3D 0)) cur++; if (*cur !=3D ']') - return (1); + return 1; cur++; goto found; } @@ -479,7 +479,7 @@ found: uri->server =3D NULL; } *str =3D cur; - return (0); + return 0; } =20 /** @@ -510,15 +510,15 @@ static int rfc3986_parse_authority(URI *uri, const ch= ar **str) cur++; ret =3D rfc3986_parse_host(uri, &cur); if (ret !=3D 0) - return (ret); + return ret; if (*cur =3D=3D ':') { cur++; ret =3D rfc3986_parse_port(uri, &cur); if (ret !=3D 0) - return (ret); + return ret; } *str =3D cur; - return (0); + return 0; } =20 /** @@ -544,13 +544,13 @@ static int rfc3986_parse_segment(const char **str, ch= ar forbid, int empty) cur =3D *str; if (!ISA_PCHAR(cur)) { if (empty) - return (0); - return (1); + return 0; + return 1; } while (ISA_PCHAR(cur) && (*cur !=3D forbid)) NEXT(cur); *str =3D cur; - return (0); + return 0; } =20 /** @@ -576,7 +576,7 @@ static int rfc3986_parse_path_ab_empty(URI *uri, const = char **str) cur++; ret =3D rfc3986_parse_segment(&cur, 0, 1); if (ret !=3D 0) - return (ret); + return ret; } if (uri !=3D NULL) { g_free(uri->path); @@ -590,7 +590,7 @@ static int rfc3986_parse_path_ab_empty(URI *uri, const = char **str) } } *str =3D cur; - return (0); + return 0; } =20 /** @@ -613,7 +613,7 @@ static int rfc3986_parse_path_absolute(URI *uri, const = char **str) cur =3D *str; =20 if (*cur !=3D '/') - return (1); + return 1; cur++; ret =3D rfc3986_parse_segment(&cur, 0, 0); if (ret =3D=3D 0) { @@ -621,7 +621,7 @@ static int rfc3986_parse_path_absolute(URI *uri, const = char **str) cur++; ret =3D rfc3986_parse_segment(&cur, 0, 1); if (ret !=3D 0) - return (ret); + return ret; } } if (uri !=3D NULL) { @@ -636,7 +636,7 @@ static int rfc3986_parse_path_absolute(URI *uri, const = char **str) } } *str =3D cur; - return (0); + return 0; } =20 /** @@ -660,12 +660,12 @@ static int rfc3986_parse_path_rootless(URI *uri, cons= t char **str) =20 ret =3D rfc3986_parse_segment(&cur, 0, 0); if (ret !=3D 0) - return (ret); + return ret; while (*cur =3D=3D '/') { cur++; ret =3D rfc3986_parse_segment(&cur, 0, 1); if (ret !=3D 0) - return (ret); + return ret; } if (uri !=3D NULL) { g_free(uri->path); @@ -679,7 +679,7 @@ static int rfc3986_parse_path_rootless(URI *uri, const = char **str) } } *str =3D cur; - return (0); + return 0; } =20 /** @@ -703,12 +703,12 @@ static int rfc3986_parse_path_no_scheme(URI *uri, con= st char **str) =20 ret =3D rfc3986_parse_segment(&cur, ':', 0); if (ret !=3D 0) - return (ret); + return ret; while (*cur =3D=3D '/') { cur++; ret =3D rfc3986_parse_segment(&cur, 0, 1); if (ret !=3D 0) - return (ret); + return ret; } if (uri !=3D NULL) { g_free(uri->path); @@ -722,7 +722,7 @@ static int rfc3986_parse_path_no_scheme(URI *uri, const= char **str) } } *str =3D cur; - return (0); + return 0; } =20 /** @@ -751,20 +751,20 @@ static int rfc3986_parse_hier_part(URI *uri, const ch= ar **str) cur +=3D 2; ret =3D rfc3986_parse_authority(uri, &cur); if (ret !=3D 0) - return (ret); + return ret; ret =3D rfc3986_parse_path_ab_empty(uri, &cur); if (ret !=3D 0) - return (ret); + return ret; *str =3D cur; - return (0); + return 0; } else if (*cur =3D=3D '/') { ret =3D rfc3986_parse_path_absolute(uri, &cur); if (ret !=3D 0) - return (ret); + return ret; } else if (ISA_PCHAR(cur)) { ret =3D rfc3986_parse_path_rootless(uri, &cur); if (ret !=3D 0) - return (ret); + return ret; } else { /* path-empty is effectively empty */ if (uri !=3D NULL) { @@ -773,7 +773,7 @@ static int rfc3986_parse_hier_part(URI *uri, const char= **str) } } *str =3D cur; - return (0); + return 0; } =20 /** @@ -800,18 +800,18 @@ static int rfc3986_parse_relative_ref(URI *uri, const= char *str) str +=3D 2; ret =3D rfc3986_parse_authority(uri, &str); if (ret !=3D 0) - return (ret); + return ret; ret =3D rfc3986_parse_path_ab_empty(uri, &str); if (ret !=3D 0) - return (ret); + return ret; } else if (*str =3D=3D '/') { ret =3D rfc3986_parse_path_absolute(uri, &str); if (ret !=3D 0) - return (ret); + return ret; } else if (ISA_PCHAR(str)) { ret =3D rfc3986_parse_path_no_scheme(uri, &str); if (ret !=3D 0) - return (ret); + return ret; } else { /* path-empty is effectively empty */ if (uri !=3D NULL) { @@ -824,19 +824,19 @@ static int rfc3986_parse_relative_ref(URI *uri, const= char *str) str++; ret =3D rfc3986_parse_query(uri, &str); if (ret !=3D 0) - return (ret); + return ret; } if (*str =3D=3D '#') { str++; ret =3D rfc3986_parse_fragment(uri, &str); if (ret !=3D 0) - return (ret); + return ret; } if (*str !=3D 0) { uri_clean(uri); - return (1); + return 1; } - return (0); + return 0; } =20 /** @@ -857,31 +857,31 @@ static int rfc3986_parse(URI *uri, const char *str) =20 ret =3D rfc3986_parse_scheme(uri, &str); if (ret !=3D 0) - return (ret); + return ret; if (*str !=3D ':') { - return (1); + return 1; } str++; ret =3D rfc3986_parse_hier_part(uri, &str); if (ret !=3D 0) - return (ret); + return ret; if (*str =3D=3D '?') { str++; ret =3D rfc3986_parse_query(uri, &str); if (ret !=3D 0) - return (ret); + return ret; } if (*str =3D=3D '#') { str++; ret =3D rfc3986_parse_fragment(uri, &str); if (ret !=3D 0) - return (ret); + return ret; } if (*str !=3D 0) { uri_clean(uri); - return (1); + return 1; } - return (0); + return 0; } =20 /** @@ -901,7 +901,7 @@ static int rfc3986_parse_uri_reference(URI *uri, const = char *str) int ret; =20 if (str =3D=3D NULL) - return (-1); + return -1; uri_clean(uri); =20 /* @@ -914,10 +914,10 @@ static int rfc3986_parse_uri_reference(URI *uri, cons= t char *str) ret =3D rfc3986_parse_relative_ref(uri, str); if (ret !=3D 0) { uri_clean(uri); - return (ret); + return ret; } } - return (0); + return 0; } =20 /** @@ -936,14 +936,14 @@ URI *uri_parse(const char *str) int ret; =20 if (str =3D=3D NULL) - return (NULL); + return NULL; uri =3D uri_new(); ret =3D rfc3986_parse_uri_reference(uri, str); if (ret) { uri_free(uri); - return (NULL); + return NULL; } - return (uri); + return uri; } =20 /** @@ -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); } =20 /** @@ -980,7 +980,7 @@ URI *uri_parse_raw(const char *str, int raw) int ret; =20 if (str =3D=3D NULL) - return (NULL); + return NULL; uri =3D uri_new(); if (raw) { uri->cleanup |=3D 2; @@ -988,9 +988,9 @@ URI *uri_parse_raw(const char *str, int raw) ret =3D uri_parse_into(uri, str); if (ret) { uri_free(uri); - return (NULL); + return NULL; } - return (uri); + return uri; } =20 /************************************************************************ @@ -1011,7 +1011,7 @@ URI *uri_new(void) URI *ret; =20 ret =3D g_new0(URI, 1); - return (ret); + return ret; } =20 /** @@ -1028,7 +1028,7 @@ static char *realloc2n(char *ret, int *max) tmp =3D *max * 2; temp =3D g_realloc(ret, (tmp + 1)); *max =3D tmp; - return (temp); + return temp; } =20 /** @@ -1048,7 +1048,7 @@ char *uri_to_string(URI *uri) int max; =20 if (uri =3D=3D NULL) - return (NULL); + return NULL; =20 max =3D 80; ret =3D g_malloc(max + 1); @@ -1249,7 +1249,7 @@ char *uri_to_string(URI *uri) ret =3D temp; } ret[len] =3D 0; - return (ret); + return ret; } =20 /** @@ -1315,7 +1315,7 @@ static int normalize_uri_path(char *path) char *cur, *out; =20 if (path =3D=3D NULL) - return (-1); + return -1; =20 /* 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] =3D=3D '/') ++cur; if (cur[0] =3D=3D '\0') - return (0); + return 0; =20 /* Keep everything we've seen so far. */ out =3D cur; @@ -1372,7 +1372,7 @@ done_cd: while (cur[0] =3D=3D '/') ++cur; if (cur[0] =3D=3D '\0') - return (0); + return 0; =20 /* * Analyze each segment in sequence for cases (e) and (f). @@ -1485,15 +1485,15 @@ done_cd: } } =20 - return (0); + return 0; } =20 static int is_hex(char c) { if (((c >=3D '0') && (c <=3D '9')) || ((c >=3D 'a') && (c <=3D 'f')) || ((c >=3D 'A') && (c <=3D 'F'))) - return (1); - return (0); + return 1; + return 0; } =20 /** @@ -1516,11 +1516,11 @@ char *uri_string_unescape(const char *str, int len,= char *target) const char *in; =20 if (str =3D=3D NULL) - return (NULL); + return NULL; if (len <=3D 0) len =3D strlen(str); if (len < 0) - return (NULL); + return NULL; =20 if (target =3D=3D NULL) { ret =3D g_malloc(len + 1); @@ -1553,7 +1553,7 @@ char *uri_string_unescape(const char *str, int len, c= har *target) } } *out =3D 0; - return (ret); + return ret; } =20 /** @@ -1574,12 +1574,12 @@ char *uri_string_escape(const char *str, const char= *list) int len, out; =20 if (str =3D=3D NULL) - return (NULL); + return NULL; if (str[0] =3D=3D 0) - return (g_strdup(str)); + return g_strdup(str); len =3D strlen(str); if (!(len > 0)) - return (NULL); + return NULL; =20 len +=3D 20; ret =3D g_malloc(len); @@ -1612,7 +1612,7 @@ char *uri_string_escape(const char *str, const char *= list) } } ret[out] =3D 0; - return (ret); + return ret; } =20 /************************************************************************ @@ -1851,7 +1851,7 @@ done: uri_free(bas); if (res !=3D NULL) uri_free(res); - return (val); + return val; } =20 /** --=20 2.14.3