[QUERY]drivers: pnp: isapnp:proc.c: assignment inside if statement

Shuah Khan skhan at linuxfoundation.org
Wed Apr 21 00:34:58 UTC 2021


On 4/20/21 12:05 PM, anupamakpatil123 wrote:
> This is a code snippet from line 63 of drivers: pnp: isapnp: proc.c
> This is an error I came across while looking through some checkpatch
> errors.
> 
> if (!(de = bus->procdir)) {
>                  sprintf(name, "%02x", bus->number);
>                  de = bus->procdir = proc_mkdir(name, isapnp_proc_bus_dir);
>                  if (!de)
>                          return -ENOMEM;
>          }
> 
> In the above code snippet is assignment inside the if statement
> necessary? Can the assignment be done outside the if statement as it is
> a good coding style practice?
> Is that change sufficient? I dont want to just shut checkpatch errors as I
> really want to improve the code.
> 
> Thankyou for taking your time to go through this.
> 

This looks correct to me. However, it could be changed to get rid
of the checkpatch error. It would be simple fix.

You could send patch in and get feedback from the driver maintainer.

thanks,
-- Shuah


More information about the Linux-kernel-mentees mailing list