From: Kim Phillips <kim.phillips@freescale.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v3] mkimage: add "-V" option to print version information
Date: Sat, 12 Feb 2011 16:04:43 -0600 [thread overview]
Message-ID: <20110212160443.aadfa098.kim.phillips@freescale.com> (raw)
In-Reply-To: <4D562D0A.9060800@free.fr>
On Sat, 12 Feb 2011 07:47:38 +0100
Albert ARIBAUD <albert.aribaud@free.fr> wrote:
> Le 12/02/2011 00:11, Kim Phillips a ?crit :
> > I'd have done it without magic nor comments as
> >
> > U_BOOT_VERSION[sizeof("U-Boot ") + 1]
> >
> > or even
> >
> > U_BOOT_VERSION[strlen("U-Boot ")]
>
> The second one calls strlen() at run-time, plus it allocates the "U-Boot
> " string for no justifiable reason -- assuming the first one can be
> compile-time evaluated by the compiler, of course.
no, the compiler evaluates the strlen at compile time and eliminates
the need to allocate the "U-Boot " string in both cases.
that's not to say that there aren't a couple of gaffes above: the
sizeof needs a - 1 instead of a + 1 (because it includes the trailing
'\0'), and both expressions need to be prepended with an '&'. So, we
have something like:
&U_BOOT_VERSION[sizeof("U-Boot ") - 1]
or
&U_BOOT_VERSION[strlen("U-Boot ")]
Kim
next prev parent reply other threads:[~2011-02-12 22:04 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-11 8:56 [U-Boot] [PATCH] mkimage: add "-V" option to print version information Wolfgang Denk
2011-02-11 12:22 ` [U-Boot] [PATCH v2] " Wolfgang Denk
2011-02-11 21:55 ` Albert ARIBAUD
2011-02-11 22:35 ` Wolfgang Denk
2011-02-11 21:52 ` [U-Boot] [PATCH] " Albert ARIBAUD
2011-02-11 22:41 ` [U-Boot] [PATCH v3] " Wolfgang Denk
2011-02-11 23:11 ` Kim Phillips
2011-02-12 6:47 ` Albert ARIBAUD
2011-02-12 9:29 ` Wolfgang Denk
2011-02-12 22:04 ` Kim Phillips [this message]
2011-02-12 9:37 ` Wolfgang Denk
2011-02-12 22:17 ` Kim Phillips
2011-02-12 23:31 ` Wolfgang Denk
2011-02-12 9:37 ` [U-Boot] [PATCH v4] " Wolfgang Denk
2011-02-12 23:13 ` Kim Phillips
2011-02-12 23:35 ` Wolfgang Denk
2011-02-13 0:08 ` Kim Phillips
2011-04-12 20:37 ` Wolfgang Denk
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=20110212160443.aadfa098.kim.phillips@freescale.com \
--to=kim.phillips@freescale.com \
--cc=u-boot@lists.denx.de \
/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 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.