From: Rusty Russell <rusty@rustcorp.com.au>
To: Felipe Contreras <felipe.contreras@gmail.com>,
linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@elte.hu>,
Linus Torvalds <torvalds@linux-foundation.org>,
Andrew Morton <akpm@linux-foundation.org>,
Levente Kurusa <levex@linux.com>,
Alexey Dobriyan <adobriyan@gmail.com>
Subject: Re: [PATCH 5/5] params: improve standard definitions
Date: Thu, 21 Nov 2013 12:13:35 +1030 [thread overview]
Message-ID: <878uwibkc8.fsf@rustcorp.com.au> (raw)
In-Reply-To: <1384623151-31302-6-git-send-email-felipe.contreras@gmail.com>
Felipe Contreras <felipe.contreras@gmail.com> writes:
> We are repeating the functionality of kstrtol in param_set_long, and the
> same for kstrtoint. We can get rid of the extra code by using the right
> functions.
>
> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Thanks, they're new since this code was written. I didn't know about them...
Applied!
Rusty.
> ---
> kernel/params.c | 25 +++++++++----------------
> 1 file changed, 9 insertions(+), 16 deletions(-)
>
> diff --git a/kernel/params.c b/kernel/params.c
> index c00d5b5..48e1a81 100644
> --- a/kernel/params.c
> +++ b/kernel/params.c
> @@ -227,17 +227,10 @@ int parse_args(const char *doing,
> }
>
> /* Lazy bastard, eh? */
> -#define STANDARD_PARAM_DEF(name, type, format, tmptype, strtolfn) \
> +#define STANDARD_PARAM_DEF(name, type, format, strtolfn) \
> int param_set_##name(const char *val, const struct kernel_param *kp) \
> { \
> - tmptype l; \
> - int ret; \
> - \
> - ret = strtolfn(val, 0, &l); \
> - if (ret < 0 || ((type)l != l)) \
> - return ret < 0 ? ret : -EINVAL; \
> - *((type *)kp->arg) = l; \
> - return 0; \
> + return strtolfn(val, 0, (type *)kp->arg); \
> } \
> int param_get_##name(char *buffer, const struct kernel_param *kp) \
> { \
> @@ -253,13 +246,13 @@ int parse_args(const char *doing,
> EXPORT_SYMBOL(param_ops_##name)
>
>
> -STANDARD_PARAM_DEF(byte, unsigned char, "%hhu", unsigned long, kstrtoul);
> -STANDARD_PARAM_DEF(short, short, "%hi", long, kstrtol);
> -STANDARD_PARAM_DEF(ushort, unsigned short, "%hu", unsigned long, kstrtoul);
> -STANDARD_PARAM_DEF(int, int, "%i", long, kstrtol);
> -STANDARD_PARAM_DEF(uint, unsigned int, "%u", unsigned long, kstrtoul);
> -STANDARD_PARAM_DEF(long, long, "%li", long, kstrtol);
> -STANDARD_PARAM_DEF(ulong, unsigned long, "%lu", unsigned long, kstrtoul);
> +STANDARD_PARAM_DEF(byte, unsigned char, "%hhu", kstrtou8);
> +STANDARD_PARAM_DEF(short, short, "%hi", kstrtos16);
> +STANDARD_PARAM_DEF(ushort, unsigned short, "%hu", kstrtou16);
> +STANDARD_PARAM_DEF(int, int, "%i", kstrtoint);
> +STANDARD_PARAM_DEF(uint, unsigned int, "%u", kstrtouint);
> +STANDARD_PARAM_DEF(long, long, "%li", kstrtol);
> +STANDARD_PARAM_DEF(ulong, unsigned long, "%lu", kstrtoul);
>
> int param_set_charp(const char *val, const struct kernel_param *kp)
> {
> --
> 1.8.4.2+fc1
prev parent reply other threads:[~2013-11-21 5:14 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-16 17:32 [PATCH 0/5] Command line related cleanups Felipe Contreras
2013-11-16 17:32 ` [PATCH 1/5] kstrtox: remove redundant cleanup Felipe Contreras
2013-11-16 20:19 ` Levente Kurusa
2013-11-16 17:32 ` [PATCH 2/5] cmdline: fix style issues Felipe Contreras
2013-11-16 17:32 ` [PATCH 3/5] cmdline: declare exported symbols immediately Felipe Contreras
2013-11-16 20:21 ` Levente Kurusa
2013-11-16 20:27 ` Felipe Contreras
2013-11-16 17:32 ` [PATCH 4/5] kstrtox: remove redundant casts Felipe Contreras
2013-11-16 17:32 ` [PATCH 5/5] params: improve standard definitions Felipe Contreras
2013-11-21 1:43 ` Rusty Russell [this message]
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=878uwibkc8.fsf@rustcorp.com.au \
--to=rusty@rustcorp.com.au \
--cc=adobriyan@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=felipe.contreras@gmail.com \
--cc=levex@linux.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=torvalds@linux-foundation.org \
/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