diff mbox series

[v4,07/31] s390: Fix error_append_hint/error_prepend usage

Message ID 20191001155319.8066-8-vsementsov@virtuozzo.com
State New
Headers show
Series error: auto propagated local_err | expand

Commit Message

Vladimir Sementsov-Ogievskiy Oct. 1, 2019, 3:52 p.m. UTC
If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

This commit (together with its neighbors) was generated by

git grep -l 'error_\(append_hint\|prepend\)(errp' | while read f; do \
spatch --sp-file scripts/coccinelle/fix-error-add-info.cocci \
--in-place $f; done

and then

./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

and then by hand, for not maintained changed files:

git commit -m "<SUB-SYSTEM>: $(< auto-msg)" <FILES>

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 hw/s390x/s390-ccw.c       | 1 +
 target/s390x/cpu_models.c | 2 ++
 2 files changed, 3 insertions(+)

Comments

Cornelia Huck Oct. 7, 2019, 3:58 p.m. UTC | #1
On Tue,  1 Oct 2019 18:52:55 +0300
Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> wrote:

> If we want to add some info to errp (by error_prepend() or
> error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
> Otherwise, this info will not be added when errp == &fatal_err
> (the program will exit prior to the error_append_hint() or
> error_prepend() call).  Fix such cases.
> 
> This commit (together with its neighbors) was generated by
> 
> git grep -l 'error_\(append_hint\|prepend\)(errp' | while read f; do \
> spatch --sp-file scripts/coccinelle/fix-error-add-info.cocci \
> --in-place $f; done
> 
> and then
> 
> ./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"
> 
> (auto-msg was a file with this commit message)
> 
> and then by hand, for not maintained changed files:
> 
> git commit -m "<SUB-SYSTEM>: $(< auto-msg)" <FILES>
> 
> Still, for backporting it may be more comfortable to use only the first
> command and then do one huge commit.
> 
> Reported-by: Greg Kurz <groug@kaod.org>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
>  hw/s390x/s390-ccw.c       | 1 +
>  target/s390x/cpu_models.c | 2 ++
>  2 files changed, 3 insertions(+)

Acked-by: Cornelia Huck <cohuck@redhat.com>
Markus Armbruster Oct. 9, 2019, 7:42 a.m. UTC | #2
Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> writes:

> If we want to add some info to errp (by error_prepend() or
> error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
> Otherwise, this info will not be added when errp == &fatal_err
> (the program will exit prior to the error_append_hint() or
> error_prepend() call).  Fix such cases.
>
> This commit (together with its neighbors) was generated by
>
> git grep -l 'error_\(append_hint\|prepend\)(errp' | while read f; do \
> spatch --sp-file scripts/coccinelle/fix-error-add-info.cocci \
> --in-place $f; done

Make that:

    $ spatch --sp-file scripts/coccinelle/fix-error-add-info.cocci --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff `git grep -l 'error_\(append_hint\|prepend\)(errp' \*.[ch]`

Adding --macro-file is essential, as Eric noted.  Without it, we miss
qcow2_store_persistent_dirty_bitmaps() in PATCH 23 and
nbd_negotiate_send_rep_verr() in PATCH 29.  There should be a way to
make spatch warn when it gives up parsing, but I can't find it right
now.

Avoiding the loop is just for speed and simplicity.

--no-show-diff goes well with --in-place.

The even simpler

    $ spatch --sp-file scripts/coccinelle/fix-error-add-info.cocci --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff --use-gitgrep

misses include/block/nbd.h's nbd_read() in PATCH 23 somehow.

I recommend to add the spatch invocation to the coccinelle script's
commit message, too [PATCH 05].

[...]
Vladimir Sementsov-Ogievskiy Oct. 11, 2019, 3:33 p.m. UTC | #3
09.10.2019 10:42, Markus Armbruster wrote:
> Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> writes:
> 
>> If we want to add some info to errp (by error_prepend() or
>> error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
>> Otherwise, this info will not be added when errp == &fatal_err
>> (the program will exit prior to the error_append_hint() or
>> error_prepend() call).  Fix such cases.
>>
>> This commit (together with its neighbors) was generated by
>>
>> git grep -l 'error_\(append_hint\|prepend\)(errp' | while read f; do \
>> spatch --sp-file scripts/coccinelle/fix-error-add-info.cocci \
>> --in-place $f; done
> 
> Make that:
> 
>      $ spatch --sp-file scripts/coccinelle/fix-error-add-info.cocci --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff `git grep -l 'error_\(append_hint\|prepend\)(errp' \*.[ch]`
> 
> Adding --macro-file is essential, as Eric noted.  Without it, we miss
> qcow2_store_persistent_dirty_bitmaps() in PATCH 23 and
> nbd_negotiate_send_rep_verr() in PATCH 29.  There should be a way to
> make spatch warn when it gives up parsing, but I can't find it right
> now.
> 
> Avoiding the loop is just for speed and simplicity.

Seems without loop it hangs or at least works slower. And loop provides a kind of progress, so I'll keep the loop.

> 
> --no-show-diff goes well with --in-place.
> 
> The even simpler
> 
>      $ spatch --sp-file scripts/coccinelle/fix-error-add-info.cocci --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff --use-gitgrep
> 
> misses include/block/nbd.h's nbd_read() in PATCH 23 somehow.
> 
> I recommend to add the spatch invocation to the coccinelle script's
> commit message, too [PATCH 05].
> 
> [...]
>
diff mbox series

Patch

diff --git a/hw/s390x/s390-ccw.c b/hw/s390x/s390-ccw.c
index 0c5a5b60bd..c0a648a7e0 100644
--- a/hw/s390x/s390-ccw.c
+++ b/hw/s390x/s390-ccw.c
@@ -55,6 +55,7 @@  static void s390_ccw_get_dev_info(S390CCWDevice *cdev,
                                   char *sysfsdev,
                                   Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     unsigned int cssid, ssid, devid;
     char dev_path[PATH_MAX] = {0}, *tmp;
 
diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c
index 009afc38b9..32f2e5e822 100644
--- a/target/s390x/cpu_models.c
+++ b/target/s390x/cpu_models.c
@@ -840,6 +840,7 @@  static void error_prepend_missing_feat(const char *name, void *opaque)
 static void check_compatibility(const S390CPUModel *max_model,
                                 const S390CPUModel *model, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     S390FeatBitmap missing;
 
     if (model->def->gen > max_model->def->gen) {
@@ -922,6 +923,7 @@  static inline void apply_cpu_model(const S390CPUModel *model, Error **errp)
 
 void s390_realize_cpu_model(CPUState *cs, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     S390CPUClass *xcc = S390_CPU_GET_CLASS(cs);
     S390CPU *cpu = S390_CPU(cs);
     const S390CPUModel *max_model;