Skip to content

Commit 9b6442a

Browse files
Vitaliy Shevtsovcminyard
authored andcommitted
ipmi: make ipmi_destroy_user() return void
Return value of ipmi_destroy_user() has no meaning, because it's always zero and callers can do nothing with it. And in most cases it's not checked. So make this function return void. This also will eliminate static code analyzer warnings such as unreachable code/redundant comparison when the return value is checked against non-zero value. Found by Linux Verification Center (linuxtesting.org) with Svace. Signed-off-by: Vitaliy Shevtsov <v.shevtsov@maxima.ru> Message-ID: <20241225014532.20091-1-v.shevtsov@maxima.ru> Signed-off-by: Corey Minyard <corey@minyard.net>
1 parent 04626c3 commit 9b6442a

File tree

5 files changed

+5
-17
lines changed

5 files changed

+5
-17
lines changed

drivers/char/ipmi/ipmi_devintf.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,9 @@ static int ipmi_open(struct inode *inode, struct file *file)
122122
static int ipmi_release(struct inode *inode, struct file *file)
123123
{
124124
struct ipmi_file_private *priv = file->private_data;
125-
int rv;
126125
struct ipmi_recv_msg *msg, *next;
127126

128-
rv = ipmi_destroy_user(priv->user);
129-
if (rv)
130-
return rv;
127+
ipmi_destroy_user(priv->user);
131128

132129
list_for_each_entry_safe(msg, next, &priv->recv_msgs, link)
133130
ipmi_free_recv_msg(msg);

drivers/char/ipmi/ipmi_msghandler.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1398,13 +1398,11 @@ static void _ipmi_destroy_user(struct ipmi_user *user)
13981398
module_put(owner);
13991399
}
14001400

1401-
int ipmi_destroy_user(struct ipmi_user *user)
1401+
void ipmi_destroy_user(struct ipmi_user *user)
14021402
{
14031403
_ipmi_destroy_user(user);
14041404

14051405
kref_put(&user->refcount, free_user);
1406-
1407-
return 0;
14081406
}
14091407
EXPORT_SYMBOL(ipmi_destroy_user);
14101408

drivers/char/ipmi/ipmi_poweroff.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -699,18 +699,14 @@ static int __init ipmi_poweroff_init(void)
699699
#ifdef MODULE
700700
static void __exit ipmi_poweroff_cleanup(void)
701701
{
702-
int rv;
703-
704702
#ifdef CONFIG_PROC_FS
705703
unregister_sysctl_table(ipmi_table_header);
706704
#endif
707705

708706
ipmi_smi_watcher_unregister(&smi_watcher);
709707

710708
if (ready) {
711-
rv = ipmi_destroy_user(ipmi_user);
712-
if (rv)
713-
pr_err("could not cleanup the IPMI user: 0x%x\n", rv);
709+
ipmi_destroy_user(ipmi_user);
714710
pm_power_off = old_poweroff_func;
715711
}
716712
}

drivers/char/ipmi/ipmi_watchdog.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,7 +1065,6 @@ static void ipmi_register_watchdog(int ipmi_intf)
10651065

10661066
static void ipmi_unregister_watchdog(int ipmi_intf)
10671067
{
1068-
int rv;
10691068
struct ipmi_user *loc_user = watchdog_user;
10701069

10711070
if (!loc_user)
@@ -1090,9 +1089,7 @@ static void ipmi_unregister_watchdog(int ipmi_intf)
10901089
mutex_lock(&ipmi_watchdog_mutex);
10911090

10921091
/* Disconnect from IPMI. */
1093-
rv = ipmi_destroy_user(loc_user);
1094-
if (rv)
1095-
pr_warn("error unlinking from IPMI: %d\n", rv);
1092+
ipmi_destroy_user(loc_user);
10961093

10971094
/* If it comes back, restart it properly. */
10981095
ipmi_start_timer_on_heartbeat = 1;

include/linux/ipmi.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ int ipmi_create_user(unsigned int if_num,
126126
* the users before you destroy the callback structures, it should be
127127
* safe, too.
128128
*/
129-
int ipmi_destroy_user(struct ipmi_user *user);
129+
void ipmi_destroy_user(struct ipmi_user *user);
130130

131131
/* Get the IPMI version of the BMC we are talking to. */
132132
int ipmi_get_version(struct ipmi_user *user,

0 commit comments

Comments
 (0)