Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753282AbbL2JMM (ORCPT ); Tue, 29 Dec 2015 04:12:12 -0500 Received: from mail-ig0-f172.google.com ([209.85.213.172]:33388 "EHLO mail-ig0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751198AbbL2JMG (ORCPT ); Tue, 29 Dec 2015 04:12:06 -0500 MIME-Version: 1.0 In-Reply-To: <20151229053235.1d2ccb9c@recife.lan> References: <20151228153332.GA6159@kroah.com> <20151229053235.1d2ccb9c@recife.lan> Date: Tue, 29 Dec 2015 11:12:05 +0200 Message-ID: Subject: Re: On Lindent shortcomings and massive style fixing From: Andrey Utkin To: Mauro Carvalho Chehab Cc: Greg KH , "linux-kernel@vger.kernel.org" , kernel-janitors , "kernel-mentors@selenic.com" , Linux Media , devel@driverdev.osuosl.org, andrey.od.utkin@gmail.com, Andy Whitcroft , Joe Perches Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3307 Lines: 71 On Tue, Dec 29, 2015 at 9:32 AM, Mauro Carvalho Chehab wrote: > IMHO, there are two problems by letting indent breaking long > lines: > > 1) indent would break strings on printks. This is something that we don't > want to break strings on multiple lines in the Kernel; Yeah, GNU indent does its work badly (although I believe it could be taught to respect long literals), this makes me want to have a better tool for clean "relayouting" C code. I believe that'd require at last a proper syntax parser. With such tool, it would be straightforward to rewrite source code automatically to please any demanding reviewer of code style, except for issues of higher level of thought (like naming or nesting limitations). > 2) It doesn't actually solve the problem of having too complex loops, > with is why the 80 columns warning is meant to warn. Worse than that, > if a piece of code is inside more than 4 or 5 indentation levels, the > resulting code of using indent for 80-cols line break is a total crap. Then I'd propose to enforce nesting limitation explicitly, because Documentation/CodingStyle appreciates low nesting, just doesn't give exact numbers. It's better this way, because the programmer could pay attention to N places of excessive nesting and fix it manually, and then carelessly reformat NNN places of "80 chars" issues automatically, comparing to reviewing all NNN places, to figure out if there's excessive nesting, or not. (CCed checkpatch.pl maintainers.) > That's said, on a quick look at the driver, it seems that the 80-cols > violations are mostly (if not all) on the comments, like: > > int i_poc_lsb = (frame_seqno_in_gop << 1); /* why multiplied by two? TODO try without multiplication */ > > and > > #define TW5864_UNDEF_REG_0x0224 0x0224 /* Undeclared in spec (or not yet added to tw5864-reg.h) but used */ > #define TW5864_UNDEF_REG_0x4014 0x4014 /* Undeclared in spec (or not yet added to tw5864-reg.h) but used */ > #define TW5864_UNDEF_REG_0xA800 0xA800 /* Undeclared in spec (or not yet added to tw5864-reg.h) but used */ > > Btw, the content of tw5864-reg-undefined.h is weird... Why not just > add the stuff there at tw5864-reg.h and remove the comments for all > defines there? tw5864-reg-undefined.h will be edited for sure (maybe dropped), of course it won't stay as it is now. It was generated by script during reverse-engineering that bastard chip from hell. > Also, Lindent already did some crappy 80-cols like breaks, like: > > static int pci_i2c_multi_read(struct tw5864_dev *dev, u8 devid, u8 devfn, u8 *buf, > u32 count) > > (count is misaligned with the open parenthesis) I just added "static " after indenting. Actually, Documentation/CodingStyle says nothing about alignment of function declaration tail on open parenthesis. Also I'd like to mention that I hate such alignment, because it requires intermixing of tabs and spaces. I am not aware if this is K&R thing or not. If it is, then please don't kill me. Thanks for kind replies, gentlemen. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/