* [U-Boot] preferred style?
@ 2010-03-22 20:51 Frans Meulenbroeks
2010-03-23 6:23 ` Heiko Schocher
0 siblings, 1 reply; 3+ messages in thread
From: Frans Meulenbroeks @ 2010-03-22 20:51 UTC (permalink / raw)
To: u-boot
Hi,
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)?
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?
Furthermore I noticed: &cmd_i2c_sub[0]. Is this preferred above just
writing cmd_i2c_sub (so without & and [0]).
Frans
^ permalink raw reply [flat|nested] 3+ messages in thread
* [U-Boot] preferred style?
2010-03-22 20:51 [U-Boot] preferred style? Frans Meulenbroeks
@ 2010-03-23 6:23 ` Heiko Schocher
2010-03-23 6:36 ` Wolfgang Denk
0 siblings, 1 reply; 3+ messages in thread
From: Heiko Schocher @ 2010-03-23 6:23 UTC (permalink / raw)
To: u-boot
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* [U-Boot] preferred style?
2010-03-23 6:23 ` Heiko Schocher
@ 2010-03-23 6:36 ` Wolfgang Denk
0 siblings, 0 replies; 3+ messages in thread
From: Wolfgang Denk @ 2010-03-23 6:36 UTC (permalink / raw)
To: u-boot
Dear Heiko Schocher,
In message <4BA85E53.90404@denx.de> you wrote:
>
> > 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 ...
If possible, yes. But in the example above you cannot get it in one
line due to the line length restrictions. And instead of splitting the
arguments on two lines, I tend to believe that the example above is
"looking better". YMMV.
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
If something is different, it's either better or worse, and usually
both. - Larry Wall
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-03-23 6:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-22 20:51 [U-Boot] preferred style? Frans Meulenbroeks
2010-03-23 6:23 ` Heiko Schocher
2010-03-23 6:36 ` Wolfgang Denk
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.