Re: [PATCH 1/5] tty: remove TTY_MAGIC

Theodore Ts'o
2022-09-16T07:34:47Z

On Fri, Sep 16, 2022 at 03:54:59AM +0200, наб wrote:
> According to Greg, in the context of magic numbers as defined in
> magic-number.rst, "the tty layer should not need this and I'll gladly
> take patches"
>
> Ref: https://lore.kernel.org/linux-doc/YyMlovoskUcHLEb7@kroah.com/

Well, I would disagree with Greg K-H on this --- but I haven't been
tty maintainer in well over a decade. Assuming code is Bug-Free(tm),
sure, it's not necessary. But there is any kind of memory bug (e.g.,
a corrupted pointer, a use-after free, some other structure
corruption), this catches the problem earlier rather than later, and
it's a light-weight to do a quick sanity check.

It has certainly caught problems in the past, and I still use this
programming technique in programs that I do maintain, such as
e2fsprogs.

But it's not a big deal either way,

- Ted

P.S. BTW, I didn't make up this technique; it's a program pattern
first used in Multics.