[2/2,media] tm6000: Fix bad indentation.

Message ID 1323178776-12305-2-git-send-email-thierry.reding@avionic-design.de (mailing list archive)
State Accepted, archived
Headers

Commit Message

Thierry Reding Dec. 6, 2011, 1:39 p.m. UTC
  Function parameters on subsequent lines should never be aligned with the
function name but rather be indented.

Signed-off-by: Thierry Reding <thierry.reding@avionic-design.de>
---
 drivers/media/video/tm6000/tm6000-video.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)
  

Comments

Antti Palosaari Dec. 6, 2011, 1:58 p.m. UTC | #1
That question is related to that kind of indentation generally, not only 
that patch.

On 12/06/2011 03:39 PM, Thierry Reding wrote:
> Function parameters on subsequent lines should never be aligned with the
> function name but rather be indented.
[...]
>   			usb_set_interface(dev->udev,
> -			dev->isoc_in.bInterfaceNumber,
> -			0);
> +					dev->isoc_in.bInterfaceNumber, 0);

Which kind of indentation should be used when function params are 
slitted to multiple lines?

In that case two tabs are used (related to function indentation).
example:
	ret= function(param1,
			param2);

Other generally used is only one tab (related to function indentation).
example:
	ret= function(param1,
		param2);

And last generally used is multiple tabs + spaces until same location 
where first param is meet (related to function indentation). I see that 
bad since use of tabs, with only spaces I see it fine. And this many 
times leads situation param level are actually different whilst 
originally idea was to put those same level.
example:
	ret= function(param1,
		      param2);


regards
Antti
  
Thierry Reding Dec. 6, 2011, 2:13 p.m. UTC | #2
* Antti Palosaari wrote:
> That question is related to that kind of indentation generally, not
> only that patch.
> 
> On 12/06/2011 03:39 PM, Thierry Reding wrote:
> >Function parameters on subsequent lines should never be aligned with the
> >function name but rather be indented.
> [...]
> >  			usb_set_interface(dev->udev,
> >-			dev->isoc_in.bInterfaceNumber,
> >-			0);
> >+					dev->isoc_in.bInterfaceNumber, 0);
> 
> Which kind of indentation should be used when function params are
> slitted to multiple lines?

I don't think this is documented anywhere and there are no hard rules with
regard to this. I guess anything is fine as long as it is indented at all.

> In that case two tabs are used (related to function indentation).
> example:
> 	ret= function(param1,
> 			param2);

I usually use that because it is my text editor's default.

> Other generally used is only one tab (related to function indentation).
> example:
> 	ret= function(param1,
> 		param2);

I think that's okay as well.

> And last generally used is multiple tabs + spaces until same
> location where first param is meet (related to function
> indentation). I see that bad since use of tabs, with only spaces I
> see it fine. And this many times leads situation param level are
> actually different whilst originally idea was to put those same
> level.
> example:
> 	ret= function(param1,
> 		      param2);

Whether this works or not always depends on the tab-width. I think most
variations are okay here. Some people like to align them, other people
don't.

Thierry
  
Mauro Carvalho Chehab Dec. 6, 2011, 8:58 p.m. UTC | #3
On 06-12-2011 12:13, Thierry Reding wrote:
> * Antti Palosaari wrote:
>> That question is related to that kind of indentation generally, not
>> only that patch.
>>
>> On 12/06/2011 03:39 PM, Thierry Reding wrote:
>>> Function parameters on subsequent lines should never be aligned with the
>>> function name but rather be indented.
>> [...]
>>>   			usb_set_interface(dev->udev,
>>> -			dev->isoc_in.bInterfaceNumber,
>>> -			0);
>>> +					dev->isoc_in.bInterfaceNumber, 0);
>>
>> Which kind of indentation should be used when function params are
>> slitted to multiple lines?

Documentation/CodingStyle currently says:

	Statements longer than 80 columns will be broken into sensible chunks, unless
	exceeding 80 columns significantly increases readability and does not hide
	information. Descendants are always substantially shorter than the parent and
	are placed substantially to the right. The same applies to function headers
	with a long argument list. However, never break user-visible strings such as
	printk messages, because that breaks the ability to grep for them.

So, it should be: "substantially to the right" whatever this means.

