[PATCH 1/2] commands: i2c: do not restrict i2c_write's data to be hex-formatted

Uwe Kleine-König u.kleine-koenig at pengutronix.de
Tue Oct 17 06:51:37 PDT 2017


Hello,

On Tue, Oct 17, 2017 at 03:16:24PM +0200, Ulrich Ölmann wrote:
> The price to pay is needing the usual prefix "0x" for each hex-formatted number.
> 
> Signed-off-by: Ulrich Ölmann <u.oelmann at pengutronix.de>

ack for the change. I'd like to see the motivation (i.e. consistency with
the other commands in barebox as mentioned in the cover letter) in the
commit log, though.

> ---
>  commands/i2c.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/commands/i2c.c b/commands/i2c.c
> index 573032ab1588..b74c53509f38 100644
> --- a/commands/i2c.c
> +++ b/commands/i2c.c
> @@ -129,7 +129,7 @@ static int do_i2c_write(int argc, char *argv[])
>  
>  	buf = xmalloc(count);
>  	for (i = 0; i < count; i++)
> -		*(buf + i) = (char) simple_strtol(argv[optind+i], NULL, 16);
> +		*(buf + i) = (char) simple_strtol(argv[optind+i], NULL, 0);

Maybe change that to:

		buf[i] = simple_strtol(...);

which is a bit easier to read and drops an unnecessary cast? (Or should
that better go in a separate change?)

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |



More information about the barebox mailing list