diff mbox series

[RFC,v2,5/9] net/net: fix local variable shadowing in net_client_init

Message ID 20190923161231.22028-6-vsementsov@virtuozzo.com (mailing list archive)
State New, archived
Headers show
Series error: auto propagated local_err | expand

Commit Message

Vladimir Sementsov-Ogievskiy Sept. 23, 2019, 4:12 p.m. UTC
Don't shadow Error *err: it's a bad thing. This patch also simplifies
following Error propagation conversion.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 net/net.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Eric Blake Sept. 23, 2019, 6:44 p.m. UTC | #1
On 9/23/19 11:12 AM, Vladimir Sementsov-Ogievskiy wrote:
> Don't shadow Error *err: it's a bad thing. This patch also simplifies
> following Error propagation conversion.
> 
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
>  net/net.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)

Can be applied independently of the rest of this series.

> 
> diff --git a/net/net.c b/net/net.c
> index 84aa6d8d00..5fc72511c1 100644
> --- a/net/net.c
> +++ b/net/net.c
> @@ -1128,10 +1128,10 @@ static int net_client_init(QemuOpts *opts, bool is_netdev, Error **errp)
>  
>              if (substrings[1]) {
>                  /* User-specified prefix length.  */
> -                int err;
> +                int ret2;
>  
> -                err = qemu_strtoul(substrings[1], NULL, 10, &prefix_len);
> -                if (err) {
> +                ret2 = qemu_strtoul(substrings[1], NULL, 10, &prefix_len);
> +                if (ret2) {

In fact, you don't need ret2; you could just:

if (qemu_strtoul(...)) {

at which point you could then join:

if (substrings[1] &&
    qemus_strtoul(...)) {

>                      error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
>                                 "ipv6-prefixlen", "a number");
>                      goto out;
> 

Either way,

Reviewed-by: Eric Blake <eblake@redhat.com>
diff mbox series

Patch

diff --git a/net/net.c b/net/net.c
index 84aa6d8d00..5fc72511c1 100644
--- a/net/net.c
+++ b/net/net.c
@@ -1128,10 +1128,10 @@  static int net_client_init(QemuOpts *opts, bool is_netdev, Error **errp)
 
             if (substrings[1]) {
                 /* User-specified prefix length.  */
-                int err;
+                int ret2;
 
-                err = qemu_strtoul(substrings[1], NULL, 10, &prefix_len);
-                if (err) {
+                ret2 = qemu_strtoul(substrings[1], NULL, 10, &prefix_len);
+                if (ret2) {
                     error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
                                "ipv6-prefixlen", "a number");
                     goto out;