Received: from eggs.gnu.org ([2001:4830:134:3::10]:35984) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fVF4J-0006Lf-VK for qemu-devel@nongnu.org; Tue, 19 Jun 2018 07:45:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fVF4F-0001ko-Lx for qemu-devel@nongnu.org; Tue, 19 Jun 2018 07:45:04 -0400 From: Markus Armbruster References: <20180619085631.2859-1-aik@ozlabs.ru> Date: Tue, 19 Jun 2018 13:44:56 +0200 In-Reply-To: <20180619085631.2859-1-aik@ozlabs.ru> (Alexey Kardashevskiy's message of "Tue, 19 Jun 2018 18:56:31 +1000") Message-ID: <87sh5jvw3r.fsf@dusky.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH qemu] xics-kvm: Fix compile warning List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alexey Kardashevskiy Cc: qemu-devel@nongnu.org, qemu-ppc@nongnu.org, David Gibson Alexey Kardashevskiy writes: > This fixes uninitialized variable warning: > > /home/aik/p/qemu/hw/intc/xics_kvm.c: In function =E2=80=98ics_set_kvm_sta= te=E2=80=99: > /home/aik/p/qemu/hw/intc/xics_kvm.c:281:20: warning: =E2=80=98ret=E2=80= =99 may be used uninitialized in this function [-Wmaybe-uninitialized] > return ret; > ^~~ > > Discovered with gcc (Ubuntu 7.3.0-16ubuntu3) 7.3.0 from Ubuntu 18.04. > > Fixes: bf358b541b8 "xics_kvm: use KVM helpers" > Signed-off-by: Alexey Kardashevskiy > --- > hw/intc/xics_kvm.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/hw/intc/xics_kvm.c b/hw/intc/xics_kvm.c > index 8bdf6af..48efbce 100644 > --- a/hw/intc/xics_kvm.c > +++ b/hw/intc/xics_kvm.c > @@ -273,8 +273,8 @@ static int ics_set_kvm_state(ICSState *ics, int versi= on_id) > state |=3D KVM_XICS_QUEUED; > } >=20=20 > - kvm_device_access(kernel_xics_fd, KVM_DEV_XICS_GRP_SOURCES, > - i + ics->offset, &state, true, &local_err); > + ret =3D kvm_device_access(kernel_xics_fd, KVM_DEV_XICS_GRP_SOURC= ES, > + i + ics->offset, &state, true, &local_er= r); > if (local_err) { > error_report("Unable to restore KVM interrupt controller sta= te" > " for IRQs %d: %s", i + ics->offset, strerror(errno)= ); return ret; } Unless all callers effectively ignore the return value, this fixes a bug, not just a compiler warning. Recommend to check callers to find the bug's impact, and document it in your commit message. Messed up in commit bf358b541b8. Would be nice to mention that in your commit message. Also messed up there: leaks local_err. Please fix that, too.