Re: [Outreachy kernel] Re: [PATCH v7] staging: unisys: visorhba: Convert module from IDR to XArray

From: Fabio M. De Francesco
Date: Tue May 04 2021 - 10:38:19 EST


On Tuesday, May 4, 2021 4:01:19 PM CEST Matthew Wilcox wrote:
> On Tue, May 04, 2021 at 03:58:02PM +0200, Fabio M. De Francesco wrote:
> > On Tuesday, May 4, 2021 3:42:16 PM CEST Matthew Wilcox wrote:
> > > On Tue, May 04, 2021 at 03:32:53PM +0200, Fabio M. De Francesco wrote:
> > > > Changes from v6; Added a call to xa_destroy() that I had forgotten.
> > >
> > > What? No! Go back and re-read what I wrote about this previously.
> >
> > I remember that explanation you gave me some days ago for not using it.
But I
> > was mislead by a comment ("Do we not have to call xa_destroy()?") by Dan
and
> > your "Correct" soon after the above comment. So I thought that I had
> > misunderstand and the put back that call to xa_destroy(). I lost something
in
> > following the flow of the reviews, I suppose.
>
> English doesn't have the equivalent of the French 'si' or German 'doch',
> unfortunately. I imagine Italian does.
>
Yes, Italian does :-) Despite this, I still think that English is less prone
to give raise to misunderstandings (obviously, if_and_only_if one knows how to
use the language).

Back to the style of the code... in particular to (1) avoid unnecessary
'else', and to (2) check for failure (i.e., not for success) (3) don't
(always) trust checkpatch.pl because often people don't want their code
changed according to its output.

Start with (3): Steven Rostedt refused to apply a patch that I did upon a
checkpatch warning: "replace "unsigned" with "unsigned int". He says he's
perfectly comfortable with 'unsigned' and that he _prefers_ 'unsigned'. That's
OK, I think; no problem.

As far as (1) and (2) are regarded, I've been told that when one modifies code
she/he should not diverge from the style of the subsystem/driver maintainer/
author. If you look at visorhba_main.c, you'll find a lot of unnecessary
'else' and 'if (success)'...

So what are the general rules one should follow when changing (trivial) Linux
code? Please note that my question has no other (hidden) purposes than
learning to work properly with the Linux community and to reduce the
unnecessary noise consequential to submitting a high number of patch versions.

Thanks a lot for any help,

Fabio