From: LABBE Corentin <clabbe.montjoie@gmail.com>
To: minyard@acm.org, openipmi-developer@lists.sourceforge.net
Cc: LABBE Corentin <clabbe.montjoie@gmail.com>, linux-kernel@vger.kernel.org
Subject: [PATCH 4/4] ipmi: replace simple_strtoul by kstrtox
Date: Wed, 25 Nov 2015 14:43:25 +0100 [thread overview]
Message-ID: <1448459006-6118-4-git-send-email-clabbe.montjoie@gmail.com> (raw)
In-Reply-To: <1448459006-6118-1-git-send-email-clabbe.montjoie@gmail.com>
The simple_strtoul function is marked as obsolete.
This patch replace it by kstrtoint/kstrtoul.
This will simplify code, since some error case not handled by
simple_strtoul are handled by kstrtox.
Signed-off-by: LABBE Corentin <clabbe.montjoie@gmail.com>
---
drivers/char/ipmi/ipmi_si_intf.c | 15 ++++++++-------
drivers/char/ipmi/ipmi_watchdog.c | 8 ++++----
2 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
index d1fc200..48bab38 100644
--- a/drivers/char/ipmi/ipmi_si_intf.c
+++ b/drivers/char/ipmi/ipmi_si_intf.c
@@ -1775,17 +1775,17 @@ static int parse_str(const struct hotmod_vals *v, int *val, char *name,
static int check_hotmod_int_op(const char *curr, const char *option,
const char *name, int *val)
{
- char *n;
+ int err;
if (strcmp(curr, name) == 0) {
if (!option) {
pr_warn(PFX "No option given for '%s'\n", curr);
return -EINVAL;
}
- *val = simple_strtoul(option, &n, 0);
- if ((*n != '\0') || (*option == '\0')) {
+ err = kstrtoint(option, 0, val);
+ if (err) {
pr_warn(PFX "Bad option given for '%s'\n", curr);
- return -EINVAL;
+ return err;
}
return 1;
}
@@ -1805,7 +1805,7 @@ static int hotmod_handler(const char *val, struct kernel_param *kp)
{
char *str = kstrdup(val, GFP_KERNEL);
int rv;
- char *next, *curr, *s, *n, *o;
+ char *next, *curr, *s, *o;
enum hotmod_op op;
enum si_type si_type;
int addr_space;
@@ -1817,6 +1817,7 @@ static int hotmod_handler(const char *val, struct kernel_param *kp)
int ipmb;
int ival;
int len;
+ int err;
struct smi_info *info;
if (!str)
@@ -1862,8 +1863,8 @@ static int hotmod_handler(const char *val, struct kernel_param *kp)
*s = '\0';
s++;
}
- addr = simple_strtoul(curr, &n, 0);
- if ((*n != '\0') || (*curr == '\0')) {
+ err = kstrtoul(curr, 0, &addr);
+ if (err) {
pr_warn(PFX "Invalid hotmod address '%s'\n", curr);
break;
}
diff --git a/drivers/char/ipmi/ipmi_watchdog.c b/drivers/char/ipmi/ipmi_watchdog.c
index 096f0ce..2f0d2c4 100644
--- a/drivers/char/ipmi/ipmi_watchdog.c
+++ b/drivers/char/ipmi/ipmi_watchdog.c
@@ -194,15 +194,15 @@ static int start_now;
static int set_param_timeout(const char *val, const struct kernel_param *kp)
{
- char *endp;
+ int err;
int l;
int rv = 0;
if (!val)
return -EINVAL;
- l = simple_strtoul(val, &endp, 0);
- if (endp == val)
- return -EINVAL;
+ err = kstrtoint(val, 0, &l);
+ if (err)
+ return err;
*((int *)kp->arg) = l;
if (watchdog_user)
--
2.4.10
next prev parent reply other threads:[~2015-11-25 13:43 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-25 13:43 [PATCH 1/4] ipmi: constify the name parameter of ipmi_smi_add_proc_entry LABBE Corentin
2015-11-25 13:43 ` [PATCH 2/4] ipmi: constify the reason parameter of start_error_recovery LABBE Corentin
2015-11-25 13:43 ` LABBE Corentin [this message]
2015-11-25 14:29 ` [PATCH 3/4] ipmi: Replace all printk(KERN_xxx by their pr_xxx counterpart LABBE Corentin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1448459006-6118-4-git-send-email-clabbe.montjoie@gmail.com \
--to=clabbe.montjoie@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=minyard@acm.org \
--cc=openipmi-developer@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®