From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mike Frysinger Date: Tue, 23 Aug 2011 17:46:56 -0400 Subject: [U-Boot] [PATCH v4 03/13] common: add run_command2 for running simple or hush commands In-Reply-To: <1314133621-6488-4-git-send-email-jason.hobbs@calxeda.com> References: <1314133621-6488-1-git-send-email-jason.hobbs@calxeda.com> <1314133621-6488-4-git-send-email-jason.hobbs@calxeda.com> Message-ID: <201108231746.57132.vapier@gentoo.org> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Tuesday, August 23, 2011 17:06:51 Jason Hobbs wrote: > Signed-off-by: Jason Hobbs > --- > changes in v2: > - whitespace correction > > changes in v4: > - fix indention of a run_command2 line > - make run_command2 static inline > > common/hush.c | 2 +- > common/main.c | 50 +++++++++++++++++++++----------------------------- > include/hush.h | 2 +- > 3 files changed, 23 insertions(+), 31 deletions(-) > > diff --git a/common/hush.c b/common/hush.c > index 85a6030..940889b 100644 > --- a/common/hush.c > +++ b/common/hush.c > @@ -3217,7 +3217,7 @@ int parse_stream_outer(struct in_str *inp, int flag) > #ifndef __U_BOOT__ > static int parse_string_outer(const char *s, int flag) > #else > -int parse_string_outer(char *s, int flag) > +int parse_string_outer(const char *s, int flag) > #endif /* __U_BOOT__ */ > { > struct in_str input; > diff --git a/common/main.c b/common/main.c > index b97d89e..e9e8350 100644 > --- a/common/main.c > +++ b/common/main.c > @@ -83,8 +83,7 @@ extern void mdm_init(void); /* defined in board.c */ > > /************************************************************************* > ** * Watch for 'delay' seconds for autoboot stop or autoboot delay string. > - * returns: 0 - no key string, allow autoboot > - * 1 - got key string, abort > + * returns: 0 - no key string, allow autoboot 1 - got key string, abort > */ > #if defined(CONFIG_BOOTDELAY) && (CONFIG_BOOTDELAY >= 0) > # if defined(CONFIG_AUTOBOOT_KEYED) > @@ -266,6 +265,20 @@ int abortboot(int bootdelay) > # endif /* CONFIG_AUTOBOOT_KEYED */ > #endif /* CONFIG_BOOTDELAY >= 0 */ > > +static inline > +int run_command2(const char *cmd, int flag) > +{ > +#ifndef CONFIG_SYS_HUSH_PARSER > + if (run_command(cmd, flag) == -1) > + return 1; > +#else > + if (parse_string_outer(cmd, > + FLAG_PARSE_SEMICOLON | FLAG_EXIT_FROM_LOOP) != 0) > + return 1; > +#endif > + return 0; > +} do you need to do your own return value munging ? seems like "returns 0 on success, non-zero on failure" would allow you to do: { #ifndef CONFIG_SYS_HUSH_PARSER return run_command(cmd, flag); #else return parse_string_outer(cmd, FLAG_PARSE_SEMICOLON | FLAG_EXIT_FROM_LOOP); #endif } -mike -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: This is a digitally signed message part. Url : http://lists.denx.de/pipermail/u-boot/attachments/20110823/e0487afe/attachment.pgp