Re: [PATCH 12/20] maccess: remove strncpy_from_unsafe

From: Linus Torvalds
Date: Tue May 19 2020 - 12:46:27 EST


On Tue, May 19, 2020 at 9:41 AM Christoph Hellwig <hch@xxxxxx> wrote:
>
> I had a lot of folks complaining about things like:
>
> #ifdef CONFIG_FOO
> if (foo)
> do_stuff();
> else
> #endif
> do_something_else();
>
> which I personally don't mind at all, so I switched to this style.

Well, I don't particularly like that style either, it is _very_ easy
to get wrong when you edit it later (and various indentation checkers
tend to be very unhappy about it too).

But that's why I like trying to just make simple helper functions instead.

Yeah, it's often a few more lines of code (if only because of the
extra function definition etc), but with good naming and sane
arguments those few extra lines can also help make it much more
understandable in the process, and it gives you a nice place to add
commentary for the really odd cases (comments inside code that then
does other things often make things just harder to see).

Linus