[lxc-devel] about LXC's coding style

Serge Hallyn serge.hallyn at ubuntu.com
Sun Jan 19 17:54:42 UTC 2014


Quoting Qiang Huang (h.huangqiang at huawei.com):
> Hi Serge and Stéphane and list,
> 
> I'm sorry but I need to complain about this :(
> 
> I saw LXC's CONTRIBUTING file, it says:
> "The coding style follows the Linux kernel coding style"
> 
> But after reading code these days, there are too many very-long-line
> codes, especially in cgroup.c, this really cause some inconvenience,
> when reading LXC code, I can't vsplit my vim any more :(

I think that's overstating it...  I do it all the time and I have
tiny cheap low-resolution laptops.

> I don't know if this is an issue for other guys, can we keep the
> rules for the future reviews?
> 
> Thanks and best regards.

It's something I've had mixed feelings about over the years.  I'd
like to enforce it, but the code never really followed that to
begin with and I haven't wanted to have some big patch doing random
code churn to follow that guideline.

The vsplitting is a minor nuisance, and that effect is mentioned
in the guidelines, but the *main* point of that rule is not for
controlling line length itself.  The main point is to de-facto
control condition nesting in functions.  So if you have too much

	if (a)
		if (b)
			if (c)
				..

then you should be considering introducing some well-named helper
functions.  I do try to enforce that rule, and patches (small,
targeted, clear) to improve code flow would be welcome.

-serge


More information about the lxc-devel mailing list