kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
From: joe@perches.com (Joe Perches)
To: kernelnewbies@lists.kernelnewbies.org
Subject: newbies CheckpatchTips for multiline statements (Breaking function calls)
Date: Tue, 16 Dec 2014 12:58:49 -0800	[thread overview]
Message-ID: <1418763529.14140.9.camel@perches.com> (raw)

http://kernelnewbies.org/CheckpatchTips

The block about "Breaking function calls" is dubious.

The majority of code today uses arguments aligned to parenthesis.
The suggested 1 tab is in fact very infrequently used.

CodingStyle has this as "substantially to the right", not 1 tab.

btw: there's a perferred/preferred tyop too.

------------

Breaking function calls

Sometimes a call to a function has several variables, and you need to
break the line in the middle of those variables. Look at this example: 

 
        pdata->urbdata = usb_alloc_coherent(pdata->udev, ACD_URB_BUFFER_LEN, GFP_KERNEL, &pdata->urb->transfer_dma);


This line is too long, so we want to break it up. By default, vim will
increase the indentation of the trailing line by one tab: 

        pdata->urbdata = usb_alloc_coherent(pdata->udev, ACD_URB_BUFFER_LEN,
                GFP_KERNEL, &pdata->urb->transfer_dma);


This style is fine, and generally perferred. However, some driver
writers prefer to have the trailing line of a function call line up with
the starting '('. They use tabs, followed by spaces, to align the
trailing line: 

 
        pdata->urbdata = usb_alloc_coherent(pdata->udev, ACD_URB_BUFFER_LEN,
                                            GFP_KERNEL,
                                            &pdata->urb->transfer_dma);


Again, the one tab indent style is preferred, but don't change lines
that use the other style. 

             reply	other threads:[~2014-12-16 20:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-16 20:58 Joe Perches [this message]
2014-12-16 21:17 ` newbies CheckpatchTips for multiline statements (Breaking function calls) Mandeep Sandhu
2014-12-17  8:58 ` Bjørn Mork
2014-12-28  3:29   ` Anand Moon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1418763529.14140.9.camel@perches.com \
    --to=joe@perches.com \
    --cc=kernelnewbies@lists.kernelnewbies.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).