[U-Boot] [PATCH 5/7] dfu:cmd: Support for DFU u-boot command

Mike Frysinger vapier at gentoo.org
Tue Jul 24 20:00:30 CEST 2012


On Monday 23 July 2012 12:01:04 Lukasz Majewski wrote:
> 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.

i don't understand what you're trying to say

> > > +	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.

except your g_dnl_init already copies the incoming string to local storage, so 
where it is stored doesn't matter.  further, the "dfu" is going to be in 
.rodata (thus never going away), it is only the "s" pointer which will be 
stored in .data, not the thing it points to.

had you done:
	char s[] = { 'd', 'f', 'u', '\0', };
then you'd get 4 bytes on the stack
-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/20120724/7bdd3c07/attachment.pgp>


More information about the U-Boot mailing list