diff mbox series

[net-next,3/5] bonding: remove unnecessary NULL check in debugfs function

Message ID 20230809124107.360574-4-shaozhengchao@huawei.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series bonding: do some cleanups in bond driver | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1330 this patch: 1330
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 1353 this patch: 1353
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 1353 this patch: 1353
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 27 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

shaozhengchao Aug. 9, 2023, 12:41 p.m. UTC
Because debugfs_create_dir returns ERR_PTR, so bonding_debug_root will
never be NULL. Remove unnecessary NULL check for bonding_debug_root in
debugfs function.

Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
---
 drivers/net/bonding/bond_debugfs.c | 9 ---------
 1 file changed, 9 deletions(-)

Comments

Jay Vosburgh Aug. 9, 2023, 4:13 p.m. UTC | #1
On 8/9/23, Zhengchao Shao <shaozhengchao@huawei.com> wrote:
> Because debugfs_create_dir returns ERR_PTR, so bonding_debug_root will
> never be NULL. Remove unnecessary NULL check for bonding_debug_root in
> debugfs function.

So after this change it will call debugfs_create_dir(), et al, with
the ERR_PTR value?  Granted, the current behavior is probably not
right, but I don't see how this makes things better.

-J

>
> Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
> ---
>  drivers/net/bonding/bond_debugfs.c | 9 ---------
>  1 file changed, 9 deletions(-)
>
> diff --git a/drivers/net/bonding/bond_debugfs.c
> b/drivers/net/bonding/bond_debugfs.c
> index e4e7f4ee48e0..4c83f89c0a47 100644
> --- a/drivers/net/bonding/bond_debugfs.c
> +++ b/drivers/net/bonding/bond_debugfs.c
> @@ -49,9 +49,6 @@ DEFINE_SHOW_ATTRIBUTE(bond_debug_rlb_hash);
>
>  void bond_debug_register(struct bonding *bond)
>  {
> -	if (!bonding_debug_root)
> -		return;
> -
>  	bond->debug_dir =
>  		debugfs_create_dir(bond->dev->name, bonding_debug_root);
>
> @@ -61,9 +58,6 @@ void bond_debug_register(struct bonding *bond)
>
>  void bond_debug_unregister(struct bonding *bond)
>  {
> -	if (!bonding_debug_root)
> -		return;
> -
>  	debugfs_remove_recursive(bond->debug_dir);
>  }
>
> @@ -71,9 +65,6 @@ void bond_debug_reregister(struct bonding *bond)
>  {
>  	struct dentry *d;
>
> -	if (!bonding_debug_root)
> -		return;
> -
>  	d = debugfs_rename(bonding_debug_root, bond->debug_dir,
>  			   bonding_debug_root, bond->dev->name);
>  	if (!IS_ERR(d)) {
> --
> 2.34.1
>
>
Hangbin Liu Aug. 10, 2023, 3:08 a.m. UTC | #2
On Wed, Aug 09, 2023 at 09:13:31AM -0700, Jay Vosburgh wrote:
> On 8/9/23, Zhengchao Shao <shaozhengchao@huawei.com> wrote:
> > Because debugfs_create_dir returns ERR_PTR, so bonding_debug_root will
> > never be NULL. Remove unnecessary NULL check for bonding_debug_root in
> > debugfs function.
> 
> So after this change it will call debugfs_create_dir(), et al, with
> the ERR_PTR value?  Granted, the current behavior is probably not
> right, but I don't see how this makes things better.

I guess Zhengchao means to remove Redundant checks? The later
debugfs_create_dir/debugfs_remove_recursive/debugfs_remove_recursive functions
will check the dentry with IS_ERR(). But I think the commit description need
an update.

Hangbin

> 
> -J
> 
> >
> > Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
> > ---
> >  drivers/net/bonding/bond_debugfs.c | 9 ---------
> >  1 file changed, 9 deletions(-)
> >
> > diff --git a/drivers/net/bonding/bond_debugfs.c
> > b/drivers/net/bonding/bond_debugfs.c
> > index e4e7f4ee48e0..4c83f89c0a47 100644
> > --- a/drivers/net/bonding/bond_debugfs.c
> > +++ b/drivers/net/bonding/bond_debugfs.c
> > @@ -49,9 +49,6 @@ DEFINE_SHOW_ATTRIBUTE(bond_debug_rlb_hash);
> >
> >  void bond_debug_register(struct bonding *bond)
> >  {
> > -	if (!bonding_debug_root)
> > -		return;
> > -
> >  	bond->debug_dir =
> >  		debugfs_create_dir(bond->dev->name, bonding_debug_root);
> >
> > @@ -61,9 +58,6 @@ void bond_debug_register(struct bonding *bond)
> >
> >  void bond_debug_unregister(struct bonding *bond)
> >  {
> > -	if (!bonding_debug_root)
> > -		return;
> > -
> >  	debugfs_remove_recursive(bond->debug_dir);
> >  }
> >
> > @@ -71,9 +65,6 @@ void bond_debug_reregister(struct bonding *bond)
> >  {
> >  	struct dentry *d;
> >
> > -	if (!bonding_debug_root)
> > -		return;
> > -
> >  	d = debugfs_rename(bonding_debug_root, bond->debug_dir,
> >  			   bonding_debug_root, bond->dev->name);
> >  	if (!IS_ERR(d)) {
> > --
> > 2.34.1
> >
> >
shaozhengchao Aug. 10, 2023, 8:08 a.m. UTC | #3
On 2023/8/10 11:08, Hangbin Liu wrote:
> On Wed, Aug 09, 2023 at 09:13:31AM -0700, Jay Vosburgh wrote:
>> On 8/9/23, Zhengchao Shao <shaozhengchao@huawei.com> wrote:
>>> Because debugfs_create_dir returns ERR_PTR, so bonding_debug_root will
>>> never be NULL. Remove unnecessary NULL check for bonding_debug_root in
>>> debugfs function.
>>
>> So after this change it will call debugfs_create_dir(), et al, with
>> the ERR_PTR value?  Granted, the current behavior is probably not
>> right, but I don't see how this makes things better.
> 
> I guess Zhengchao means to remove Redundant checks? The later
> debugfs_create_dir/debugfs_remove_recursive/debugfs_remove_recursive functions
> will check the dentry with IS_ERR(). But I think the commit description need
> an update.
> 
> Hangbin
> 
Yes, I will update this commit description.

Zhengchao Shao
>>
>> -J
>>
>>>
>>> Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
>>> ---
>>>   drivers/net/bonding/bond_debugfs.c | 9 ---------
>>>   1 file changed, 9 deletions(-)
>>>
>>> diff --git a/drivers/net/bonding/bond_debugfs.c
>>> b/drivers/net/bonding/bond_debugfs.c
>>> index e4e7f4ee48e0..4c83f89c0a47 100644
>>> --- a/drivers/net/bonding/bond_debugfs.c
>>> +++ b/drivers/net/bonding/bond_debugfs.c
>>> @@ -49,9 +49,6 @@ DEFINE_SHOW_ATTRIBUTE(bond_debug_rlb_hash);
>>>
>>>   void bond_debug_register(struct bonding *bond)
>>>   {
>>> -	if (!bonding_debug_root)
>>> -		return;
>>> -
>>>   	bond->debug_dir =
>>>   		debugfs_create_dir(bond->dev->name, bonding_debug_root);
>>>
>>> @@ -61,9 +58,6 @@ void bond_debug_register(struct bonding *bond)
>>>
>>>   void bond_debug_unregister(struct bonding *bond)
>>>   {
>>> -	if (!bonding_debug_root)
>>> -		return;
>>> -
>>>   	debugfs_remove_recursive(bond->debug_dir);
>>>   }
>>>
>>> @@ -71,9 +65,6 @@ void bond_debug_reregister(struct bonding *bond)
>>>   {
>>>   	struct dentry *d;
>>>
>>> -	if (!bonding_debug_root)
>>> -		return;
>>> -
>>>   	d = debugfs_rename(bonding_debug_root, bond->debug_dir,
>>>   			   bonding_debug_root, bond->dev->name);
>>>   	if (!IS_ERR(d)) {
>>> --
>>> 2.34.1
>>>
>>>
diff mbox series

Patch

diff --git a/drivers/net/bonding/bond_debugfs.c b/drivers/net/bonding/bond_debugfs.c
index e4e7f4ee48e0..4c83f89c0a47 100644
--- a/drivers/net/bonding/bond_debugfs.c
+++ b/drivers/net/bonding/bond_debugfs.c
@@ -49,9 +49,6 @@  DEFINE_SHOW_ATTRIBUTE(bond_debug_rlb_hash);
 
 void bond_debug_register(struct bonding *bond)
 {
-	if (!bonding_debug_root)
-		return;
-
 	bond->debug_dir =
 		debugfs_create_dir(bond->dev->name, bonding_debug_root);
 
@@ -61,9 +58,6 @@  void bond_debug_register(struct bonding *bond)
 
 void bond_debug_unregister(struct bonding *bond)
 {
-	if (!bonding_debug_root)
-		return;
-
 	debugfs_remove_recursive(bond->debug_dir);
 }
 
@@ -71,9 +65,6 @@  void bond_debug_reregister(struct bonding *bond)
 {
 	struct dentry *d;
 
-	if (!bonding_debug_root)
-		return;
-
 	d = debugfs_rename(bonding_debug_root, bond->debug_dir,
 			   bonding_debug_root, bond->dev->name);
 	if (!IS_ERR(d)) {