All of lore.kernel.org
 help / color / mirror / Atom feed
* [QUERY]drivers: pnp: isapnp:proc.c: assignment inside if statement
@ 2021-04-20 18:05 ` anupamakpatil123
  0 siblings, 0 replies; 4+ messages in thread
From: anupamakpatil123 @ 2021-04-20 18:05 UTC (permalink / raw)
  To: kernelnewbies; +Cc: bkkarthik, linux-kernel-mentees


[-- Attachment #1.1: Type: text/plain, Size: 719 bytes --]

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.

Anupama K Patil

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

[-- Attachment #2: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [QUERY]drivers: pnp: isapnp:proc.c: assignment inside if statement
@ 2021-04-20 18:05 ` anupamakpatil123
  0 siblings, 0 replies; 4+ messages in thread
From: anupamakpatil123 @ 2021-04-20 18:05 UTC (permalink / raw)
  To: kernelnewbies; +Cc: bkkarthik, linux-kernel-mentees


[-- Attachment #1.1: Type: text/plain, Size: 719 bytes --]

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.

Anupama K Patil

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

[-- Attachment #2: Type: text/plain, Size: 170 bytes --]

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [QUERY]drivers: pnp: isapnp:proc.c: assignment inside if statement
  2021-04-20 18:05 ` anupamakpatil123
@ 2021-04-21  0:34   ` Shuah Khan
  -1 siblings, 0 replies; 4+ messages in thread
From: Shuah Khan @ 2021-04-21  0:34 UTC (permalink / raw)
  To: anupamakpatil123, kernelnewbies; +Cc: linux-kernel-mentees, bkkarthik

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
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [QUERY]drivers: pnp: isapnp:proc.c: assignment inside if statement
@ 2021-04-21  0:34   ` Shuah Khan
  0 siblings, 0 replies; 4+ messages in thread
From: Shuah Khan @ 2021-04-21  0:34 UTC (permalink / raw)
  To: anupamakpatil123, kernelnewbies
  Cc: linux-kernel-mentees, bkkarthik, Shuah Khan

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

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-04-26  3:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-20 18:05 [QUERY]drivers: pnp: isapnp:proc.c: assignment inside if statement anupamakpatil123
2021-04-20 18:05 ` anupamakpatil123
2021-04-21  0:34 ` Shuah Khan
2021-04-21  0:34   ` Shuah Khan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.