mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Alexander Kurz <akurz@blala.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 5/5] scripts: imx-usb-loader: split off topic-code into functions
Date: Mon, 18 Jul 2016 08:12:24 +0200	[thread overview]
Message-ID: <20160718061224.GK20657@pengutronix.de> (raw)
In-Reply-To: <alpine.DEB.2.00.1607172224100.24666@blala.de>

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@blala.de>:
> > >
> > >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@blala.de >
> > >---
> > > 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@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

      reply	other threads:[~2016-07-18  6:12 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-17 15:53 [PATCH 1/5] scripts: imx-usb-loader: const function args Alexander Kurz
2016-07-17 15:53 ` [PATCH 2/5] scripts: imx-usb-loader: remove useless code Alexander Kurz
2016-07-17 15:53 ` [PATCH 3/5] scripts: imx-usb-loader: remove useless variable Alexander Kurz
2016-07-17 15:53 ` [PATCH 4/5] scripts: imx-usb-loader: structured protocol access Alexander Kurz
2016-07-17 15:53 ` [PATCH 5/5] scripts: imx-usb-loader: split off topic-code into functions Alexander Kurz
2016-07-17 16:19   ` Alexander Shiyan
2016-07-17 20:31     ` Alexander Kurz
2016-07-18  6:12       ` Sascha Hauer [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160718061224.GK20657@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=akurz@blala.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox