[PATCH] i2c_tools.c: add i2ctransfer utility
Xabier Oneca -- xOneca
xoneca at gmail.com
Mon Jan 7 12:23:38 UTC 2019
Hi Nikolaus,
> >> + while (*++argv) {
> >> + char *arg_ptr = *argv;
> >> + unsigned long len, raw_data;
> >> + __u16 flags;
> >> + __u8 data, *buf;
> >> + char *end;
> >> +
> >> + if (nmsgs > I2C_RDWR_IOCTL_MAX_MSGS)
> >> + bb_error_msg_and_die("Error: Too many messages (max: %d)\n",
> >> + I2C_RDWR_IOCTL_MAX_MSGS);
> >
> > Off-by-one error? Seems you meant to use >=.
>
> The code is actually correct, as nmsgs is incremented below after
> writing to msgs[nmsgs] and nmsgs == I2C_RDWR_IOCTL_MAX_MSGS is valid.
Sorry, I don't see how can here nmsgs == I2C_RDWR_IOCTL_MAX_MSGS be
valid. nmsgs is the array index, so it can never reach
I2C_RDWR_IOCTL_MAX_MSGS.
> >> + } else {
> >> + /* 'force' allows whole address range */
> >
> > Not sure about this statement. It seems to be a '-a' for this:
> > https://manpages.debian.org/unstable/i2c-tools/i2ctransfer.8.en.html#OPTIONS
> > It seems none of the I2C functions of Busybox but i2cdetect support -a.
>
> My version of i2ctransfer for i2c-tools does not (yet) support -a, see
> https://manpages.debian.org/testing/i2c-tools/i2ctransfer.8.en.html#OPTIONS
> but I think it is a good extension, so I added support for it.
Sorry, I didn't notice that I checked the man pages for unstable! :/
Only looking at the man, it is not clear what the behaviour should be
here. But if you checked that -f allows any address, then it's fine
for me.
Cheers,
Xabier Oneca_,,_
More information about the busybox
mailing list