lkml.org 
[lkml]   [2022]   [May]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH v6] can, tty: can327 CAN/ldisc driver for ELM327 based OBD-II adapters
    On Fri, 13 May 2022 15:31:20 +0900
    Vincent Mailhol <vincent.mailhol@gmail.com> wrote:

    > On Fri. 13 May 2022 at 11:38, Vincent Mailhol
    > <vincent.mailhol@gmail.com> wrote: [...]
    > > > + case ELM327_STATE_RECEIVING:
    > > > + /* Find <CR> delimiting feedback lines. */
    > > > + for (len = 0;
    > > > + (len < elm->rxfill) && (elm->rxbuf[len] !=
    > > > '\r');
    > > > + len++) {
    > > > + /* empty loop */
    > >
    > > Question of taste but would prefer a while look with the len++ in
    > > the body (if you prefer to do as above, no need to argue, just keep
    > > it like it is).
    >
    > Actually, what about this?
    >
    > len = strnchr(elm->rxbuf, elm->rxfill, '\r');

    Actually I'd use memchr() if anything, but not really here. I do end up
    using the actual index. And since both strchr() and mrmchr() return
    pointers, I'd rather avoid them because I prefer to use indices
    whenever possible.


    Max

    \
     
     \ /
      Last update: 2022-05-13 21:00    [W:2.917 / U:0.228 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site