Skip to content

Commit

Permalink
dlm: no need to check return value of debugfs_create functions
Browse files Browse the repository at this point in the history
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.

Signed-off-by: Greg Kroah-Hartman <[email protected]>
Signed-off-by: David Teigland <[email protected]>
  • Loading branch information
gregkh authored and teigland committed Jul 11, 2019
1 parent b355516 commit a48f972
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 27 deletions.
21 changes: 2 additions & 19 deletions fs/dlm/debug_fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@ void dlm_delete_debug_file(struct dlm_ls *ls)
debugfs_remove(ls->ls_debug_toss_dentry);
}

int dlm_create_debug_file(struct dlm_ls *ls)
void dlm_create_debug_file(struct dlm_ls *ls)
{
char name[DLM_LOCKSPACE_LEN + 8];

Expand All @@ -748,8 +748,6 @@ int dlm_create_debug_file(struct dlm_ls *ls)
dlm_root,
ls,
&format1_fops);
if (!ls->ls_debug_rsb_dentry)
goto fail;

/* format 2 */

Expand All @@ -761,8 +759,6 @@ int dlm_create_debug_file(struct dlm_ls *ls)
dlm_root,
ls,
&format2_fops);
if (!ls->ls_debug_locks_dentry)
goto fail;

/* format 3 */

Expand All @@ -774,8 +770,6 @@ int dlm_create_debug_file(struct dlm_ls *ls)
dlm_root,
ls,
&format3_fops);
if (!ls->ls_debug_all_dentry)
goto fail;

/* format 4 */

Expand All @@ -787,8 +781,6 @@ int dlm_create_debug_file(struct dlm_ls *ls)
dlm_root,
ls,
&format4_fops);
if (!ls->ls_debug_toss_dentry)
goto fail;

memset(name, 0, sizeof(name));
snprintf(name, DLM_LOCKSPACE_LEN + 8, "%s_waiters", ls->ls_name);
Expand All @@ -798,21 +790,12 @@ int dlm_create_debug_file(struct dlm_ls *ls)
dlm_root,
ls,
&waiters_fops);
if (!ls->ls_debug_waiters_dentry)
goto fail;

return 0;

fail:
dlm_delete_debug_file(ls);
return -ENOMEM;
}

int __init dlm_register_debugfs(void)
void __init dlm_register_debugfs(void)
{
mutex_init(&debug_buf_lock);
dlm_root = debugfs_create_dir("dlm", NULL);
return dlm_root ? 0 : -ENOMEM;
}

void dlm_unregister_debugfs(void)
Expand Down
8 changes: 4 additions & 4 deletions fs/dlm/dlm_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -719,14 +719,14 @@ int dlm_plock_init(void);
void dlm_plock_exit(void);

#ifdef CONFIG_DLM_DEBUG
int dlm_register_debugfs(void);
void dlm_register_debugfs(void);
void dlm_unregister_debugfs(void);
int dlm_create_debug_file(struct dlm_ls *ls);
void dlm_create_debug_file(struct dlm_ls *ls);
void dlm_delete_debug_file(struct dlm_ls *ls);
#else
static inline int dlm_register_debugfs(void) { return 0; }
static inline void dlm_register_debugfs(void) { }
static inline void dlm_unregister_debugfs(void) { }
static inline int dlm_create_debug_file(struct dlm_ls *ls) { return 0; }
static inline void dlm_create_debug_file(struct dlm_ls *ls) { }
static inline void dlm_delete_debug_file(struct dlm_ls *ls) { }
#endif

Expand Down
5 changes: 1 addition & 4 deletions fs/dlm/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ static int __init init_dlm(void)
if (error)
goto out_lockspace;

error = dlm_register_debugfs();
if (error)
goto out_config;
dlm_register_debugfs();

error = dlm_user_init();
if (error)
Expand All @@ -61,7 +59,6 @@ static int __init init_dlm(void)
dlm_user_exit();
out_debug:
dlm_unregister_debugfs();
out_config:
dlm_config_exit();
out_lockspace:
dlm_lockspace_exit();
Expand Down

0 comments on commit a48f972

Please sign in to comment.