Content-Type: multipart/mixed; boundary="===============8464059130132249869==" MIME-Version: 1.0 From: Hans de Goede To: kbuild-all@lists.01.org Subject: Re: drivers/platform/surface/surface3-wmi.c:60:14: warning: variable 'status' set but not used Date: Thu, 04 Feb 2021 12:36:56 +0100 Message-ID: <80b763f8-8a19-aada-ae49-515fda2f209c@redhat.com> In-Reply-To: <1a749e41-86da-8607-ec39-c91cf4107a9f@gmail.com> List-Id: --===============8464059130132249869== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Hi, On 1/4/21 4:24 PM, Maximilian Luz wrote: > On 1/4/21 3:52 PM, Hans de Goede wrote: >> Hi, >> >> On 12/29/20 4:58 AM, kernel test robot wrote: >>> Hi Maximilian, >>> >>> FYI, the error/warning still remains. >>> >>> tree:=C2=A0=C2=A0 https://git.kernel.org/pub/scm/linux/kernel/git/torva= lds/linux.git master >>> head:=C2=A0=C2=A0 dea8dcf2a9fa8cc540136a6cd885c3beece16ec3 >>> commit: f23027ca3d48b6f93c5994069fb25b73539fdf34 platform/surface: Move= Surface 3 WMI driver to platform/surface >>> date:=C2=A0=C2=A0 9 weeks ago >>> config: x86_64-randconfig-r001-20201221 (attached as .config) >>> compiler: gcc-9 (Debian 9.3.0-15) 9.3.0 >>> reproduce (this is a W=3D1 build): >>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 # https://git.kernel.o= rg/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=3Df23027ca3d48b6f= 93c5994069fb25b73539fdf34 >>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 git remote add linus h= ttps://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git >>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 git fetch --no-tags li= nus master >>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 git checkout f23027ca3= d48b6f93c5994069fb25b73539fdf34 >>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 # save the attached .c= onfig to linux build tree >>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 make W=3D1 ARCH=3Dx86_= 64 >>> >>> If you fix the issue, kindly add following tag as appropriate >>> Reported-by: kernel test robot >>> >>> All warnings (new ones prefixed by >>): >>> >>> =C2=A0=C2=A0=C2=A0 drivers/platform/surface/surface3-wmi.c: In function= 's3_wmi_query_block': >>>>> drivers/platform/surface/surface3-wmi.c:60:14: warning: variable 'sta= tus' set but not used [-Wunused-but-set-variable] >>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 60 |=C2=A0 acpi_status status; >>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ^~~~~~ >> >> I guess fixing this would require something like this: >> >> From: Hans de Goede >> Subject: [PATCH] platform/surface: surface3-wmi: Fix variable 'status' s= et but not used compiler warning >> >> Explictly check the status rather then relying on output.pointer staying >> NULL on an error. This silences the following compiler warning: >> >> drivers/platform/surface/surface3-wmi.c:60:14: warning: variable 'status= ' set but not used [-Wunused-but-set-variable] >> >> Reported-by: kernel test robot >> Signed-off-by: Hans de Goede >> --- >> =C2=A0 drivers/platform/surface/surface3-wmi.c | 4 ++++ >> =C2=A0 1 file changed, 4 insertions(+) >> >> diff --git a/drivers/platform/surface/surface3-wmi.c b/drivers/platform/= surface/surface3-wmi.c >> index 130b6f52a600..4b7f79c0b78e 100644 >> --- a/drivers/platform/surface/surface3-wmi.c >> +++ b/drivers/platform/surface/surface3-wmi.c >> @@ -63,6 +63,10 @@ static int s3_wmi_query_block(const char *guid, int i= nstance, int *ret) >> =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 mutex_lock(&s3_wmi_lock); >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 status =3D wmi_query_block(guid, instance= , &output); >> +=C2=A0=C2=A0=C2=A0 if (ACPI_FAILURE(status)) { >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 error =3D -EIO; >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 goto out_free_unlock; >> +=C2=A0=C2=A0=C2=A0 } >> =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 obj =3D output.pointer; >> =C2=A0 >> Maximilian, can you review and/or test this fix please ? > = > Ah, this was on my TODO list (among looking at some other things in this > driver), sorry that I haven't gotten to it yet. I'd have proposed pretty > much the exact same thing. > = > One thing to note though: You should initialize obj with NULL. Keeping > it uninitialized may mess with kfree() under out_free_unlock. > = > Unfortunately I don't have access to a Surface 3 to test, but apart from > not initializing obj, this patch looks good to me. You may add my > reviewed-by tag once you've fixed that. Thank you, and sorry for being a bit slow with my follow up. I've added the obj =3D NULL initialization and added your reviewed-by tag. I'm sending this out as an official patch submission for the archives now and then I'll apply it to my review-hans branch right away, so no need for you to do anything :) > Also note that drivers/platform/x86/msi-wmi.c suffers from the same > problem in msi_wmi_query_block() and should receive a similar fix. Thanks, I'll prep a patch for that too. Regards, Hans --===============8464059130132249869==--