Re: [PATCH v1 1/4] serial: core: Use string length for SysRq magic sequence

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Mar 10, 2020 at 02:38:48PM +0000, Dmitry Safonov wrote:
> On 3/10/20 1:20 PM, Andy Shevchenko wrote:
> [..]> @@ -3209,7 +3209,9 @@ static DECLARE_WORK(sysrq_enable_work,
> uart_sysrq_on);
> >   */
> >  static bool uart_try_toggle_sysrq(struct uart_port *port, unsigned int ch)
> >  {
> > -	if (ARRAY_SIZE(sysrq_toggle_seq) <= 1)
> > +	int sysrq_toggle_seq_len = strlen(sysrq_toggle_seq);
> > +
> > +	if (!sysrq_toggle_seq_len)
> >  		return false;
> 
> Eh, I wanted to avoid the strlen() call in runtime for every time sysrq
> is pressed. It's not very frequent moment surely, but..

I really don't like ARRAY_SIZE() against plain strings.
This will use \0 inclusively and confuse the understanding the code.

> Could you try

I even can tell you w/o trying, that it will fix this (yes, it does),
but see above.

> : int sysrq_toggle_seq_len = ARRAY_SIZE(sysrq_toggle_seq);
> :
> : if (sysrq_toggle_seq_len <= 1)
> :     return false;
> : /* ... */
> : port->sysrq_seq++;
> : if (port->sysrq_seq + 1 < sysrq_toggle_seq_len) {
> 
> if this will shut the warning instead?
> BTW, is this gcc 10 you see the warning with?
> I have gcc (GCC) 9.2.0 and I don't see a warning with/without the config
> string.

gcc (Debian 9.2.1-30) 9.2.1 20200224

-- 
With Best Regards,
Andy Shevchenko





[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux PPP]     [Linux FS]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Linmodem]     [Device Mapper]     [Linux Kernel for ARM]

  Powered by Linux