Re: [PATCH v2] tty: vt/keyboard: Hoist and reuse variable in vt_do_kdgkb_ioctl

From: Greg Kroah-Hartman

Date: Thu Mar 12 2026 - 12:00:41 EST


On Thu, Mar 12, 2026 at 04:30:00PM +0100, Thorsten Blum wrote:
> On 12. Mar 2026, at 15:18, Greg Kroah-Hartman wrote:
> > On Mon, Mar 02, 2026 at 04:32:52PM +0100, Thorsten Blum wrote:
> >> Hoist 'len' and use it in both cases.
> >
> > Why? And what is "both cases"?
>
> To reuse 'len' in both switch cases (KDGKBSENT and KDSKBSENT) instead of
> defining 'len = sizeof(user_kdgkb->kb_string)' in KDGKBSENT and inlining
> sizeof(user_kdgkb->kb_string) in KDSKBSENT.

As the sizeof() turns into a static number, the code is a bit simpler
as-is, right?

And there's no real need to change this for the sake of changing it that
I can see.

> >> + /*
> >> + * Ownership transfer: vt_kdskbsent() returns a pointer
> >> + * that must be freed (new buffer, old buffer, or NULL).
> >> + */
> >> kbs = vt_kdskbsent(kbs, kb_func);
> >
> > That's fine, but what does it have to do with len?
>
> It's unrelated to 'len' and just a drive-by change while I was at it.

Which, by default, makes this patch impossible to accept :(

thanks,

greg k-h