[PATCH 6/7] crypto: ccp: no need to check return value of debugfs_create functions

2019-01-22 Thread Greg Kroah-Hartman
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: Tom Lendacky 
Cc: Gary Hook 
Cc: Herbert Xu 
Cc: "David S. Miller" 
Cc: linux-cry...@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/crypto/ccp/ccp-debugfs.c | 36 +++-
 1 file changed, 7 insertions(+), 29 deletions(-)

diff --git a/drivers/crypto/ccp/ccp-debugfs.c b/drivers/crypto/ccp/ccp-debugfs.c
index 1a734bd2070a..4bd26af7098d 100644
--- a/drivers/crypto/ccp/ccp-debugfs.c
+++ b/drivers/crypto/ccp/ccp-debugfs.c
@@ -286,10 +286,7 @@ void ccp5_debugfs_setup(struct ccp_device *ccp)
 {
struct ccp_cmd_queue *cmd_q;
char name[MAX_NAME_LEN + 1];
-   struct dentry *debugfs_info;
-   struct dentry *debugfs_stats;
struct dentry *debugfs_q_instance;
-   struct dentry *debugfs_q_stats;
int i;
 
if (!debugfs_initialized())
@@ -299,24 +296,14 @@ void ccp5_debugfs_setup(struct ccp_device *ccp)
if (!ccp_debugfs_dir)
ccp_debugfs_dir = debugfs_create_dir(KBUILD_MODNAME, NULL);
mutex_unlock(&ccp_debugfs_lock);
-   if (!ccp_debugfs_dir)
-   return;
 
ccp->debugfs_instance = debugfs_create_dir(ccp->name, ccp_debugfs_dir);
-   if (!ccp->debugfs_instance)
-   goto err;
 
-   debugfs_info = debugfs_create_file("info", 0400,
-  ccp->debugfs_instance, ccp,
-  &ccp_debugfs_info_ops);
-   if (!debugfs_info)
-   goto err;
+   debugfs_create_file("info", 0400, ccp->debugfs_instance, ccp,
+   &ccp_debugfs_info_ops);
 
-   debugfs_stats = debugfs_create_file("stats", 0600,
-   ccp->debugfs_instance, ccp,
-   &ccp_debugfs_stats_ops);
-   if (!debugfs_stats)
-   goto err;
+   debugfs_create_file("stats", 0600, ccp->debugfs_instance, ccp,
+   &ccp_debugfs_stats_ops);
 
for (i = 0; i < ccp->cmd_q_count; i++) {
cmd_q = &ccp->cmd_q[i];
@@ -325,21 +312,12 @@ void ccp5_debugfs_setup(struct ccp_device *ccp)
 
debugfs_q_instance =
debugfs_create_dir(name, ccp->debugfs_instance);
-   if (!debugfs_q_instance)
-   goto err;
-
-   debugfs_q_stats =
-   debugfs_create_file("stats", 0600,
-   debugfs_q_instance, cmd_q,
-   &ccp_debugfs_queue_ops);
-   if (!debugfs_q_stats)
-   goto err;
+
+   debugfs_create_file("stats", 0600, debugfs_q_instance, cmd_q,
+   &ccp_debugfs_queue_ops);
}
 
return;
-
-err:
-   debugfs_remove_recursive(ccp->debugfs_instance);
 }
 
 void ccp5_debugfs_destroy(void)
-- 
2.20.1



Re: [PATCH 6/7] crypto: ccp: no need to check return value of debugfs_create functions

2019-01-22 Thread Gary R Hook
On 1/22/19 9:14 AM, 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.

Stupid question(s) time.

If we don't care about failures (because the subsystem handles them 
without our involvement) why do these functions even have return values? 
Why haven't they been changed to void so that they reflect the current 
style of intended use?

I realize I'm old fashioned, but if a failure occurs, I've always been 
of a mind to kick out and not try to do any further work. But debugfs is 
to be treated as an exception to that paradigm? Carry on, ignore errors, 
don't worry about it?

That said,

Acked-by: Gary R Hook 

