lkml.org 
[lkml]   [2021]   [Nov]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH v3] tty: vt: keyboard: add default switch-case, to handle smatch-warnings in method vt_do_kdgkb_ioctl
From
On 11/7/21 01:17, Ajay Garg wrote:
> On Sun, Nov 7, 2021 at 3:42 AM Pavel Skripkin <paskripkin@gmail.com> wrote:
>>
>> On 11/7/21 01:03, Ajay Garg wrote:
>> > diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
>> > index c7fbbcdcc346..b83e7669658d 100644
>> > --- a/drivers/tty/vt/keyboard.c
>> > +++ b/drivers/tty/vt/keyboard.c
>> > @@ -2090,6 +2090,12 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
>> >
>> > ret = 0;
>> > break;
>> > + default: {
>> > + kbs = NULL;
>> > + ret = -ENOIOCTLCMD;
>> > +
>> > + break;
>> > + }
>>
>> Are these brackets needed here? There are no local variables inside
>> default case.
>
> Hmm,
>
> * case KDGKBSENT: uses braces.
> * case KDSKBSENT: does not use braces.
>
> I based the layout for default-case on the same lines as case
> KDGKBSENT: , as I prefer explicit braces :)
>

I am not against these braces, but I, honestly, dislike them, because
`case : {` syntax looks ugly _to me_.

KDGKBSENT uses it because of local variable `len` and not using them
will cause build error.

I didn't find any strict requirements to not use brackets when there is
no local variable, so it's up to maintainers (again).


Anyway, thank for respinning :)



With regards,
Pavel Skripkin

\
 
 \ /
  Last update: 2021-11-06 23:26    [W:1.227 / U:0.484 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site