> I don't think this is documented anywhere and there are no hard rules with
> regard to this. I guess anything is fine as long as it is indented at all.
>
>> In that case two tabs are used (related to function indentation).
>> example:
>> 	ret= function(param1,
>> 			param2);
>
> I usually use that because it is my text editor's default.
>
>> Other generally used is only one tab (related to function indentation).
>> example:
>> 	ret= function(param1,
>> 		param2);
>
> I think that's okay as well.

One tab can hardly be interpreted as "substantially to the right".

>
>> And last generally used is multiple tabs + spaces until same
>> location where first param is meet (related to function
>> indentation). I see that bad since use of tabs, with only spaces I
>> see it fine. And this many times leads situation param level are
>> actually different whilst originally idea was to put those same
>> level.
>> example:
>> 	ret= function(param1,
>> 		      param2);

In practice, this is the most commonly used way, from what I noticed, not only
at drivers/media. A good place to look for commonly used CodingStyle are the
most used headers at include/linux. As far as I noticed, they all use this
style.

>
> Whether this works or not always depends on the tab-width. I think most
> variations are okay here. Some people like to align them, other people
> don't.

Tab width is always 8, according with the CodingStyle:

	"Tabs are 8 characters, and thus indentations are also 8 characters."

Regards,
Mauro

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
  
Antti Palosaari Dec. 6, 2011, 9:03 p.m. UTC | #4
On 12/06/2011 10:58 PM, Mauro Carvalho Chehab wrote:
> On 06-12-2011 12:13, Thierry Reding wrote:
>> * Antti Palosaari wrote:
>>> That question is related to that kind of indentation generally, not
>>> only that patch.
>>>
>>> On 12/06/2011 03:39 PM, Thierry Reding wrote:
>>>> Function parameters on subsequent lines should never be aligned with
>>>> the
>>>> function name but rather be indented.
>>> [...]
>>>> usb_set_interface(dev->udev,
>>>> - dev->isoc_in.bInterfaceNumber,
>>>> - 0);
>>>> + dev->isoc_in.bInterfaceNumber, 0);
>>>
>>> Which kind of indentation should be used when function params are
>>> slitted to multiple lines?
>
> Documentation/CodingStyle currently says:
>
> Statements longer than 80 columns will be broken into sensible chunks,
> unless
> exceeding 80 columns significantly increases readability and does not hide
> information. Descendants are always substantially shorter than the
> parent and
> are placed substantially to the right. The same applies to function headers
> with a long argument list. However, never break user-visible strings
> such as
> printk messages, because that breaks the ability to grep for them.
>
> So, it should be: "substantially to the right" whatever this means.
>
>> I don't think this is documented anywhere and there are no hard rules
>> with
>> regard to this. I guess anything is fine as long as it is indented at
>> all.
>>
>>> In that case two tabs are used (related to function indentation).
>>> example:
>>> ret= function(param1,
>>> param2);
>>
>> I usually use that because it is my text editor's default.
>>
>>> Other generally used is only one tab (related to function indentation).
>>> example:
>>> ret= function(param1,
>>> param2);
>>
>> I think that's okay as well.
>
> One tab can hardly be interpreted as "substantially to the right".
>
>>
>>> And last generally used is multiple tabs + spaces until same
>>> location where first param is meet (related to function
>>> indentation). I see that bad since use of tabs, with only spaces I
>>> see it fine. And this many times leads situation param level are
>>> actually different whilst originally idea was to put those same
>>> level.
>>> example:
>>> ret= function(param1,
>>> param2);
>
> In practice, this is the most commonly used way, from what I noticed,
> not only
> at drivers/media. A good place to look for commonly used CodingStyle are
> the
> most used headers at include/linux. As far as I noticed, they all use this
> style.

Yes, but it is not correct according to CodingStyle if you use spaces 
even when mixing with tabs.

Correct seems to be intend it adding only tabs, as many as possible, 
still not to exceed 80 char line len limit.


>> Whether this works or not always depends on the tab-width. I think most
>> variations are okay here. Some people like to align them, other people
>> don't.
>
> Tab width is always 8, according with the CodingStyle:
>
> "Tabs are 8 characters, and thus indentations are also 8 characters."
>
> Regards,
> Mauro
>
  
