Re: [PATCH] btrfs: no need to check return value of debugfs_create functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jan 04, 2019 at 02:44:49PM +0100, David Sterba wrote:
> On Fri, Jan 04, 2019 at 02:25:20PM +0100, Greg Kroah-Hartman wrote:
> > When calling debugfs functions, there is no need to ever check the
> > return value.  The function can work or not, but the code logic should
> > never do something different based on this.
> > 
> > Cc: Chris Mason <clm@xxxxxx>
> > Cc: Josef Bacik <josef@xxxxxxxxxxxxxx>
> > Cc: David Sterba <dsterba@xxxxxxxx>
> > Cc: linux-btrfs@xxxxxxxxxxxxxxx
> > Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
> > ---
> >  fs/btrfs/sysfs.c | 10 ++--------
> >  1 file changed, 2 insertions(+), 8 deletions(-)
> > 
> > Meta-comment, why is there a btrfs debugfs directory at all?  All you
> > have here is a single "test" file that doesn't do anything except expose
> > a variable that never changes.  What is this directory and single file
> > for?  Can I just delete the whole thing?
> 
> As explained in the commit that introduces the function
> (1bae30982bc86ab66d61ccb):
> 
>   Help during debugging to export various interesting infromation and
>   tunables without the need of extra mount options or ioctls.
> 
>   Usage:
>   * declare your variable in sysfs.h, and include where you need it
>   * define the variable in sysfs.c and make it visible via
>     debugfs_create_TYPE
> 
>   Depends on CONFIG_DEBUG_FS.
> 
> It's there for developers, so don't delete it. Which also means the
> error code should be handled and not ignored.

If no one has used it, why keep it?

Anyway, if you want it there, that's fine, but no, the error message can
be ignored.  You should never have a different code flow if a debugfs
call fails or not.  So the patch I posted here is still correct and
should be applied.

> I can enhance the comment so it's explained in-place and not too
> tempting to remove it. This is not the first time somebody wants to
> remove it
> (https://lore.kernel.org/linux-btrfs/d6715b5b-0aa3-3032-43c6-eccd907a60b8@xxxxxxxxxx/),

If it keeps wanting to get removed, that's a big hint maybe you should :)

thanks,

greg k-h



[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux