diff mbox series

qed: remove an unneed NULL check on list iterator

Message ID 20220405002256.22772-1-xiam0nd.tong@gmail.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series qed: remove an unneed NULL check on list iterator | expand

Checks

Context Check Description
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 6 of 6 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 13 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/tree_selection success Guessing tree name failed - patch did not apply

Commit Message

Xiaomeng Tong April 5, 2022, 12:22 a.m. UTC
The define for_each_pci_dev(d) is:
 while ((d = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, d)) != NULL)

Thus, the list iterator 'd' is always non-NULL so it doesn't need to
be checked. So just remove the unnecessary NULL check. Also remove the
unnecessary initializer because the list iterator is always initialized.

Signed-off-by: Xiaomeng Tong <xiam0nd.tong@gmail.com>
---
 drivers/net/ethernet/qlogic/qed/qed_nvmetcp_ip_services.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Jakub Kicinski April 6, 2022, 1:26 a.m. UTC | #1
On Tue,  5 Apr 2022 08:22:56 +0800 Xiaomeng Tong wrote:
>  struct pci_dev *qed_validate_ndev(struct net_device *ndev)
>  {
> -	struct pci_dev *pdev = NULL;
> +	struct pci_dev *pdev;
>  	struct net_device *upper;

Please keep the longest-to-shortest ordering of variable declaration
lines.
Xiaomeng Tong April 7, 2022, 1:22 a.m. UTC | #2
On Tue, 5 Apr 2022 18:26:41 -0700, Jakub Kicinski wrote:
> On Tue,  5 Apr 2022 08:22:56 +0800 Xiaomeng Tong wrote:
> >  struct pci_dev *qed_validate_ndev(struct net_device *ndev)
> >  {
> > -	struct pci_dev *pdev = NULL;
> > +	struct pci_dev *pdev;
> >  	struct net_device *upper;
> 
> Please keep the longest-to-shortest ordering of variable declaration
> lines.

I have fix it in v2 patch [1], as you suggested. Please check it.
Thank you very much.

[1] https://lore.kernel.org/lkml/20220406015921.29267-1-xiam0nd.tong@gmail.com/
--
Xiaomeng Tong
diff mbox series

Patch

diff --git a/drivers/net/ethernet/qlogic/qed/qed_nvmetcp_ip_services.c b/drivers/net/ethernet/qlogic/qed/qed_nvmetcp_ip_services.c
index 96a2077fd315..37af8395f1bd 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_nvmetcp_ip_services.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_nvmetcp_ip_services.c
@@ -161,11 +161,11 @@  EXPORT_SYMBOL(qed_vlan_get_ndev);
 
 struct pci_dev *qed_validate_ndev(struct net_device *ndev)
 {
-	struct pci_dev *pdev = NULL;
+	struct pci_dev *pdev;
 	struct net_device *upper;
 
 	for_each_pci_dev(pdev) {
-		if (pdev && pdev->driver &&
+		if (pdev->driver &&
 		    !strcmp(pdev->driver->name, "qede")) {
 			upper = pci_get_drvdata(pdev);
 			if (upper->ifindex == ndev->ifindex)