> 
> Cc: Tom Lendacky 
> Cc: Gary Hook 
> Cc: Herbert Xu 
> Cc: "David S. Miller" 
> Cc: linux-cry...@vger.kernel.org
> Signed-off-by: Greg Kroah-Hartman 
> ---
>   drivers/crypto/ccp/ccp-debugfs.c | 36 +++-
>   1 file changed, 7 insertions(+), 29 deletions(-)
> 
> diff --git a/drivers/crypto/ccp/ccp-debugfs.c 
> b/drivers/crypto/ccp/ccp-debugfs.c
> index 1a734bd2070a..4bd26af7098d 100644
> --- a/drivers/crypto/ccp/ccp-debugfs.c
> +++ b/drivers/crypto/ccp/ccp-debugfs.c
> @@ -286,10 +286,7 @@ void ccp5_debugfs_setup(struct ccp_device *ccp)
>   {
>   struct ccp_cmd_queue *cmd_q;
>   char name[MAX_NAME_LEN + 1];
> - struct dentry *debugfs_info;
> - struct dentry *debugfs_stats;
>   struct dentry *debugfs_q_instance;
> - struct dentry *debugfs_q_stats;
>   int i;
>   
>   if (!debugfs_initialized())
> @@ -299,24 +296,14 @@ void ccp5_debugfs_setup(struct ccp_device *ccp)
>   if (!ccp_debugfs_dir)
>   ccp_debugfs_dir = debugfs_create_dir(KBUILD_MODNAME, NULL);
>   mutex_unlock(&ccp_debugfs_lock);
> - if (!ccp_debugfs_dir)
> - return;
>   
>   ccp->debugfs_instance = debugfs_create_dir(ccp->name, ccp_debugfs_dir);
> - if (!ccp->debugfs_instance)
> - goto err;
>   
> - debugfs_info = debugfs_create_file("info", 0400,
> -ccp->debugfs_instance, ccp,
> -&ccp_debugfs_info_ops);
> - if (!debugfs_info)
> - goto err;
> + debugfs_create_file("info", 0400, ccp->debugfs_instance, ccp,
> + &ccp_debugfs_info_ops);
>   
> - debugfs_stats = debugfs_create_file("stats", 0600,
> - ccp->debugfs_instance, ccp,
> - &ccp_debugfs_stats_ops);
> - if (!debugfs_stats)
> - goto err;
> + debugfs_create_file("stats", 0600, ccp->debugfs_instance, ccp,
> + &ccp_debugfs_stats_ops);
>   
>   for (i = 0; i < ccp->cmd_q_count; i++) {
>   cmd_q = &ccp->cmd_q[i];
> @@ -325,21 +312,12 @@ void ccp5_debugfs_setup(struct ccp_device *ccp)
>   
>   debugfs_q_instance =
>   debugfs_create_dir(name, ccp->debugfs_instance);
> - if (!debugfs_q_instance)
> - goto err;
> -
> - debugfs_q_stats =
> - debugfs_create_file("stats", 0600,
> - debugfs_q_instance, cmd_q,
> - &ccp_debugfs_queue_ops);
> - if (!debugfs_q_stats)
> - goto err;
> +
> + debugfs_create_file("stats", 0600, debugfs_q_instance, cmd_q,
> + &ccp_debugfs_queue_ops);
>   }
>   
>   return;
> -
> -err:
> - debugfs_remove_recursive(ccp->debugfs_instance);
>   }
>   
>   void ccp5_debugfs_destroy(void)
> 



Re: [PATCH 6/7] crypto: ccp: no need to check return value of debugfs_create functions

2019-01-22 Thread Greg Kroah-Hartman
On Tue, Jan 22, 2019 at 10:06:54PM +, Gary R Hook wrote:
> On 1/22/19 9:14 AM, 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.
> 
> Stupid question(s) time.
> 
> If we don't care about failures (because the subsystem handles them 
> without our involvement) why do these functions even have return values? 
> Why haven't they been changed to void so that they reflect the current 
> style of intended use?

Because on "normal" operations, you use the return value for something
(i.e. a parent directory to pass to other functions, or a value so you
can remove the file later).

> I realize I'm old fashioned, but if a failure occurs, I've always been 
> of a mind to kick out and not try to do any further work. But debugfs is 
> to be treated as an exception to that paradigm? Carry on, ignore errors, 
> don't worry about it?

Yes, that is the case here, it goes against what everyone normally
thinks about kernel development :)

thanks,

greg k-h