kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
From: der.herr@hofr.at (Nicholas Mc Guire)
To: kernelnewbies@lists.kernelnewbies.org
Subject: CHECK: Alignment should match open parenthesis
Date: Fri, 13 Mar 2015 17:58:55 +0100	[thread overview]
Message-ID: <20150313165855.GA25768@opentech.at> (raw)
In-Reply-To: <4E5779AD88B2F040B8A7E83ECF544D1A5C6474@SJCPEX01CL03.citrite.net>

On Fri, 13 Mar 2015, Jeff Haran wrote:

> -----Original Message-----
> From: kernelnewbies-bounces at kernelnewbies.org [mailto:kernelnewbies-bounces at kernelnewbies.org] On Behalf Of Nicholas Mc Guire
> Sent: Friday, March 13, 2015 8:33 AM
> To: Daniel Baluta
> Cc: kernelnewbies at kernelnewbies.org; palik imre
> Subject: Re: CHECK: Alignment should match open parenthesis
> 
> On Fri, 13 Mar 2015, Daniel Baluta wrote:
> 
> > On Fri, Mar 13, 2015 at 3:47 PM, Nicholas Mc Guire <der.herr@hofr.at> wrote:
> > > On Fri, 13 Mar 2015, Nicholas Mc Guire wrote:
> > >
> > >> On Fri, 13 Mar 2015, palik imre wrote:
> > >>
> > >> > On Friday, 13 March 2015, 13:43, Nicholas Mc Guire <der.herr@hofr.at> wrote:
> > >> > > On Fri, 13 Mar 2015, palik imre wrote:
> > >> > >
> > >> > >
> > >> > > > Sorry for the silly question, but I have some issues with this checkpatch.pl warning.
> > >> > > >
> > >> > > > I mean Documentation/CodingStyle says:
> > >> > > >
> > >> > > > Outside of comments, documentation and except in Kconfig, 
> > >> > > > spaces are never used for indentation, and the above example is deliberately broken.
> > >> > > >
> > >> > > > But checkpatch.pl claims I should align to open parentheses.  These two things seem to be contradictory to me.  Could somebody clarify this?
> > >> > >
> > >> > > >
> > >> > > leading tabs *followed* by spaces to align parameters to a 
> > >> > > function are fine
> > >> >
> > >> > The emacs settings in Documentation/CodingStyle seem to 
> > >> > contradict to you, as it is set up to use 
> > >> > c-lineup-arglist-tabs-only
> > >> >
> > >> The problem is that CodingStyle does not explicitly address 
> > >> parameter alignment for functions that do not fit on a single line 
> > >> but checkpatch.pl does
> > >>
> > >> you can try it out - if you align to the opening braces with spaces 
> > >> with preceding TABs it will not fuss and this is also common practice.
> > >>
> > > here is a quick shot at summarizing this
> > >
> > >
> > > If the parameter list to a functions would exceed the 80 char limit 
> > > then break it at the separators, and align to opening braces, e.g.:
> > >
> > >                         ret = fw_load_from_user_helper(fw, name, device,
> > >                                                        opt_flags, 
> > > timeout);
> > >
> > > or:
> > >
> > >         int =
> > >         wait_for_completion_interruptible_timeout(data->completion,
> > >                                                   PMI_TIMEOUT);
> > >
> > > Note that this is indented by tabs and then aligned with spaced to 
> > > fit the opening braces. If you can not fit it even if you break the 
> > > parameter list at the commas then indent by tabs only but 
> > > *significantly* to the left of the opening braces, e.g.:
> > >
> > >                 int ret = wait_for_completion_interruptible_timeout(
> > >                                 &info->done, 
> > > usecs_to_jiffies(TIMEOUT_US));
> > >
> > >
> > > would be suprised if there is no writeup somewhere alredy but I did 
> > > not find this covered in Documentations anywhere.
> > 
> > I think it would be a coding idea to have this in CodingStyle doc :).
> >
> At this level of detail it would be almost unmaintainable and also you would end up with far too many rules to actually keep them in mind. That is the job of tools like checkpatch.pl they can have all the myriads of corner cases encoded without creating a burden to the developers/maintainers.
> 
> thx!
> hofrat 
> 
> I often see people writing posts to this list stating that they are want to get started and want to contribute something. I suppose this thread provides a suggestion for them. Take the latest version of checkpatch .pl and reverse engineer from it an update to the coding style document that documents in plain, human readable English what that script implements. Seems it bit back asswards to me for the requirements to derive from a script that implements them, but that seems to be where we are at. The very fact that this thread even exists, that the original question needed to be asked demonstrates that there's something missing in the style document.
>

If you look at things like MISRA-C - 200+ "Rules" to follow for safe code
it turns out that basically nobody is able to write MISRA compliant code
under consideration of all 200+ rules unless they have tools that tell them
what is wrong with enough information that it can be fixed. And at the same
time having those rules codified makes it hard (if not impossible) to
update/maintain these rules - lots of which are actually out of date or
overstated but now can't be "fixed" - It might help to have this up on a
web-page/wiki somewhere - but if you put this into Documentation/CodingStyle at
this granularity the rate of people reading and keeping it cache-hot while
coding would sharply decline.

thx!
hofrat

  reply	other threads:[~2015-03-13 16:58 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-13 12:07 CHECK: Alignment should match open parenthesis palik imre
2015-03-13 12:43 ` Nicholas Mc Guire
2015-03-13 13:09   ` palik imre
2015-03-13 13:28     ` Nicholas Mc Guire
2015-03-13 13:47       ` Nicholas Mc Guire
2015-03-13 14:35         ` Daniel Baluta
2015-03-13 14:46           ` Greg KH
2015-03-13 15:33           ` Nicholas Mc Guire
2015-03-13 16:15             ` Daniel Baluta
2015-03-13 16:46             ` Jeff Haran
2015-03-13 16:58               ` Nicholas Mc Guire [this message]
2015-03-13 17:18                 ` Jeff Haran
2015-03-13 17:31                   ` Nicholas Mc Guire
2015-03-13 18:05                     ` Jeff Haran
2015-03-13 18:57                       ` Nicholas Mc Guire

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150313165855.GA25768@opentech.at \
    --to=der.herr@hofr.at \
    --cc=kernelnewbies@lists.kernelnewbies.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).