From: Andy Shevchenko Date: Fri, 2 Apr 2021 17:43:32 +0000 (+0300) Subject: ipmi_si: Use strstrip() to remove surrounding spaces X-Git-Tag: v5.13-rc1~110^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d14ce8c7708766a75fcb0ceca69cabcadfad9e43;p=thirdparty%2Flinux.git ipmi_si: Use strstrip() to remove surrounding spaces Instead of home grown analogue, use strstrip() from the kernel library. Signed-off-by: Andy Shevchenko Message-Id: <20210402174334.13466-9-andriy.shevchenko@linux.intel.com> Signed-off-by: Corey Minyard --- diff --git a/drivers/char/ipmi/ipmi_si_hotmod.c b/drivers/char/ipmi/ipmi_si_hotmod.c index 4fbb4e18bae21..087f5eb1ebc0d 100644 --- a/drivers/char/ipmi/ipmi_si_hotmod.c +++ b/drivers/char/ipmi/ipmi_si_hotmod.c @@ -185,24 +185,16 @@ static atomic_t hotmod_nr; static int hotmod_handler(const char *val, const struct kernel_param *kp) { - char *str = kstrdup(val, GFP_KERNEL), *curr, *next; int rv; struct ipmi_plat_data h; - unsigned int len; - int ival; + char *str, *curr, *next; + str = kstrdup(val, GFP_KERNEL); if (!str) return -ENOMEM; /* Kill any trailing spaces, as we can get a "\n" from echo. */ - len = strlen(str); - ival = len - 1; - while ((ival >= 0) && isspace(str[ival])) { - str[ival] = '\0'; - ival--; - } - - for (curr = str; curr; curr = next) { + for (curr = strstrip(str); curr; curr = next) { enum hotmod_op op; next = strchr(curr, ':'); @@ -235,7 +227,7 @@ static int hotmod_handler(const char *val, const struct kernel_param *kp) put_device(dev); } } - rv = len; + rv = strlen(val); out: kfree(str); return rv;