[PATCH v3] i2c_tools.c: add i2ctransfer utility

Denys Vlasenko vda.linux at googlemail.com
Sun Feb 10 18:59:59 UTC 2019


On Sun, Feb 10, 2019 at 7:24 PM Denys Vlasenko <vda.linux at googlemail.com> wrote:
> On Mon, Jan 7, 2019 at 2:29 PM Nikolaus Voss <nv at vosn.de> wrote:
> > i2ctransfer sends and receives user defined i2c messages
> > v2: apply Xabier's comments: add -a option, don't decrement argc,
> >     use bb_show_usage() and xzalloc()
> > v3: fix possible out of bound access to msgs[nmsgs]
> >
> > Reviewed-by: Xabier Oneca -- xOneca <xoneca at gmail.com>
> > Signed-off-by: Nikolaus Voss <nikolaus.voss at loewensteinmedical.de>
> > ---
> >  miscutils/i2c_tools.c | 206 +++++++++++++++++++++++++++++++++++++++++-
> >  1 file changed, 205 insertions(+), 1 deletion(-)
> >
> > +                       switch (*arg_ptr++) {
> > +                       case 'r': flags |= I2C_M_RD; break;
> > +                       case 'w': break;
> > +                       default:
> > +                               bb_show_usage();
> > +                       }
> > +
> > +                       len = strtoul(arg_ptr, &end, 0);
> > +                       if (len > 0xffff || arg_ptr == end)
> > +                               bb_error_msg_and_die("Error: Length invalid: %s\n", *argv);
> > +
> > +                       arg_ptr = end;
> > +                       if (*arg_ptr) {
> > +                               if (*arg_ptr++ != '@')
> > +                                       bb_error_msg_and_die("Error: Unknown separator after length: %s\n",
> > +                                                    *argv);
> > +                               bus_addr = xstrtou_range(arg_ptr, 0, first, last);
> > +
> > +                               if (!(opts & opt_f))
> > +                                       i2c_set_slave_addr(fd, bus_addr, opts & opt_f);
>
> This last if() looks fishy. What is it trying to accomplish?

Applied with some changes. Please review and test!


More information about the busybox mailing list