[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <7fb01791-929a-540c-1ad7-395d38d2e419@robertabel.eu>
Date: Mon, 26 Feb 2018 23:29:14 +0100
From: Robert Abel <rabel@...ertabel.eu>
To: Geert Uytterhoeven <geert@...ux-m68k.org>
Cc: linux-kernel <linux-kernel@...r.kernel.org>,
Miguel Ojeda <miguel.ojeda.sandonis@...il.com>,
Willy Tarreau <w@....eu>,
Andy Shevchenko <andy.shevchenko@...il.com>
Subject: Re: [PATCH 3/4] auxdisplay: charlcd: fix x/y address commands
Hi Geert,
On 26 Feb 2018 09:46, Geert Uytterhoeven wrote:
>> +
>> + nxt_cmd = *esc++;
>> + nxt_esc = esc;
>> +
>> + while ('\0' != *esc) {
>> +
>> + cmd = nxt_cmd;
>> + esc = nxt_esc;
>> + nxt_esc = strpbrk(esc, "xy;");
>> + if (NULL != nxt_esc) {
>> + nxt_cmd = *nxt_esc;
>> + /* terminate current sequence with NUL */
>> + *nxt_esc++ = '\0';
>> + }
>
> So if none of "x", "y", or ";" is found, nxt_cmd will still contain
> the current command?
> Shouldn't it be reset to '\0' or so?
I originally had a comment there, but it then felt kinda silly.
Since one of the conditions of the code is that a semicolon ';' is
detected at the end of the stream, the situation you describe never
occurs until the end of the command string.
nxt_esc == NULL only when cmd == ';' and *esc == NULL. Since there is
nothing to terminate and the code won't run again (due to while (*esc)),
I didn't reset nxt_cmd. Other than that, I also don't know that there is
a sensible reset value.
Regards,
Robert
Powered by blists - more mailing lists