From: Markus Armbruster <armbru@redhat.com>
To: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Cc: "Kevin Wolf" <kwolf@redhat.com>,
"Stefano Stabellini" <sstabellini@kernel.org>,
"Michael Roth" <mdroth@linux.vnet.ibm.com>,
qemu-block@nongnu.org, "Paul Durrant" <paul@xen.org>,
"Laszlo Ersek" <lersek@redhat.com>,
"Christian Schoenebeck" <qemu_oss@crudebyte.com>,
qemu-devel@nongnu.org, "Greg Kurz" <groug@kaod.org>,
"Gerd Hoffmann" <kraxel@redhat.com>,
"Stefan Hajnoczi" <stefanha@redhat.com>,
"Anthony Perard" <anthony.perard@citrix.com>,
xen-devel@lists.xenproject.org, "Max Reitz" <mreitz@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@redhat.com>,
armbru@redhat.com, "Stefan Berger" <stefanb@linux.ibm.com>
Subject: Re: [Xen-devel] [PATCH v9 02/10] scripts: Coccinelle script to use ERRP_AUTO_PROPAGATE()
Date: Fri, 13 Mar 2020 15:58:35 +0100 [thread overview]
Message-ID: <87imj8i9no.fsf@dusky.pond.sub.org> (raw)
In-Reply-To: <20200312085936.9552-3-vsementsov@virtuozzo.com> (Vladimir Sementsov-Ogievskiy's message of "Thu, 12 Mar 2020 11:59:28 +0300")
I tried this script on the whole tree. Observations:
* $ git-diff --shortstat \*.[ch]
333 files changed, 3480 insertions(+), 4586 deletions(-)
* Twelve functions have "several definitions of Error * local variable".
Eight declare such a variable within a loop. Reported because
Coccinelle matches along control flow, not just along text. Ignore.
Remaining four:
* ivshmem_common_realize()
Two variables (messed up in commit fe44dc91807), should be replaced
by one.
* qmp_query_cpu_model_expansion() two times
Three declarations in separate blocks; two should be replaced by
&error_abort, one moved to the function block.
* xen_block_device_destroy()
Two declarations in seperate blocks; should be replaced by a single
one.
Separate manual cleanup patches, ideally applied before running
Coccinelle to keep Coccinelle's changes as simple and safe as
possible. I'll post patches. Only the one for
xen_block_device_destroy() affects by this series.
* No function "propagates to errp several times"
I tested the rule does detect this as advertized by feeding it an
obvious example. We're good.
* ERRP_AUTO_PROPAGATE() inserted 744 times, always right at the
beginning of a function.
* As far as I can tell, all changed functions have ERRP_AUTO_PROPAGATE()
inserted. Good.
* Almost 1100 error propagations dropped:error_propagate() removed,
error_propagate_prepend() replaced by just error_prepend().
* Four error_propagate() are transformed. Two instances each in
aspeed_soc_ast2600_realize() and aspeed_soc_realize(). Pattern:
{
+ ERRP_AUTO_PROPAGATE();
...
- Error *err = NULL, *local_err = NULL;
+ Error *local_err = NULL;
...
object_property_set_T(...,
- &err);
+ errp);
object_property_set_T(...,
&local_err);
- error_propagate(&err, local_err);
- if (err) {
- error_propagate(errp, err);
+ error_propagate(errp, local_err);
+ if (*errp) {
return;
}
This is what error.h calls "Receive and accumulate multiple errors
(first one wins)".
Result:
ERRP_AUTO_PROPAGATE();
...
Error *local_err = NULL;
...
object_property_set_T(..., errp);
object_property_set_T(..., &local_err);
error_propagate(errp, local_err);
if (*errp) {
return;
}
Could be done without the accumulation:
ERRP_AUTO_PROPAGATE();
...
object_property_set_T(..., errp);
if (*errp) {
return;
}
object_property_set_T(..., errp);
if (*errp) {
return;
}
I find this a bit easier to understand. Matter of taste. If we want
to change to this, do it manually and separately. I'd do it on top.
* Some 90 propagations remain.
Some of them could use cleanup, e.g. file_memory_backend_set_pmem(),
css_clear_io_interrupt(). Out of scope for this series.
Some move errors around in unusual ways, e.g. in block/nbd.c. Could
use review. Out of scope for this series.
I spotted three that should be transformed, but aren't:
- qcrypto_block_luks_store_key()
I believe g_autoptr() confuses Coccinelle. Undermines all our
Coccinelle use, not just this patch. I think we need to update
scripts/cocci-macro-file.h for it.
- armsse_realize()
Something in this huge function confuses Coccinelle, but I don't
know what exactly. If I delete most of it, the error_propagate()
transforms okay. If I delete less, Coccinelle hangs.
- apply_cpu_model()
Gets transformed fine if I remove the #ifndef CONFIG_USER_ONLY. I
have no idea why the #if spooks Coccinelle here, but not elsewhere.
None of these three affects this series. No need to hold it back for
further investigation.
* 30 error_free() and two warn_reportf_err() are transformed. Patterns:
- error_free(local_err);
- local_err = NULL;
+ error_free_errp(errp);
and
- error_free(local_err);
+ error_free_errp(errp);
and
- warn_report_err(local_err);
- local_err = NULL;
+ warn_report_errp(errp);
Good.
* Many error_free(), error_reportf_err() and warn_reportf_err() remain.
None of them have an argument of the form *errp. Such arguments would
have to be reviewed for possible interference with
ERRP_AUTO_PROPAGATE().
* Almost 700 Error *err = NULL removed. Almost 600 remain.
* Error usage in rdma.c is questionable / wrong. Out of scope for this
series.
As far as I can tell, your Coccinelle script is working as intended,
except for three missed error propagations noted above. We can proceed
with this series regardless, if we want. I'd prefer to integrate my
forthcoming cleanup to xen_block_device_destroy(), though.
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
WARNING: multiple messages have this Message-ID (diff)
From: Markus Armbruster <armbru@redhat.com>
To: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Cc: "Kevin Wolf" <kwolf@redhat.com>,
"Stefano Stabellini" <sstabellini@kernel.org>,
"Michael Roth" <mdroth@linux.vnet.ibm.com>,
qemu-block@nongnu.org, "Paul Durrant" <paul@xen.org>,
"Laszlo Ersek" <lersek@redhat.com>,
"Christian Schoenebeck" <qemu_oss@crudebyte.com>,
qemu-devel@nongnu.org, "Greg Kurz" <groug@kaod.org>,
"Gerd Hoffmann" <kraxel@redhat.com>,
"Stefan Hajnoczi" <stefanha@redhat.com>,
"Anthony Perard" <anthony.perard@citrix.com>,
xen-devel@lists.xenproject.org, "Max Reitz" <mreitz@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@redhat.com>,
armbru@redhat.com, "Stefan Berger" <stefanb@linux.ibm.com>
Subject: Re: [PATCH v9 02/10] scripts: Coccinelle script to use ERRP_AUTO_PROPAGATE()
Date: Fri, 13 Mar 2020 15:58:35 +0100 [thread overview]
Message-ID: <87imj8i9no.fsf@dusky.pond.sub.org> (raw)
In-Reply-To: <20200312085936.9552-3-vsementsov@virtuozzo.com> (Vladimir Sementsov-Ogievskiy's message of "Thu, 12 Mar 2020 11:59:28 +0300")
I tried this script on the whole tree. Observations:
* $ git-diff --shortstat \*.[ch]
333 files changed, 3480 insertions(+), 4586 deletions(-)
* Twelve functions have "several definitions of Error * local variable".
Eight declare such a variable within a loop. Reported because
Coccinelle matches along control flow, not just along text. Ignore.
Remaining four:
* ivshmem_common_realize()
Two variables (messed up in commit fe44dc91807), should be replaced
by one.
* qmp_query_cpu_model_expansion() two times
Three declarations in separate blocks; two should be replaced by
&error_abort, one moved to the function block.
* xen_block_device_destroy()
Two declarations in seperate blocks; should be replaced by a single
one.
Separate manual cleanup patches, ideally applied before running
Coccinelle to keep Coccinelle's changes as simple and safe as
possible. I'll post patches. Only the one for
xen_block_device_destroy() affects by this series.
* No function "propagates to errp several times"
I tested the rule does detect this as advertized by feeding it an
obvious example. We're good.
* ERRP_AUTO_PROPAGATE() inserted 744 times, always right at the
beginning of a function.
* As far as I can tell, all changed functions have ERRP_AUTO_PROPAGATE()
inserted. Good.
* Almost 1100 error propagations dropped:error_propagate() removed,
error_propagate_prepend() replaced by just error_prepend().
* Four error_propagate() are transformed. Two instances each in
aspeed_soc_ast2600_realize() and aspeed_soc_realize(). Pattern:
{
+ ERRP_AUTO_PROPAGATE();
...
- Error *err = NULL, *local_err = NULL;
+ Error *local_err = NULL;
...
object_property_set_T(...,
- &err);
+ errp);
object_property_set_T(...,
&local_err);
- error_propagate(&err, local_err);
- if (err) {
- error_propagate(errp, err);
+ error_propagate(errp, local_err);
+ if (*errp) {
return;
}
This is what error.h calls "Receive and accumulate multiple errors
(first one wins)".
Result:
ERRP_AUTO_PROPAGATE();
...
Error *local_err = NULL;
...
object_property_set_T(..., errp);
object_property_set_T(..., &local_err);
error_propagate(errp, local_err);
if (*errp) {
return;
}
Could be done without the accumulation:
ERRP_AUTO_PROPAGATE();
...
object_property_set_T(..., errp);
if (*errp) {
return;
}
object_property_set_T(..., errp);
if (*errp) {
return;
}
I find this a bit easier to understand. Matter of taste. If we want
to change to this, do it manually and separately. I'd do it on top.
* Some 90 propagations remain.
Some of them could use cleanup, e.g. file_memory_backend_set_pmem(),
css_clear_io_interrupt(). Out of scope for this series.
Some move errors around in unusual ways, e.g. in block/nbd.c. Could
use review. Out of scope for this series.
I spotted three that should be transformed, but aren't:
- qcrypto_block_luks_store_key()
I believe g_autoptr() confuses Coccinelle. Undermines all our
Coccinelle use, not just this patch. I think we need to update
scripts/cocci-macro-file.h for it.
- armsse_realize()
Something in this huge function confuses Coccinelle, but I don't
know what exactly. If I delete most of it, the error_propagate()
transforms okay. If I delete less, Coccinelle hangs.
- apply_cpu_model()
Gets transformed fine if I remove the #ifndef CONFIG_USER_ONLY. I
have no idea why the #if spooks Coccinelle here, but not elsewhere.
None of these three affects this series. No need to hold it back for
further investigation.
* 30 error_free() and two warn_reportf_err() are transformed. Patterns:
- error_free(local_err);
- local_err = NULL;
+ error_free_errp(errp);
and
- error_free(local_err);
+ error_free_errp(errp);
and
- warn_report_err(local_err);
- local_err = NULL;
+ warn_report_errp(errp);
Good.
* Many error_free(), error_reportf_err() and warn_reportf_err() remain.
None of them have an argument of the form *errp. Such arguments would
have to be reviewed for possible interference with
ERRP_AUTO_PROPAGATE().
* Almost 700 Error *err = NULL removed. Almost 600 remain.
* Error usage in rdma.c is questionable / wrong. Out of scope for this
series.
As far as I can tell, your Coccinelle script is working as intended,
except for three missed error propagations noted above. We can proceed
with this series regardless, if we want. I'd prefer to integrate my
forthcoming cleanup to xen_block_device_destroy(), though.
next prev parent reply other threads:[~2020-03-13 14:59 UTC|newest]
Thread overview: 67+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-12 8:59 [Xen-devel] [PATCH v9 00/10] error: auto propagated local_err part I Vladimir Sementsov-Ogievskiy
2020-03-12 8:59 ` Vladimir Sementsov-Ogievskiy
2020-03-12 8:59 ` [Xen-devel] [PATCH v9 01/10] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
2020-03-12 8:59 ` Vladimir Sementsov-Ogievskiy
2020-03-12 8:59 ` [Xen-devel] [PATCH v9 02/10] scripts: Coccinelle script to use ERRP_AUTO_PROPAGATE() Vladimir Sementsov-Ogievskiy
2020-03-12 8:59 ` Vladimir Sementsov-Ogievskiy
2020-03-12 16:36 ` [Xen-devel] " Markus Armbruster
2020-03-12 16:36 ` Markus Armbruster
2020-03-13 6:38 ` [Xen-devel] " Vladimir Sementsov-Ogievskiy
2020-03-13 6:38 ` Vladimir Sementsov-Ogievskiy
2020-03-13 15:42 ` [Xen-devel] " Markus Armbruster
2020-03-13 15:42 ` Markus Armbruster
2020-03-13 16:12 ` [Xen-devel] " Vladimir Sementsov-Ogievskiy
2020-03-13 16:12 ` Vladimir Sementsov-Ogievskiy
2020-03-13 21:54 ` [Xen-devel] " Markus Armbruster
2020-03-13 21:54 ` Markus Armbruster
2020-03-13 22:12 ` [Xen-devel] " Eric Blake
2020-03-13 22:12 ` Eric Blake
2020-03-15 16:38 ` [Xen-devel] " Markus Armbruster
2020-03-15 16:38 ` Markus Armbruster
2020-03-16 7:12 ` [Xen-devel] " Vladimir Sementsov-Ogievskiy
2020-03-16 7:12 ` Vladimir Sementsov-Ogievskiy
2020-03-16 8:21 ` [Xen-devel] " Markus Armbruster
2020-03-16 8:21 ` Markus Armbruster
2020-03-17 9:29 ` [Xen-devel] " Vladimir Sementsov-Ogievskiy
2020-03-17 9:29 ` Vladimir Sementsov-Ogievskiy
2020-03-17 10:39 ` [Xen-devel] " Markus Armbruster
2020-03-17 10:39 ` Markus Armbruster
2020-03-17 11:35 ` [Xen-devel] " Vladimir Sementsov-Ogievskiy
2020-03-17 11:35 ` Vladimir Sementsov-Ogievskiy
2020-03-19 10:45 ` [Xen-devel] " Markus Armbruster
2020-03-19 10:45 ` Markus Armbruster
2020-03-19 12:12 ` [Xen-devel] " Vladimir Sementsov-Ogievskiy
2020-03-19 12:12 ` Vladimir Sementsov-Ogievskiy
2020-03-20 13:58 ` [Xen-devel] " Markus Armbruster
2020-03-20 13:58 ` Markus Armbruster
2020-03-20 14:36 ` [Xen-devel] " Vladimir Sementsov-Ogievskiy
2020-03-20 14:36 ` Vladimir Sementsov-Ogievskiy
2020-03-20 16:23 ` [Xen-devel] " Markus Armbruster
2020-03-20 16:23 ` Markus Armbruster
2020-03-17 13:54 ` [Xen-devel] " Vladimir Sementsov-Ogievskiy
2020-03-17 13:54 ` Vladimir Sementsov-Ogievskiy
2020-03-19 8:31 ` [Xen-devel] " Markus Armbruster
2020-03-19 8:31 ` Markus Armbruster
2020-03-13 7:50 ` [Xen-devel] " Markus Armbruster
2020-03-13 7:50 ` Markus Armbruster
2020-03-13 8:06 ` [Xen-devel] " Vladimir Sementsov-Ogievskiy
2020-03-13 8:06 ` Vladimir Sementsov-Ogievskiy
2020-03-13 15:34 ` [Xen-devel] " Markus Armbruster
2020-03-13 15:34 ` Markus Armbruster
2020-03-13 14:58 ` Markus Armbruster [this message]
2020-03-13 14:58 ` Markus Armbruster
2020-03-13 15:22 ` [Xen-devel] " Vladimir Sementsov-Ogievskiy
2020-03-13 15:22 ` Vladimir Sementsov-Ogievskiy
2020-03-12 8:59 ` [PATCH v9 03/10] hw/sd/ssi-sd: fix error handling in ssi_sd_realize Vladimir Sementsov-Ogievskiy
2020-03-12 8:59 ` [PATCH v9 04/10] SD (Secure Card): introduce ERRP_AUTO_PROPAGATE Vladimir Sementsov-Ogievskiy
2020-03-12 8:59 ` [PATCH v9 05/10] pflash: " Vladimir Sementsov-Ogievskiy
2020-03-12 8:59 ` [PATCH v9 06/10] fw_cfg: " Vladimir Sementsov-Ogievskiy
2020-03-12 8:59 ` [PATCH v9 07/10] virtio-9p: " Vladimir Sementsov-Ogievskiy
2020-03-12 8:59 ` [PATCH v9 08/10] TPM: " Vladimir Sementsov-Ogievskiy
2020-03-12 8:59 ` [PATCH v9 09/10] nbd: " Vladimir Sementsov-Ogievskiy
2020-03-12 8:59 ` [Xen-devel] [PATCH v9 10/10] xen: " Vladimir Sementsov-Ogievskiy
2020-03-12 8:59 ` Vladimir Sementsov-Ogievskiy
2020-03-12 14:24 ` [Xen-devel] [PATCH v9 00/10] error: auto propagated local_err part I Markus Armbruster
2020-03-12 14:24 ` Markus Armbruster
2020-03-13 6:40 ` [Xen-devel] " Vladimir Sementsov-Ogievskiy
2020-03-13 6:40 ` Vladimir Sementsov-Ogievskiy
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=87imj8i9no.fsf@dusky.pond.sub.org \
--to=armbru@redhat.com \
--cc=anthony.perard@citrix.com \
--cc=groug@kaod.org \
--cc=kraxel@redhat.com \
--cc=kwolf@redhat.com \
--cc=lersek@redhat.com \
--cc=mdroth@linux.vnet.ibm.com \
--cc=mreitz@redhat.com \
--cc=paul@xen.org \
--cc=philmd@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu_oss@crudebyte.com \
--cc=sstabellini@kernel.org \
--cc=stefanb@linux.ibm.com \
--cc=stefanha@redhat.com \
--cc=vsementsov@virtuozzo.com \
--cc=xen-devel@lists.xenproject.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.