hw/nmi: Use object_child_foreach_recursive() in nmi_children()
Replace object_child_foreach() and recursion by a single object_child_foreach_recursive() call. Propagate the returned value so callers can check it. Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20260812121232.71958-2-philmd@oss.qualcomm.com> Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Philippe Mathieu-Daudé committed
Feb 20, 2024 at 14:38 UTC
f37b245e564d7004f6a5f61a44cc021dda45f13e
1 file changed
+4
-8
hw/core/nmi.c
+4
-8
@@ -31,8 +31,6 @@ struct do_nmi_s {
31
bool handled;
32
};
33
34
-static void nmi_children(Object *o, struct do_nmi_s *ns);
35
-
34
static int do_nmi(Object *o, void *opaque)
35
{
36
struct do_nmi_s *ns = opaque;
@@ -47,14 +45,13 @@ static int do_nmi(Object *o, void *opaque)
45
return -1;
46
}
47
}
50
- nmi_children(o, ns);
48
49
return 0;
50
}
51
55
-static void nmi_children(Object *o, struct do_nmi_s *ns)
52
+static int nmi_children(Object *o, struct do_nmi_s *ns)
53
{
57
- object_child_foreach(o, do_nmi, ns);
54
+ return object_child_foreach_recursive(o, do_nmi, ns);
55
}
56
57
void nmi_monitor_handle(int cpu_index, Error **errp)
@@ -65,10 +62,9 @@ void nmi_monitor_handle(int cpu_index, Error **errp)
62
.handled = false
63
};
64
68
- nmi_children(object_get_root(), &ns);
69
- if (ns.handled) {
65
+ if (nmi_children(object_get_root(), &ns)) {
66
error_propagate(errp, ns.err);
71
- } else {
67
+ } else if (!ns.handled) {
68
error_setg(errp, "machine does not provide NMIs");
69
}
70
}