Message ID | 20200902080801.160652-4-philmd@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | misc: Reduce assert side-effects | expand |
On Wed, 2 Sep 2020 10:07:59 +0200 Philippe Mathieu-Daudé <philmd@redhat.com> wrote: > This variable is used once in an assertion. Remove single > declaration and access directly in the assert(). > > See in "qemu/osdep.h": > > * [...] disable assertion is not > * supported upstream so the risk is all yours. Meanwhile, please > * submit patches to remove any side-effects inside an assertion, or > * fixing error handling that should use Error instead of assert. > > Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> > --- Same remarks as patch 2/5. > hw/ppc/spapr.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c > index dd2fa4826b3..6447a5b3808 100644 > --- a/hw/ppc/spapr.c > +++ b/hw/ppc/spapr.c > @@ -628,7 +628,6 @@ static int spapr_dt_dynamic_reconfiguration_memory(SpaprMachineState *spapr, > static int spapr_dt_memory(SpaprMachineState *spapr, void *fdt) > { > MachineState *machine = MACHINE(spapr); > - SpaprMachineClass *smc = SPAPR_MACHINE_GET_CLASS(spapr); > hwaddr mem_start, node_size; > int i, nb_nodes = machine->numa_state->num_nodes; > NodeInfo *nodes = machine->numa_state->nodes; > @@ -670,7 +669,7 @@ static int spapr_dt_memory(SpaprMachineState *spapr, void *fdt) > if (spapr_ovec_test(spapr->ov5_cas, OV5_DRCONF_MEMORY)) { > int ret; > > - g_assert(smc->dr_lmb_enabled); > + g_assert(SPAPR_MACHINE_GET_CLASS(spapr)->dr_lmb_enabled); > ret = spapr_dt_dynamic_reconfiguration_memory(spapr, fdt); > if (ret) { > return ret;
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index dd2fa4826b3..6447a5b3808 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -628,7 +628,6 @@ static int spapr_dt_dynamic_reconfiguration_memory(SpaprMachineState *spapr, static int spapr_dt_memory(SpaprMachineState *spapr, void *fdt) { MachineState *machine = MACHINE(spapr); - SpaprMachineClass *smc = SPAPR_MACHINE_GET_CLASS(spapr); hwaddr mem_start, node_size; int i, nb_nodes = machine->numa_state->num_nodes; NodeInfo *nodes = machine->numa_state->nodes; @@ -670,7 +669,7 @@ static int spapr_dt_memory(SpaprMachineState *spapr, void *fdt) if (spapr_ovec_test(spapr->ov5_cas, OV5_DRCONF_MEMORY)) { int ret; - g_assert(smc->dr_lmb_enabled); + g_assert(SPAPR_MACHINE_GET_CLASS(spapr)->dr_lmb_enabled); ret = spapr_dt_dynamic_reconfiguration_memory(spapr, fdt); if (ret) { return ret;
This variable is used once in an assertion. Remove single declaration and access directly in the assert(). See in "qemu/osdep.h": * [...] disable assertion is not * supported upstream so the risk is all yours. Meanwhile, please * submit patches to remove any side-effects inside an assertion, or * fixing error handling that should use Error instead of assert. Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> --- hw/ppc/spapr.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)