On Sun, 30 Oct 2011 23:57:41 +0100
[email protected] wrote:
> Author: acinonyx
> Date: 2011-10-30 23:57:41 +0100 (Sun, 30 Oct 2011)
> New Revision: 28688
Just a few comments...
> --- trunk/tools/firmware-utils/src/mkedimaximg.c
> (rev 0)
> +++ trunk/tools/firmware-utils/src/mkedimaximg.c 2011-10-30 22:57:41 UTC
> (rev 28688)
> +#if (__BYTE_ORDER == __LITTLE_ENDIAN)
> +# define HOST_TO_LE16(x) (x)
> +# define HOST_TO_LE32(x) (x)
> +#else
> +# define HOST_TO_LE16(x) bswap_16(x)
> +# define HOST_TO_LE32(x) bswap_32(x)
> +#endif
> +
> +struct header
> +{
> + unsigned char sign[4];
> + unsigned int start;
> + unsigned int flash;
> + unsigned char model[4];
> + unsigned int size;
> +} __attribute__ ((packed));
> +static unsigned short fwcsum (struct buf *buf) {
> + int i;
> + unsigned short ret = 0;
> +
> + for (i = 0; i < buf->size / 2; i++)
> + ret -= ((unsigned short *) buf->start)[i];
It seems you need
ret -= LE16_TO_HOST(((unsigned short *) buf->start)[i]);
to be endianness safe.
> + if (header.sign == NULL) {
> + fprintf(stderr, "no signature specified\n");
> + usage(EXIT_FAILURE);
> + }
> +
> + if (header.model == NULL) {
> + fprintf(stderr, "no model specified\n");
> + usage(EXIT_FAILURE);
> + }
You are actually comparing arrays to NULL here. Seems an odd thing to do.
You probably want
if (!header.sign[0])
and
if (!header.model[0])
That ought to be good enough in this case.
--
Greetings, Michael.
_______________________________________________
openwrt-devel mailing list
[email protected]
https://lists.openwrt.org/mailman/listinfo/openwrt-devel