[U-Boot] preferred style?

Heiko Schocher hs at denx.de
Tue Mar 23 07:23:15 CET 2010


Hello Frans,

Frans Meulenbroeks wrote:
> I've been peeking at optimizing a little bit more in i2c, and I bumped
> into a stylish question:
> 
> I see function prototypes like:
> static int
> mod_i2c_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char *argv[])
> 
> and also
> int do_i2c_probe (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
> 
> A few questions on this:
> 
> is the preferred place of the type on a separate line (like for
> mod_i2c_mem) or on the same line as the function (as for
> do_i2c_probe)?

Hmm.. I prefer to have this in one line, and think, this is the
way to go ...

> Also do_i2c_probe and friends are mentioned in the subcmd table and
> are not used outside the file. (at least do_i2c_probe isn't, didn't
> check the others yet)
> So wouldn't it be preferable to have them static too?

Yep. I checked this for all do_i2c_* functions, they should be all
static. Thanks for detecting this.

> Furthermore I noticed: &cmd_i2c_sub[0]. Is this preferred above just
> writing cmd_i2c_sub (so without & and [0]).

I prefer with & and [0]

bye
Heiko
-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany


More information about the U-Boot mailing list