cpu: Remove pointless check

These two pointers can never be NULL since they are initialised to a reference
of a struct.  This became apparent when commit 210a195394 added a VIR_DEBUG
which used both pointers because due to the concise condition the compiler saw
that if the "and" part of the condition did short-circuit (and it assumed that
can happen) the second variable would not be initialised, but it is used in the
debugging message, so the build failed with:

  In file included from ../src/cpu/cpu_x86.c:27:
  ../src/cpu/cpu_x86.c: In function ‘virCPUx86DataIsIdentical’:
  ../src/util/virlog.h:79:5: error: ‘bdata’ may be used uninitialized in this
  function [-Werror=maybe-uninitialized]

Fix this by just assigning the helper pointers and remove the condition
altogether.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
Martin Kletzander 2022-04-27 09:42:59 +02:00
parent 6975ed0a94
commit 381498796c

View File

@ -3314,10 +3314,8 @@ virCPUx86DataIsIdentical(const virCPUData *a,
return VIR_CPU_COMPARE_INCOMPATIBLE;
}
if (!((adata = &a->data.x86) && (bdata = &b->data.x86))) {
VIR_DEBUG("missing x86 data: a:%p b:%p", adata, bdata);
return VIR_CPU_COMPARE_ERROR;
}
adata = &a->data.x86;
bdata = &b->data.x86;
if (adata->len != bdata->len) {
VIR_DEBUG("unequal length a:%zu b:%zu", adata->len, bdata->len);