From mboxrd@z Thu Jan 1 00:00:00 1970 From: Lukasz Majewski Date: Mon, 23 Jul 2012 18:01:04 +0200 Subject: [U-Boot] [PATCH 5/7] dfu:cmd: Support for DFU u-boot command In-Reply-To: <201207200020.17935.vapier@gentoo.org> References: <1341308291-14663-1-git-send-email-l.majewski@samsung.com> <1341308291-14663-6-git-send-email-l.majewski@samsung.com> <201207200020.17935.vapier@gentoo.org> Message-ID: <20120723180104.4fbccddb@amdc308.digital.local> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Dear Mike, > On Tuesday 03 July 2012 05:38:09 Lukasz Majewski wrote: > > --- /dev/null > > +++ b/common/cmd_dfu.c > > > > +int do_dfu(cmd_tbl_t *cmdtp, int flag, int argc, char * const > > argv[]) > > static It can be static (static int do_dfu). On the other hand the U_BOOT_CMD macro defines: int (*cmd)(struct cmd_tbl_s *, int, int, char * const []); at struct cmd_tbl_s, which is int. > > > +{ > > + char *str_env = NULL, *env_bkp = NULL; > > no need to assign NULL here. str_env should be const. Yes, correct. > > > + static char *s = "dfu"; > > no need to declare this static Why not? The s ptr is further passed to g_dnl_init(s), so my intend was to declare string in the data segment of this translation unit. In this way the data under this ptr will not vanish. > > > + int ret = 0; > > no need to init to 0 Ok. > > > + env_bkp = strdup(str_env); > > + ret = dfu_config_entities(env_bkp, argv[1], > > + (int)simple_strtoul(argv[2], NULL, > > 10)); > > + if (ret) > > + return CMD_RET_FAILURE; > > + > > + if (strcmp(argv[3], "list") == 0) { > > + dfu_show_entities(); > > + dfu_free_entities(); > > + free(env_bkp); > > + return CMD_RET_SUCCESS; > > for these last three statements, you could just do "goto done" and > put a done label below ... Yes, you are correct. Thanks for tip. > > > +exit: > > + g_dnl_cleanup(); > > done: > > > + dfu_free_entities(); > > + free(env_bkp); > > + > > + return CMD_RET_SUCCESS; > > -mike -- Best regards, Lukasz Majewski Samsung Poland R&D Center | Linux Platform Group