ntb.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH] ntb: hw: intel: remove return value check of `ndev_init_debugfs`
@ 2023-04-22 15:56 Yinhao Hu
  2023-04-24 15:33 ` Dave Jiang
  0 siblings, 1 reply; 2+ messages in thread
From: Yinhao Hu @ 2023-04-22 15:56 UTC (permalink / raw)
  To: Dave Jiang, Jon Mason, Allen Hubbe
  Cc: hust-os-kernel-patches, Yinhao Hu, Dongliang Mu, ntb, linux-kernel

Smatch complains that:
ndev_init_debugfs() warn: 'ndev->debugfs_dir' is an error pointer or valid

Debugfs checks are generally not supposed to be checked for errors
and it is not necessary here.

Just delete the dead code.

Signed-off-by: Yinhao Hu <dddddd@hust.edu.cn>
Reviewed-by: Dongliang Mu <dzm91@hust.edu.cn>
---
The issue is found by static analysis and remains untested.
---
 drivers/ntb/hw/intel/ntb_hw_gen1.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/ntb/hw/intel/ntb_hw_gen1.c b/drivers/ntb/hw/intel/ntb_hw_gen1.c
index 9ab836d0d4f1..9b0b2c43f1bb 100644
--- a/drivers/ntb/hw/intel/ntb_hw_gen1.c
+++ b/drivers/ntb/hw/intel/ntb_hw_gen1.c
@@ -778,13 +778,10 @@ static void ndev_init_debugfs(struct intel_ntb_dev *ndev)
 		ndev->debugfs_dir =
 			debugfs_create_dir(pci_name(ndev->ntb.pdev),
 					   debugfs_dir);
-		if (!ndev->debugfs_dir)
-			ndev->debugfs_info = NULL;
-		else
-			ndev->debugfs_info =
-				debugfs_create_file("info", S_IRUSR,
-						    ndev->debugfs_dir, ndev,
-						    &intel_ntb_debugfs_info);
+		ndev->debugfs_info =
+			debugfs_create_file("info", S_IRUSR,
+					    ndev->debugfs_dir, ndev,
+					    &intel_ntb_debugfs_info);
 	}
 }
 
-- 
2.34.1


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

* Re: [PATCH] ntb: hw: intel: remove return value check of `ndev_init_debugfs`
  2023-04-22 15:56 [PATCH] ntb: hw: intel: remove return value check of `ndev_init_debugfs` Yinhao Hu
@ 2023-04-24 15:33 ` Dave Jiang
  0 siblings, 0 replies; 2+ messages in thread
From: Dave Jiang @ 2023-04-24 15:33 UTC (permalink / raw)
  To: Yinhao Hu, Jon Mason, Allen Hubbe
  Cc: hust-os-kernel-patches, Dongliang Mu, ntb, linux-kernel



On 4/22/23 8:56 AM, Yinhao Hu wrote:
> Smatch complains that:
> ndev_init_debugfs() warn: 'ndev->debugfs_dir' is an error pointer or valid
> 
> Debugfs checks are generally not supposed to be checked for errors
> and it is not necessary here.

Can you please provide source on where this is true?

> 
> Just delete the dead code.
> 
> Signed-off-by: Yinhao Hu <dddddd@hust.edu.cn>
> Reviewed-by: Dongliang Mu <dzm91@hust.edu.cn>
> ---
> The issue is found by static analysis and remains untested.
> ---
>   drivers/ntb/hw/intel/ntb_hw_gen1.c | 11 ++++-------
>   1 file changed, 4 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/ntb/hw/intel/ntb_hw_gen1.c b/drivers/ntb/hw/intel/ntb_hw_gen1.c
> index 9ab836d0d4f1..9b0b2c43f1bb 100644
> --- a/drivers/ntb/hw/intel/ntb_hw_gen1.c
> +++ b/drivers/ntb/hw/intel/ntb_hw_gen1.c
> @@ -778,13 +778,10 @@ static void ndev_init_debugfs(struct intel_ntb_dev *ndev)
>   		ndev->debugfs_dir =
>   			debugfs_create_dir(pci_name(ndev->ntb.pdev),
>   					   debugfs_dir);
> -		if (!ndev->debugfs_dir)
> -			ndev->debugfs_info = NULL;
> -		else
> -			ndev->debugfs_info =
> -				debugfs_create_file("info", S_IRUSR,
> -						    ndev->debugfs_dir, ndev,
> -						    &intel_ntb_debugfs_info);
> +		ndev->debugfs_info =
> +			debugfs_create_file("info", S_IRUSR,
> +					    ndev->debugfs_dir, ndev,
> +					    &intel_ntb_debugfs_info);
>   	}
>   }
>   

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

end of thread, other threads:[~2023-04-24 15:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-22 15:56 [PATCH] ntb: hw: intel: remove return value check of `ndev_init_debugfs` Yinhao Hu
2023-04-24 15:33 ` Dave Jiang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).