From ee1004bba6eadeddf988a29716dc28849c0211c8 Mon Sep 17 00:00:00 2001 From: Philippe Mathieu-Daudé Date: Mon, 29 Jan 2024 17:44:43 +0100 Subject: bulk: Access existing variables initialized to &S->F when available MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a variable is initialized to &struct->field, use it in place. Rationale: while this makes the code more concise, this also helps static analyzers. Mechanical change using the following Coccinelle spatch script: @@ type S, F; identifier s, m, v; @@ S *s; ... F *v = &s->m; <+... - &s->m + v ...+> Inspired-by: Zhao Liu Signed-off-by: Philippe Mathieu-Daudé Message-ID: <20240129164514.73104-2-philmd@linaro.org> Acked-by: Fabiano Rosas Reviewed-by: Zhao Liu Reviewed-by: Anthony PERARD [thuth: Dropped hunks that need a rebase, and fixed sizeof() in pmu_realize()] Signed-off-by: Thomas Huth --- hw/misc/macio/pmu.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'hw/misc/macio/pmu.c') diff --git a/hw/misc/macio/pmu.c b/hw/misc/macio/pmu.c index e9a90da88f..e40c51bf52 100644 --- a/hw/misc/macio/pmu.c +++ b/hw/misc/macio/pmu.c @@ -737,8 +737,7 @@ static void pmu_realize(DeviceState *dev, Error **errp) timer_mod(s->one_sec_timer, s->one_sec_target); if (s->has_adb) { - qbus_init(&s->adb_bus, sizeof(s->adb_bus), TYPE_ADB_BUS, - dev, "adb.0"); + qbus_init(adb_bus, sizeof(*adb_bus), TYPE_ADB_BUS, dev, "adb.0"); adb_register_autopoll_callback(adb_bus, pmu_adb_poll, s); } } -- cgit 1.4.1