On Sun, Jul 17, 2016 at 10:31:47PM +0200, Alexander Kurz wrote: > > > On Sun, 17 Jul 2016, Alexander Shiyan wrote: > > > >Воскресенье, 17 июля 2016, 18:53 +03:00 от Alexander Kurz <akurz@xxxxxxxx>: > > > > > >Improve code understandability: extract the "jump application" Serial > > >Download Protocol access method and file-to-buffer reader functionality > > >out of do_irom_download(). > > > > > >Signed-off-by: Alexander Kurz < akurz@xxxxxxxx > > > >--- > > > scripts/imx/imx-usb-loader.c | 159 +++++++++++++++++++++++++------------------ > > > 1 file changed, 92 insertions(+), 67 deletions(-) > > > > > >diff --git a/scripts/imx/imx-usb-loader.c b/scripts/imx/imx-usb-loader.c > > ... > > >+FILE *xfile; > > >+unsigned fsize; > > >+int cnt; > > >+unsigned char *buf; > > >+xfile = fopen(name, "rb"); > > >+if (!xfile) { > > >+printf("error, can not open input file: %s\n", name); > > >+return -5; > > ... > > >+fsize = get_file_size(xfile); > > >+if (fsize < 0x20) { > > >+printf("error, file: %s is too small\n", name); > > >+fclose(xfile); > > >+return -2; > > -2 ? Maybe -EINVAL or so will be more appropriate here? > > > > --- > Yes, right, > that's just the behviour from the existing implementation (don't touch too > many topics with one patch at one time) > There are much more magic-number returns in imx-usb-loader.c, I propose to > do a specific cleanup on this. I agree with you both: Error codes should be used and also this is topic for a separate cleanup. What's worthwile doing is to create a scripts/lib/ directory and move common functions like read_file there. This patch just brings the fourth implementation of this function. Anyway, this patch makes it easy later to replace the read_file implementation with a common implementation later, so I applied it, also the rest of this series. Sascha -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list barebox@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/barebox