[Swan-dev] readable C style for split control statements

Andrew Cagney andrew.cagney at gmail.com
Mon Oct 1 15:08:48 UTC 2018


On Mon, 1 Oct 2018 at 10:08, Andrew Cagney <andrew.cagney at gmail.com> wrote:
>
> On Sun, 30 Sep 2018 at 15:52, D. Hugh Redelmeier <hugh at mimosa.com> wrote:
> >
> > Tuomo just committed 8db3582c4cb021ce762c9832a5314d28018f10aa:
> >         addr_lookup.c: fix coding style
> >
> > These changed indentations of IF statements that were split across lines.
> >
> > For example:
> > @@ -181,7 +181,7 @@ static ssize_t netlink_read_reply(int sock, char **pbuf, size_t bufsize,
> >                 struct nlmsghdr *nlhdr = (struct nlmsghdr *)(*pbuf + msglen);
> >
> >                 if (!NLMSG_OK(nlhdr, (size_t)readlen) ||
> > -                   nlhdr->nlmsg_type == NLMSG_ERROR)
> > +                       nlhdr->nlmsg_type == NLMSG_ERROR)
> >                         return -1;
> >
> >                 /* Move read pointer */
> >
> >
> > This absolutely brings these statements into conformity with
> > <https://github.com/torvalds/linux/blob/master/Documentation/process/coding-style.rst>
>
> I couldn't find anything specific?   And when I cut/pasted the
> suggested lisp into my .emacsrc, it hung the second line off the paren
> the way you (and I) prefer.

Hmm, perhaps half right, half wrong?  It seems to tab-indent expressions like:
        passert(foo &
                bar);
but not if() statements.

Either way, I think best strategy is to leave code alone until it
needs changing.  I'm sticking to the shipped 'linux' mode for now.

Andrew

PS: the useful thing about that blob of emacs is it contained a trick
to turn on a mode for everything under a directory tree so, finally, I
get my mode enabled automatically


More information about the Swan-dev mailing list