Best way to split a long function declaration with modifiers
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
Quoted 7 lines · Igor Stoppa
I have been wondering if it's ok to break a long (function declaration) line in the following way:
static
__always_inline
structfoo_bar*__get_foo_bar(type1 parm1, type2 parm2, type3 parm3)
Quoted 6 lines
instead of:
static
__always_inlinestructfoo_bar*__get_foo_bar(type1 parm1,
type2 parm2, type3 parm3)
I think so.
Quoted 4 lines
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.
Quoted 4 lines · Joe Perches
Quoted 4 lines
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
A message that is not in the archive (sent off-list or not yet received): CAH2bzCT0BhTy6-hTkaevt1VyYaZpq=AvF6cRpPHs=tzzU76twg@mail.gmail.com
Quoted 10 lines · On Sat, 2018-05-12 at 19:07 +0300, [email protected] wrote:
Quoted 5 lines · Joe Perches
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