Re: [PATCH -next] platform/olpc: Remove redundant null pointer checks in olpc_ec_setup_debugfs()

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

 



Hi Li,

On 9/3/24 4:37 PM, Li Zetao wrote:
> Since the debugfs_create_dir() never returns a null pointer, checking
> the return value for a null pointer is redundant, and using IS_ERR is
> safe enough.
> 
> Signed-off-by: Li Zetao <lizetao1@xxxxxxxxxx>

debugfs functions like debugfs_create_file() explicitly allow
being called with a ERR_PTR() style pointer and then turn
the call into a no-op to make using them more easy and because
debugfs errors are considered non critical.

The idea is that drivers can simply use debugfs without any
error checking at all. So the correct thing to do here would
be to completely drop the error checking like how e.g. :

drivers/platform/x86/dell/dell-laptop.c

also does no error checking.

Regards,

Hans



> ---
>  drivers/platform/olpc/olpc-ec.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/platform/olpc/olpc-ec.c b/drivers/platform/olpc/olpc-ec.c
> index 921520475ff6..66287a2ddbf3 100644
> --- a/drivers/platform/olpc/olpc-ec.c
> +++ b/drivers/platform/olpc/olpc-ec.c
> @@ -332,7 +332,7 @@ static struct dentry *olpc_ec_setup_debugfs(void)
>  	struct dentry *dbgfs_dir;
>  
>  	dbgfs_dir = debugfs_create_dir("olpc-ec", NULL);
> -	if (IS_ERR_OR_NULL(dbgfs_dir))
> +	if (IS_ERR(dbgfs_dir))
>  		return NULL;
>  
>  	debugfs_create_file("cmd", 0600, dbgfs_dir, NULL, &ec_dbgfs_ops);





[Index of Archives]     [Linux Kernel Development]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux