* [PATCH] lib/cmdline.c: add to the get_options() documentation
@ 2017-08-21 9:46 Dan Carpenter
2017-08-21 10:42 ` Ilya Matveychikov
0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2017-08-21 9:46 UTC (permalink / raw)
To: Ilya Matveychikov
Cc: Baoquan He, Andrew Morton, Ingo Molnar, linux-kernel, kernel-janitors
I wasn't sure how get_options() worked, so I looked at examples. And by
sheer chance the first example I picked the only example which uses it
incorrectly... I've added some comments that hopefully help.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/lib/cmdline.c b/lib/cmdline.c
index 4c0888c4a68d..0eb8d0ab60db 100644
--- a/lib/cmdline.c
+++ b/lib/cmdline.c
@@ -73,14 +73,15 @@ EXPORT_SYMBOL(get_option);
/**
* get_options - Parse a string into a list of integers
* @str: String to be parsed
- * @nints: size of integer array
+ * @nints: size of integer array (including the extra int at the start)
* @ints: integer array
*
* This function parses a string containing a comma-separated
* list of integers, a hyphen-separated range of _positive_ integers,
* or a combination of both. The parse halts when the array is
* full, or when no more numbers can be retrieved from the
- * string.
+ * string. It stores the number of numbers as the first element in the
+ * array.
*
* Return value is the character in the string which caused
* the parse to end (typically a null terminator, if @str is
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] lib/cmdline.c: add to the get_options() documentation
2017-08-21 9:46 [PATCH] lib/cmdline.c: add to the get_options() documentation Dan Carpenter
@ 2017-08-21 10:42 ` Ilya Matveychikov
2017-08-21 11:50 ` Dan Carpenter
0 siblings, 1 reply; 3+ messages in thread
From: Ilya Matveychikov @ 2017-08-21 10:42 UTC (permalink / raw)
To: Dan Carpenter
Cc: Baoquan He, Andrew Morton, Ingo Molnar, linux-kernel,
kernel-janitors, ben.hutchings
> On Aug 21, 2017, at 1:46 PM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
>
> I wasn't sure how get_options() worked, so I looked at examples. And by
> sheer chance the first example I picked the only example which uses it
> incorrectly... I've added some comments that hopefully help.
>
See also comments on my patch from Ben Hutchings:
https://patchwork.kernel.org/patch/9811617/
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] lib/cmdline.c: add to the get_options() documentation
2017-08-21 10:42 ` Ilya Matveychikov
@ 2017-08-21 11:50 ` Dan Carpenter
0 siblings, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2017-08-21 11:50 UTC (permalink / raw)
To: Ilya Matveychikov
Cc: Baoquan He, Andrew Morton, Ingo Molnar, linux-kernel,
kernel-janitors, ben.hutchings
On Mon, Aug 21, 2017 at 02:42:52PM +0400, Ilya Matveychikov wrote:
>
> > On Aug 21, 2017, at 1:46 PM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> >
> > I wasn't sure how get_options() worked, so I looked at examples. And by
> > sheer chance the first example I picked the only example which uses it
> > incorrectly... I've added some comments that hopefully help.
> >
>
> See also comments on my patch from Ben Hutchings:
> https://patchwork.kernel.org/patch/9811617/
Ugh... The implementation of get_options() looks gnarly, yes. That
affects the part of my comment which says:
+ * string. It stores the number of numbers as the first element in the
+ * array.
If we are going to keep the current behavior then we should specify that
ints[0] can be higher than "nints - 1". But I feel like the current
behavior is wrong and that get_range() should never return more than n.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-08-21 11:51 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-21 9:46 [PATCH] lib/cmdline.c: add to the get_options() documentation Dan Carpenter
2017-08-21 10:42 ` Ilya Matveychikov
2017-08-21 11:50 ` Dan Carpenter
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®