LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [RFC: Coding Style] Best way to split a long function declaration with modifiers
@ 2018-05-12 15:19 Igor Stoppa
  2018-05-12 15:41 ` Joe Perches
  0 siblings, 1 reply; 4+ messages in thread
From: Igor Stoppa @ 2018-05-12 15:19 UTC (permalink / raw)
  To: Jonathan Corbet, linux-kernel

Hi,
I have been wondering if it's ok to break a long (function declaration) 
line in the following way:

static __always_inline
struct foo_bar *__get_foo_bar(type1 parm1, type2 parm2, type3 parm3)


instead of:

static __always_inline struct foo_bar *__get_foo_bar(type1 parm1,
						     type2 parm2,
						     type3 parm3)


I personally like more the former, not to mention that it uses also one 
line less, but it seems less common in the sources.
The coding style references do not seem to say anything explicit about 
which style to prefer.

And not all the code in the kernel is of the same quality, so finding an 
example doesn't automatically mean that it's a good practice to follow :-)

--
thanks, igor

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFC: Coding Style] Best way to split a long function declaration with modifiers
  2018-05-12 15:19 [RFC: Coding Style] Best way to split a long function declaration with modifiers Igor Stoppa
@ 2018-05-12 15:41 ` Joe Perches
  2018-05-12 16:10   ` Igor Stoppa
       [not found]   ` <CAH2bzCT0BhTy6-hTkaevt1VyYaZpq=AvF6cRpPHs=tzzU76twg@mail.gmail.com>
  0 siblings, 2 replies; 4+ messages in thread
From: Joe Perches @ 2018-05-12 15:41 UTC (permalink / raw)
  To: Igor Stoppa, Jonathan Corbet, linux-kernel

On Sat, 2018-05-12 at 18:19 +0300, Igor Stoppa wrote:
> I have been wondering if it's ok to break a long (function declaration) 
> line in the following way:
> 
> static __always_inline
> struct foo_bar *__get_foo_bar(type1 parm1, type2 parm2, type3 parm3)
> 
> 
> instead of:
> 
> static __always_inline struct foo_bar *__get_foo_bar(type1 parm1,
> 						     type2 parm2,
> 						     type3 parm3)
> 

I think so.

> I personally like more the former, not to mention that it uses also one 
> line less, but it seems less common in the sources.
> The coding style references do not seem to say anything explicit about 
> which style to prefer.

I think the first style should be preferred when the
combined character length of <type> <function_name> is
relatively long.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFC: Coding Style] Best way to split a long function declaration with modifiers
  2018-05-12 15:41 ` Joe Perches
@ 2018-05-12 16:10   ` Igor Stoppa
       [not found]   ` <CAH2bzCT0BhTy6-hTkaevt1VyYaZpq=AvF6cRpPHs=tzzU76twg@mail.gmail.com>
  1 sibling, 0 replies; 4+ messages in thread
From: Igor Stoppa @ 2018-05-12 16:10 UTC (permalink / raw)
  To: Joe Perches, Jonathan Corbet, linux-kernel

On 12/05/18 18:41, Joe Perches wrote:

>> I personally like more the former, not to mention that it uses also one
>> line less, but it seems less common in the sources.
>> The coding style references do not seem to say anything explicit about
>> which style to prefer.

thank you, I could provide a patch to the docs for this case, if it's 
not considered too much of a corner case.

--
igor

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFC: Coding Style] Best way to split a long function declaration with modifiers
       [not found]   ` <CAH2bzCT0BhTy6-hTkaevt1VyYaZpq=AvF6cRpPHs=tzzU76twg@mail.gmail.com>
@ 2018-05-12 16:24     ` Joe Perches
  0 siblings, 0 replies; 4+ messages in thread
From: Joe Perches @ 2018-05-12 16:24 UTC (permalink / raw)
  To: igor.stoppa; +Cc: Jonathan Corbet, linux-kernel

On Sat, 2018-05-12 at 19:07 +0300, igor.stoppa@gmail.com wrote:
> On 12 May 2018 at 18:41, Joe Perches <joe@perches.com> wrote:
> 
> > 
> > I think the first style should be preferred when the
> > combined character length of <type> <function_name> is
> > relatively long.
> > 
> 
> thank you, I could provide a patch to the docs for this case, if it's not
> considered too much of a corner case.

I think it should not considered anything like a mandate.

Perhaps it could be described as an optional/possible style
but perhaps as well it's not necessary as coding_style for
this does not have to be rigidly specified.

cheers, Joe

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-05-12 16:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-12 15:19 [RFC: Coding Style] Best way to split a long function declaration with modifiers Igor Stoppa
2018-05-12 15:41 ` Joe Perches
2018-05-12 16:10   ` Igor Stoppa
     [not found]   ` <CAH2bzCT0BhTy6-hTkaevt1VyYaZpq=AvF6cRpPHs=tzzU76twg@mail.gmail.com>
2018-05-12 16:24     ` Joe Perches

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).