Mauro Carvalho Chehab Dec. 7, 2011, 1:24 p.m. UTC | #5
On 06-12-2011 19:03, Antti Palosaari wrote:
> On 12/06/2011 10:58 PM, Mauro Carvalho Chehab wrote:
>> On 06-12-2011 12:13, Thierry Reding wrote:
>>> * Antti Palosaari wrote:
>>>> That question is related to that kind of indentation generally, not
>>>> only that patch.
>>>>
>>>> On 12/06/2011 03:39 PM, Thierry Reding wrote:
>>>>> Function parameters on subsequent lines should never be aligned with
>>>>> the
>>>>> function name but rather be indented.
>>>> [...]
>>>>> usb_set_interface(dev->udev,
>>>>> - dev->isoc_in.bInterfaceNumber,
>>>>> - 0);
>>>>> + dev->isoc_in.bInterfaceNumber, 0);
>>>>
>>>> Which kind of indentation should be used when function params are
>>>> slitted to multiple lines?
>>
>> Documentation/CodingStyle currently says:
>>
>> Statements longer than 80 columns will be broken into sensible chunks,
>> unless
>> exceeding 80 columns significantly increases readability and does not hide
>> information. Descendants are always substantially shorter than the
>> parent and
>> are placed substantially to the right. The same applies to function headers
>> with a long argument list. However, never break user-visible strings
>> such as
>> printk messages, because that breaks the ability to grep for them.
>>
>> So, it should be: "substantially to the right" whatever this means.
>>
>>> I don't think this is documented anywhere and there are no hard rules
>>> with
>>> regard to this. I guess anything is fine as long as it is indented at
>>> all.
>>>
>>>> In that case two tabs are used (related to function indentation).
>>>> example:
>>>> ret= function(param1,
>>>> param2);
>>>
>>> I usually use that because it is my text editor's default.
>>>
>>>> Other generally used is only one tab (related to function indentation).
>>>> example:
>>>> ret= function(param1,
>>>> param2);
>>>
>>> I think that's okay as well.
>>
>> One tab can hardly be interpreted as "substantially to the right".
>>
>>>
>>>> And last generally used is multiple tabs + spaces until same
>>>> location where first param is meet (related to function
>>>> indentation). I see that bad since use of tabs, with only spaces I
>>>> see it fine. And this many times leads situation param level are
>>>> actually different whilst originally idea was to put those same
>>>> level.
>>>> example:
>>>> ret= function(param1,
>>>> param2);
>>
>> In practice, this is the most commonly used way, from what I noticed,
>> not only
>> at drivers/media. A good place to look for commonly used CodingStyle are
>> the
>> most used headers at include/linux. As far as I noticed, they all use this
>> style.
>
> Yes, but it is not correct according to CodingStyle if you use spaces even when mixing with tabs.
>
> Correct seems to be intend it adding only tabs, as many as possible, still not to exceed 80 char line len limit.

This is not indentation, it is long line breaking. There's nothing there
saying that white spaces are not allowed on line breaks, nor checkpatch
complains about it.

So, it seems to be the better way for doing it, although CodingStyle doesn't
enforce it.

>
>
>>> Whether this works or not always depends on the tab-width. I think most
>>> variations are okay here. Some people like to align them, other people
>>> don't.
>>
>> Tab width is always 8, according with the CodingStyle:
>>
>> "Tabs are 8 characters, and thus indentations are also 8 characters."
>>
>> Regards,
>> Mauro
>>
>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
  

Patch

diff --git a/drivers/media/video/tm6000/tm6000-video.c b/drivers/media/video/tm6000/tm6000-video.c
index 87eb909..a15fd9d 100644
--- a/drivers/media/video/tm6000/tm6000-video.c
+++ b/drivers/media/video/tm6000/tm6000-video.c
@@ -1649,12 +1649,10 @@  static int tm6000_release(struct file *file)
 
 		if (dev->int_in.endp)
 			usb_set_interface(dev->udev,
-			dev->isoc_in.bInterfaceNumber,
-			2);
+					dev->isoc_in.bInterfaceNumber, 2);
 		else
 			usb_set_interface(dev->udev,
-			dev->isoc_in.bInterfaceNumber,
-			0);
+					dev->isoc_in.bInterfaceNumber, 0);
 
 		/* Start interrupt USB pipe */
 		tm6000_ir_int_start(dev);