[U-Boot] Continuation line alignment
Gerlando Falauto
gerlando.falauto at keymile.com
Tue Nov 8 00:32:56 CET 2011
On 11/08/2011 12:02 AM, Scott Wood wrote:
> On 11/07/2011 04:05 PM, Wolfgang Denk wrote:
>> Dear Gerlando Falauto,
>>
>> In message<4EB84859.6000906 at keymile.com> you wrote:
>>>
>>> -int _do_env_set (int flag, int argc, char * const argv[])
>>> +int env_check_apply(const char *name, const char *oldval,
>>> + const char *newval, int flag)
>>>
>>>> Please use only TAB for indentation. Please fix globally.
>>>
>>> From fs/ubibfs/ubifs.h:
>>
>> Never ever use examples from other code to argument your's was right -
>> the example you chose might be wrong as well.
>>
>>> Could you please provide some examples as to what would be the correct
>>> coding style for function declarations and/or function calls that spawn
>>> on multiple lines? I could not find anything on the topic.
>>
>> http://www.denx.de/wiki/U-Boot/CodingStyle:
>>
>> Use TAB characters for indentation and vertical alignment, not
>> spaces
>
> It is impossible to align this nicely with tabs alone. Such alignment
> is not just an isolated example, but quite common in both the Linux
> kernel and U-Boot.
>
> Grep for a tab followed by a space...
>
>>> + if (himport_ex(&env_htab, (char *)default_environment,
>>> + sizeof(default_environment), '\0', 0,
>>> + 0, NULL, apply_function) == 0) {
>>>
>>> What should be the right indentation?
>>
>> In any case it makse no sense to have the 2nd and 3rd line indented
>> differently, right?
>
> They generally shouldn't be different from each other, but that doesn't
> answer the question of what it should look like.
Thank you! :-)
> Documentation/CodingStyle calls for something like this:
>
> if (himport_ex(&env_htab, (char *)default_environment,
> sizeof(default_environment), '\0',
> 0, 0, NULL, apply_function) == 0) {
I would have thought this would make more sense (offset by 1, not 9):
if (himport_ex(&env_htab, (char *)default_environment,
sizeof(default_environment), '\0',
0, 0, NULL, apply_function) == 0) {
Or maybe even:
if (himport_ex(&env_htab, (char *)default_environment,
sizeof(default_environment), '\0',
0, 0, NULL, apply_function) == 0) {
which would save a lot of screen real estate.
Now we can also argue that the argument list is really too big...
> ...but judging by how common it is, many people find this nicer:
>
> if (himport_ex(&env_htab, (char *)default_environment,
> sizeof(default_environment), '\0',
> 0, 0, NULL, apply_function) == 0) {
Actually I don't have that much of a preference in this case, it's just
a matter of aesthetics, and I think it doesn't affect readabilty that
much. As long as we agree on what is OK and what is not (or, rather,
what is the preferred way).
What bothers me more is, for instance, the condition under which my
smartphone will work correctly:
if (((day_of_week() % 2 == 0) &&
(temperature() < 14.4 || temperature() > 15.3))
|| ((sky_color() == E_BLUE) && (sim_credit() % 100 != 27))
|| (uptime() < 3600) ) {
work = 1;
} else if ( ((received_calls() > 1) &&
(zenith_angle() == 0))
|| (call_is_important())
) {
work = 0;
} else {
udelay(rand());
work = ((rand() % 2) == 1);
}
Any ideas how to align that? Please don't answer: get a real phone. :-)
Thanks!
Gerlando Falauto
More information about the U-Boot
mailing list