Hi Siarhei!

Am 13.09.2015 um 23:30 schrieb Siarhei Siamashka:
[...]
A minor nitpick. Basically, if we want to know if there was anything
wrong, then this can be done by checking if the return code is less
than or equal to IH_TYPE_INVALID. Such check could be also wrapped in
a macro.

[...]
This is somewhat related to my previous comment. What if we add a new
negative error code later? Then the program will still print this
"U-Boot image type mismatch:  expected IH_TYPE_FIRMWARE ..." error
message, unless somebody adds a new 'if' branch for the new error
code similar to how IH_TYPE_INVALID and IH_TYPE_ARCH_MISMATCH cases
are handled. This is generally not very nice, though not really
critical either.

Yes, I was assuming that someone adding a new (negative) error code
would also arrange for handling that. But it's probably not the best
coding style. The solution I would suggest is an
"if (image_type <= IH_TYPE_INVALID) {}" block containing a switch
statement. The switch would handle specific error codes, or 'fall
back' to a default error message, and the if block would always
exit(1) at the end.

fel.c: In function ‘aw_fel_write_uboot_image’:
fel.c:895:4: warning: format ‘%u’ expects argument of type ‘unsigned int’, but 
argument 3 has type ‘size_t’ [-Wformat=]
     "expected %u, got %u\n", len - HEADER_SIZE, data_size);
     ^

Why were these type casts dropped?

Oh. It didn't result in an error/warning for me. The first cast is
obsolete after len is now size_t (i.e. unsigned) and guaranteed to
be equal to or larger than HEADER_SIZE. The second cast just seemed
quirky to me, but it looks like my replacement isn't really portable.
The correct format specificer for a size_t should be "%zu", I'll fix
that.

Regards, B. Nortmann

--
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to