lkml.org 
[lkml]   [2014]   [Jun]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v2 2/2] lib.c: skip --param parameters
From
Date
On Mon, 2014-06-30 at 01:51 -0700, Christopher Li wrote:
> On Mon, Jun 30, 2014 at 1:32 AM, Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
> >
> > Hmm... I'd just added test printf to the handle_param() and see if I
> > print *next, it is either --param or --param=*. So, using return (next +
> > 2) helps, otherwise we end up with the same situation as before patch.
>
> The return value from handle_switch() is a bit tricky. It is actually points to
> the current args which about to be expired.
>
> Take a look at this code which invoke the handle_switch().
> for (;;) {
> char *arg = *++args; <---------------- notice the ++
> before the fetch
> if (!arg)
> break;
>
> if (arg[0] == '-' && arg[1]) {
> args = handle_switch(arg+1, args); <-------- args return here.
> continue;
> }
> add_ptr_list_notag(filelist, arg);
> }
>
> >
> > What did I miss?
>
> So the caller loop will perform 1 pointer advance before fetch.
> Your code can advance 2 pointer, so that is total 3 pointer advance.

Yeah, thanks for explanation. Just noticed this after send a message.

>
> >
> > Which was explicitly mentioned in the commit message.
>
> Sorry about that, I jump to the code first. I later notice that in
> the commit message as well.
>
> Any way, the change I push should fix all that.

Yup. Thank you.


--
Andy Shevchenko <andriy.shevchenko@intel.com>
Intel Finland Oy



\
 
 \ /
  Last update: 2014-06-30 13:41    [W:0.035 / U:0.056 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site