[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH-for-5.1 v2 48/54] scripts/coccinelle: Use &error_abort in TypeInf
From: |
Philippe Mathieu-Daudé |
Subject: |
[PATCH-for-5.1 v2 48/54] scripts/coccinelle: Use &error_abort in TypeInfo::instance_init() |
Date: |
Mon, 6 Apr 2020 19:47:37 +0200 |
The instance_init() calls are not suppose to fail. Add a
Coccinelle script to use &error_abort instead of ignoring
errors by using a NULL Error*.
Signed-off-by: Philippe Mathieu-Daudé <address@hidden>
---
.../use-error_abort-in-instance_init.cocci | 52 +++++++++++++++++++
MAINTAINERS | 1 +
2 files changed, 53 insertions(+)
create mode 100644 scripts/coccinelle/use-error_abort-in-instance_init.cocci
diff --git a/scripts/coccinelle/use-error_abort-in-instance_init.cocci
b/scripts/coccinelle/use-error_abort-in-instance_init.cocci
new file mode 100644
index 0000000000..8302d74a0c
--- /dev/null
+++ b/scripts/coccinelle/use-error_abort-in-instance_init.cocci
@@ -0,0 +1,52 @@
+// Use &error_abort in TypeInfo::instance_init()
+//
+// Copyright: (C) 2020 Philippe Mathieu-Daudé
+// This work is licensed under the terms of the GNU GPLv2 or later.
+//
+// spatch \
+// --macro-file scripts/cocci-macro-file.h --include-headers \
+// --sp-file scripts/coccinelle/use-error_abort-in-instance_init.cocci \
+// --keep-comments --in-place
+//
+// Inspired by https://www.mail-archive.com/address@hidden/msg692500.html
+// and https://www.mail-archive.com/address@hidden/msg693637.html
+
+
+@ has_qapi_error @
+@@
+ #include "qapi/error.h"
+
+
+@ match_instance_init @
+TypeInfo info;
+identifier instance_initfn;
+@@
+ info.instance_init = instance_initfn;
+
+
+@ use_error_abort @
+identifier match_instance_init.instance_initfn;
+identifier func_with_error;
+expression parentobj, propname, childobj, size, type, errp;
+position pos;
+@@
+void instance_initfn(...)
+{
+ <+...
+(
+ object_initialize_child(parentobj, propname,
+ childobj, size, type,
+ errp, NULL);
+|
+ func_with_error@pos(...,
+- NULL);
++ &error_abort);
+)
+ ...+>
+}
+
+
+@script:python depends on use_error_abort && !has_qapi_error@
+p << use_error_abort.pos;
+@@
+print('[[manual edit required, %s misses #include "qapi/error.h"]]' %
p[0].file)
diff --git a/MAINTAINERS b/MAINTAINERS
index 14de2a31dc..ae71a0a4b0 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2059,6 +2059,7 @@ F: scripts/coccinelle/error-use-after-free.cocci
F: scripts/coccinelle/error_propagate_null.cocci
F: scripts/coccinelle/remove_local_err.cocci
F: scripts/coccinelle/simplify-init-realize-error_propagate.cocci
+F: scripts/coccinelle/use-error_abort-in-instance_init.cocci
F: scripts/coccinelle/use-error_fatal.cocci
F: scripts/coccinelle/use-error_propagate-in-realize.cocci
--
2.21.1
- [PATCH-for-5.1 v2 39/54] hw/arm/fsl-imx: Add missing error-propagation code, (continued)
- [PATCH-for-5.1 v2 39/54] hw/arm/fsl-imx: Add missing error-propagation code, Philippe Mathieu-Daudé, 2020/04/06
- [PATCH-for-5.1 v2 35/54] hw/pci-host/pnv_phb3: Add missing error-propagation code, Philippe Mathieu-Daudé, 2020/04/06
- [PATCH-for-5.1 v2 41/54] hw/dma/xilinx_axidma: Add missing error-propagation code, Philippe Mathieu-Daudé, 2020/04/06
- [PATCH-for-5.1 v2 40/54] hw/arm/stm32fx05_soc: Add missing error-propagation code, Philippe Mathieu-Daudé, 2020/04/06
- [PATCH-for-5.1 v2 38/54] hw/arm/bcm2835_peripherals: Add missing error-propagation code, Philippe Mathieu-Daudé, 2020/04/06
- [PATCH-for-5.1 v2 44/54] hw/misc/macio/macio: Add missing error-propagation code, Philippe Mathieu-Daudé, 2020/04/06
- [PATCH-for-5.1 v2 42/54] hw/i386/x86: Add missing error-propagation code, Philippe Mathieu-Daudé, 2020/04/06
- [PATCH-for-5.1 v2 46/54] hw/riscv/sifive_u: Add missing error-propagation code, Philippe Mathieu-Daudé, 2020/04/06
- [PATCH-for-5.1 v2 47/54] hw/sd/milkymist-memcard: Add missing error-propagation code, Philippe Mathieu-Daudé, 2020/04/06
- [PATCH-for-5.1 v2 48/54] scripts/coccinelle: Use &error_abort in TypeInfo::instance_init(),
Philippe Mathieu-Daudé <=
- Re: [PATCH-for-5.1 v2 48/54] scripts/coccinelle: Use &error_abort in TypeInfo::instance_init(), Vladimir Sementsov-Ogievskiy, 2020/04/07
- Re: [PATCH-for-5.1 v2 48/54] scripts/coccinelle: Use &error_abort in TypeInfo::instance_init(), Philippe Mathieu-Daudé, 2020/04/07
- Re: [PATCH-for-5.1 v2 48/54] scripts/coccinelle: Use &error_abort in TypeInfo::instance_init(), Vladimir Sementsov-Ogievskiy, 2020/04/07
- Re: [PATCH-for-5.1 v2 48/54] scripts/coccinelle: Use &error_abort in TypeInfo::instance_init(), Philippe Mathieu-Daudé, 2020/04/07
- Re: [PATCH-for-5.1 v2 48/54] scripts/coccinelle: Use &error_abort in TypeInfo::instance_init(), Philippe Mathieu-Daudé, 2020/04/07
- Re: [PATCH-for-5.1 v2 48/54] scripts/coccinelle: Use &error_abort in TypeInfo::instance_init(), Vladimir Sementsov-Ogievskiy, 2020/04/07
- Re: [PATCH-for-5.1 v2 48/54] scripts/coccinelle: Use &error_abort in TypeInfo::instance_init(), Philippe Mathieu-Daudé, 2020/04/07
[PATCH-for-5.1 v2 43/54] hw/mips/cps: Add missing error-propagation code, Philippe Mathieu-Daudé, 2020/04/06
[PATCH-for-5.1 v2 45/54] hw/net/xilinx_axienet: Add missing error-propagation code, Philippe Mathieu-Daudé, 2020/04/06
[PATCH-for-5.1 v2 52/54] hw/mips/boston: Add missing error-propagation code, Philippe Mathieu-Daudé, 2020/04/06