Re: [cocci] [PATCH 25/36] platform/x86: toshiba_haps: remove conditional return with no effect
Sang-Heon Jeon <[email protected]> Sat, 25 Jul 2026 01:21:47 +0900
| Newsgroups | fr.inria.cocci,org.kernel.vger.linux-kernel,org.kernel.vger.platform-driver-x86 |
|---|---|
| Message-ID | <CABFDxMGQ7CfSy+xOD1QnjHyBm99z659g5KQgFX0=4eTd7hW_Ww@mail.gmail.com> |
Hello, On Sat, Jul 25, 2026 at 12:44=E2=80=AFAM Ilpo J=C3=A4rvinen <[email protected]> wrote: > > On Fri, 24 Jul 2026, Sang-Heon Jeon wrote: > > > Both branches of the check return the same value, so the check has > > no effect. Remove it and return the value directly. > > > > This is the result of running the Coccinelle script from > > scripts/coccinelle/misc/cond_return_no_effect.cocci. > > > > Signed-off-by: Sang-Heon Jeon <[email protected]> > > --- > > drivers/platform/x86/toshiba_haps.c | 6 +----- > > 1 file changed, 1 insertion(+), 5 deletions(-) > > > > diff --git a/drivers/platform/x86/toshiba_haps.c b/drivers/platform/x86= /toshiba_haps.c > > index c6633b74029f..4f62476b8dd1 100644 > > --- a/drivers/platform/x86/toshiba_haps.c > > +++ b/drivers/platform/x86/toshiba_haps.c > > @@ -251,11 +251,7 @@ static int toshiba_haps_resume(struct device *devi= ce) > > haps->protection_level); > > > > /* Reset the protection on resume */ > > - ret =3D toshiba_haps_reset_protection(haps->acpi_dev->handle); > > - if (ret !=3D 0) > > - return ret; > > - > > - return ret; > > + return toshiba_haps_reset_protection(haps->acpi_dev->handle); > > } > > #endif > > Sadly this has not seen much testing: > > CC drivers/platform/x86/toshiba_haps.o > drivers/platform/x86/toshiba_haps.c: In function =E2=80=98toshiba_haps_re= sume=E2=80=99: > drivers/platform/x86/toshiba_haps.c:247:13: error: variable =E2=80=98ret= =E2=80=99 set but not used [-Werror=3Dunused-but-set-variable] > 247 | int ret; > | ^~~ > cc1: all warnings being treated as errors > make[5]: *** [scripts/Makefile.build:289: > drivers/platform/x86/toshiba_haps.o] Error 1 > > ...I guess you never took the time to look at and understand the > surrounding code either. :-( Right, the assignment of toshiba_haps_protection_level() return value is unnecessary, whether or not this cleanup is applied. I didn't expect a case like this, so I didn't look at it carefully enough and missed it. I'll fix it in v2. Sorry for the noise. > -- > i. Best Regards, Sang-Heon Jeon