[U-Boot] Question about Coding-Style

Stefano Babic sbabic at denx.de
Tue Feb 4 16:02:56 CET 2014


Hi Hannes,

On 04/02/2014 15:50, Hannes Petermaier wrote:

> The 80 character thing is reported from checkpatch.pl as WARNING, not as
> ERROR - so there will be a chance of the patch to become accepted by a
> custodian.

No, it will *not* be accepted. There must be a very good reason to
accept it.

As far as I know, there are only a few warnings that are generally
accepted (I think using typedf is one of them).

> In between i tried to reformat by Code to obey to these rules, but now
> checkpatch.pl tells me following:
> 
> WARNING: Avoid unnecessary line continuations
> #531: FILE: board/BuR/bur_tseries/board.c:155:
> +	if (tps65217_voltage_update(TPS65217_DEFDCDC3, \

Why do you need "\" ? It is not a macro, checkpatch is right.

> 
> in real life the code section looks like this:
> /* Set DCDC3 (CORE) voltage to 1.125V */
> if (tps65217_voltage_update(TPS65217_DEFDCDC3, \
> 			TPS65217_DCDC_VOLT_SEL_1125MV)) {

Again, you do not need the line continuation because it is not a macro.
The compiler knows that the statement is not yet finished.

> 	puts("tps65217_voltage_update failure\n");
> 	return;
> }
> 
> If i don't do the line break  at line 155 checkpatch.pl is disturbing me
> with the 80 character rule.

Simply drop the unnecessary "\".

> 
> Another thing is linewrapping of output strings, to obey to the rules i
> have to format the string as following:
> 
> if (i2c_probe(TPS65217_CHIP_PM)) {
> 	printf("PMIC chip (0x%02x) not present! skipping" \
> 		"further configuration.\n", TPS65217_CHIP_PM);
> 	return;
> }
> 
> But this makes it impossible to grep the code in case of an error.

You must combine a more complicate grep, maybe with the -A (after
context) option or using a regexp. However, this is not a reason to
break the rule.

Best regards,
Stefano Babic

-- 
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================


More information about the U-Boot mailing list