scsi: mptfusion: Remove unnecessary parentheses and simplify null checks
Subsystems (2)
PATCH 1/1 scsi: mptfusion: Remove unnecessary parentheses and simplify null checks
Clang warns when multiple pairs of parentheses are used for a single conditional statement.
drivers/message/fusion/mptbase.c:338:11: warning: equality comparison with extraneous parentheses [-Wparentheses-equality]
if ((ioc == NULL))
~~~~^~~~~~~drivers/message/fusion/mptbase.c:338:11: note: remove extraneous parentheses around the comparison to silence this warning
if ((ioc == NULL))
~ ^ ~drivers/message/fusion/mptbase.c:338:11: note: use '=' to turn this equality comparison into an assignment
if ((ioc == NULL))
^~
=
drivers/message/fusion/mptbase.c:342:12: warning: equality comparison
with extraneous parentheses [-Wparentheses-equality]
if ((pdev == NULL))
~~~~~^~~~~~~drivers/message/fusion/mptbase.c:342:12: note: remove extraneous parentheses around the comparison to silence this warning
if ((pdev == NULL))
~ ^ ~drivers/message/fusion/mptbase.c:342:12: note: use '=' to turn this equality comparison into an assignment
if ((pdev == NULL))
^~
=2 warnings generated.
Remove them and while we're at it, simplify the NULL checks as '!var' is used more than 'var == NULL'.
--- drivers/message/fusion/mptbase.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/message/fusion/mptbase.c +2 -2
@@ -335,11 +335,11 @@ static int mpt_remove_dead_ioc_func(void *arg)MPT_ADAPTER *ioc = (MPT_ADAPTER *)arg;struct pci_dev *pdev; -if ((ioc ==NULL )) +if (!ioc)return -1 ; pdev = ioc->pcidev; -if ((pdev ==NULL )) +if (!pdev)return -1 ;pci_stop_and_remove_bus_device_locked (pdev);
Signature · 1 line
2.18.0
Quoted 30 lines · Nathan Chancellor
Clang warns when multiple pairs of parentheses are used for a single conditional statement.
drivers/message/fusion/mptbase.c:338:11: warning: equality comparison with extraneous parentheses [-Wparentheses-equality]if ((ioc == NULL)) ~~~~^~~~~~~
drivers/message/fusion/mptbase.c:338:11: note: remove extraneous parentheses around the comparison to silence this warning
if ((ioc == NULL))
~ ^ ~drivers/message/fusion/mptbase.c:338:11: note: use '=' to turn this equality comparison into an assignmentif ((ioc == NULL)) ^~ = drivers/message/fusion/mptbase.c:342:12: warning: equality comparison with extraneous parentheses [-Wparentheses-equality] if ((pdev == NULL)) ~~~~~^~~~~~~
drivers/message/fusion/mptbase.c:342:12: note: remove extraneous parentheses around the comparison to silence this warning
if ((pdev == NULL))
~ ^ ~drivers/message/fusion/mptbase.c:342:12: note: use '=' to turn this equality comparison into an assignmentif ((pdev == NULL)) ^~ =
Quoted 7 lines
2 warnings generated.
Remove them and while we're at it, simplify the NULL checks as '!var' is used more than 'var == NULL'.
Reported-by Nick Desaulniers <[email protected]>Signed-off-by Nathan Chancellor <[email protected]>
Nathan,
Thanks for this patch.
Quoted 25 lines
--- drivers/message/fusion/mptbase.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/message/fusion/mptbase.c +2
-3@@ -335,11 +335,11 @@ static int mpt_remove_dead_ioc_func(void *arg)MPT_ADAPTER *ioc = (MPT_ADAPTER *)arg;struct pci_dev *pdev; -if ((ioc ==NULL )) +if (!ioc)return -1 ; pdev = ioc->pcidev; -if ((pdev ==NULL )) +if (!pdev)return -1 ;pci_stop_and_remove_bus_device_locked (pdev); --2.18.0
Signature · 2 lines
Thanks, ~Nick Desaulniers
Martin K. Petersen
AppliedNathan,
Quoted 2 lines
Clang warns when multiple pairs of parentheses are used for a single conditional statement.
Applied to 4.20/scsi-queue. Thank you!
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering
Quoted 15 lines · Nathan Chancellor
Reported-by Nick Desaulniers <[email protected]>Signed-off-by Nathan Chancellor <[email protected]>--- drivers/message/fusion/mptbase.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/message/fusion/mptbase.c +0
-1@@ -335,11 +335,11 @@ static int mpt_remove_dead_ioc_func(void *arg)MPT_ADAPTER *ioc = (MPT_ADAPTER *)arg;struct pci_dev *pdev; -if ((ioc ==NULL ))
drivers/message/fusion/mptbase.c static int mpt_remove_dead_ioc_func(void *arg)
Quoted 10 lines
drivers/message/fusion/mptbase.c +2
-2+if (!ioc)return -1 ; pdev = ioc->pcidev; -if ((pdev ==NULL )) +if (!pdev)return -1 ;pci_stop_and_remove_bus_device_locked (pdev); --
The exact same code also exists in drivers/scsi/mpt3sas/. I had a similar patch for both drivers, but saw that yours now got merged for fusion.
If you don't mind, could you fix mpt3sas_base.c the same way?
Arnd
Quoted 33 lines · Arnd Bergmann
Quoted 15 lines · Nathan Chancellor
Reported-by Nick Desaulniers <[email protected]>Signed-off-by Nathan Chancellor <[email protected]>--- drivers/message/fusion/mptbase.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/message/fusion/mptbase.c +0
-1@@ -335,11 +335,11 @@ static int mpt_remove_dead_ioc_func(void *arg)MPT_ADAPTER *ioc = (MPT_ADAPTER *)arg;struct pci_dev *pdev; -if ((ioc ==NULL ))drivers/message/fusion/mptbase.c static int mpt_remove_dead_ioc_func(void *arg)
Quoted 10 lines
drivers/message/fusion/mptbase.c +2
-2+if (!ioc)return -1 ; pdev = ioc->pcidev; -if ((pdev ==NULL )) +if (!pdev)return -1 ;pci_stop_and_remove_bus_device_locked (pdev); --The exact same code also exists in
drivers/scsi/mpt3sas/. I had a similar patch for both drivers, but saw that yours now got merged for fusion.
Quoted 3 lines
If you don't mind, could you fix
mpt3sas_base.cthe same way?Arnd
Hi Arnd,
I did sent a patch for this a little bit later: https://lore.kernel.org/lkml/[email protected]/
I am still waiting for it to be merged.
Thanks!
Nathan
Nathan,
Quoted 5 lines
Quoted 5 lines
The exact same code also exists in
drivers/scsi/mpt3sas/. I had a similar patch for both drivers, but saw that yours now got merged for fusion.If you don't mind, could you fix
mpt3sas_base.cthe same way?
Quoted 8 lines
Quoted 1 line
Arnd
Hi Arnd,
I did sent a patch for this a little bit later:
https://lore.kernel.org/lkml/[email protected]/I am still waiting for it to be merged.
I generally don't merge patches for drivers that are actively maintained unless the driver maintainer explicitly acks the change. However, this was trivial enough. Applied to 4.20/scsi-queue.
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering