[OpenWrt-Devel] [PATCH 2/2] procd: apply official kernel clang-format style

Petr Štetiar ynezz at true.cz
Tue May 14 07:08:34 PDT 2019


Paul Spooren <mail at aparcar.org> [2019-05-10 17:36:21]:

Hi,

> Currently some files use a mixture of spaces and tabs within a single
> file, instead of fixing style manually, a tool could do the job.

I find consistent coding style important, but I also know, how hard is it to
achieve it. It's some time already, so I don't remember all the glory details,
but different clang-format versions produce different results, doesn't support
certain options etc., so it's pretty confusing and introducing another
overhead. Then you should enforce it somehow (commit hooks, make target),
otherwise it's going to bitrot after sometime again etc.

> +static struct init_handler handlers[] = { {
> +						  .name = "sysinit",
> +						  .cb = runrc,
> +					  },
> +					  {
> +						  .name = "shutdown",
> +						  .cb = runrc,
> +					  },
> +					  {
> +						  .name = "askfirst",
> +						  .cb = askfirst,
> +						  .multi = 1,
> +					  },
> +					  {
> +						  .name = "askconsole",
> +						  .cb = askconsole,
> +						  .multi = 1,
> +					  },
> +					  {
> +						  .name = "respawn",
> +						  .cb = rcrespawn,
> +						  .multi = 1,
> +					  },
> +					  {
> +						  .name = "askconsolelate",
> +						  .cb = askconsole,
> +						  .multi = 1,
> +					  },
> +					  {
> +						  .name = "respawnlate",
> +						  .cb = rcrespawn,
> +						  .multi = 1,
> +					  } };

it's just me or is this very ugly?

> -	list_for_each_entry(a, &actions, list)
> -		if (!strcmp(a->handler->name, handler)) {
> -			if (a->handler->multi) {
> -				a->handler->cb(a);
> -				continue;
> -			}
> +	list_for_each_entry(a, &actions,
> +			    list) if (!strcmp(a->handler->name, handler))
> +	{
> +		if (a->handler->multi) {

eh? (I've stopped reading the changes any further)

-- ynezz



More information about the openwrt-devel mailing list