From: Markus Armbruster <armbru@redhat.com>
To: Eduardo Habkost <ehabkost@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v3 3/3] coccinelle: Remove unnecessary variables for function return value
Date: Tue, 14 Jun 2016 10:57:44 +0200 [thread overview]
Message-ID: <87d1nkkv07.fsf@dusky.pond.sub.org> (raw)
In-Reply-To: <1465855078-19435-4-git-send-email-ehabkost@redhat.com> (Eduardo Habkost's message of "Mon, 13 Jun 2016 18:57:58 -0300")
Eduardo Habkost <ehabkost@redhat.com> writes:
> Use Coccinelle script to replace 'ret = E; return ret' with
> 'return E'. The script will do the substitution only when the
> function return type and variable type are the same.
>
> Sending as RFC because the patch looks more intrusive than the
> others. Probably better to split it per subsystem and let each
> maintainer review and apply it?
I guess you forgot to drop this paragraph. Can do it on commit to
error-next.
> Manual fixups:
>
> * audio/audio.c: coding style of "read (...)" and "write (...)"
> * block/qcow2-cluster.c: wrap line to make it shorter
> * block/qcow2-refcount.c: change indentation of wrapped line
> * target-tricore/op_helper.c: fix coding style of
> "remainder|quotient"
> * target-mips/dsp_helper.c: reverted changes because I don't
> want to argue about checkpatch.pl
> * ui/qemu-pixman.c: fix line indentation
> * block/rbd.c: restore blank line between declarations and
> statements
>
> Reviewed-by: Eric Blake <eblake@redhat.com>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
[...]
> diff --git a/scripts/coccinelle/return_directly.cocci b/scripts/coccinelle/return_directly.cocci
> new file mode 100644
> index 0000000..c52f4fc
> --- /dev/null
> +++ b/scripts/coccinelle/return_directly.cocci
> @@ -0,0 +1,21 @@
> +// replace 'R = X; return R;' with 'return R;'
> +
> +// remove assignment
Second comment feels redundant. Can drop on commit to error-next.
> +@ removal @
Rule name "removal" is not used. Can drop on commit to error-next.
> +identifier VAR;
> +expression E;
> +type T;
> +identifier F;
> +@@
> + T F(...)
> + {
> + ...
> +- T VAR;
> + ... when != VAR
> +
> +- VAR =
> ++ return
> + E;
> +- return VAR;
> + ... when != VAR
> + }
[...]
> diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
> index b04bfaf..afc8d6b 100644
> --- a/block/qcow2-cluster.c
> +++ b/block/qcow2-cluster.c
> @@ -154,11 +154,8 @@ static int l2_load(BlockDriverState *bs, uint64_t l2_offset,
> uint64_t **l2_table)
> {
> BDRVQcow2State *s = bs->opaque;
> - int ret;
> -
I'd prefer to keep this blank line. Can touch up on commit to error-next.
> - ret = qcow2_cache_get(bs, s->l2_table_cache, l2_offset, (void**) l2_table);
> -
> - return ret;
> + return qcow2_cache_get(bs, s->l2_table_cache, l2_offset,
> + (void **) l2_table);
> }
>
> /*
[...]
next prev parent reply other threads:[~2016-06-14 8:57 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-13 21:57 [Qemu-devel] [PATCH v3 0/3] coccinelle: Clean up error checks and return value variables Eduardo Habkost
2016-06-13 21:57 ` [Qemu-devel] [PATCH v3 1/3] error: Remove NULL checks on error_propagate() calls Eduardo Habkost
2016-06-13 21:57 ` [Qemu-devel] [PATCH v3 2/3] error: Remove unnecessary local_err variables Eduardo Habkost
2016-06-13 23:06 ` Eric Blake
2016-06-14 8:49 ` Markus Armbruster
2016-06-13 21:57 ` [Qemu-devel] [PATCH v3 3/3] coccinelle: Remove unnecessary variables for function return value Eduardo Habkost
2016-06-14 8:57 ` Markus Armbruster [this message]
2016-06-14 9:11 ` Paolo Bonzini
2016-06-14 11:20 ` Markus Armbruster
2016-06-14 11:58 ` Eduardo Habkost
2016-06-14 11:20 ` Eduardo Habkost
2016-06-14 9:03 ` [Qemu-devel] [PATCH v3 0/3] coccinelle: Clean up error checks and return value variables Markus Armbruster
2016-06-14 17:45 ` Markus Armbruster
2016-06-14 17:46 ` Eduardo Habkost
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87d1nkkv07.fsf@dusky.pond.sub.org \
--to=armbru@redhat.com \
--cc=ehabkost@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.