From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] net: can: remove custom hex_to_bin()
Date: Mon, 18 Jul 2011 15:23:16 +0300 [thread overview]
Message-ID: <1310991796.3903.6.camel@smile> (raw)
In-Reply-To: <201107182041.EHB78622.VOFSHFMOOFtLJQ@I-love.SAKURA.ne.jp>
On Mon, 2011-07-18 at 20:41 +0900, Tetsuo Handa wrote:
> Andy Shevchenko wrote:
> > for (i = 0, dlc_pos++; i < cf.can_dlc; i++) {
> > -
> > - tmp = asc2nibble(sl->rbuff[dlc_pos++]);
> > - if (tmp > 0x0F)
> > + tmp = hex_to_bin(sl->rbuff[dlc_pos++]);
> > + if (tmp < 0)
> > return;
> > cf.data[i] = (tmp << 4);
> > - tmp = asc2nibble(sl->rbuff[dlc_pos++]);
> > - if (tmp > 0x0F)
> > + tmp = hex_to_bin(sl->rbuff[dlc_pos++]);
> > + if (tmp < 0)
> > return;
> > cf.data[i] |= tmp;
> > }
>
> What about changing
>
> void hex2bin(u8 *dst, const char *src, size_t count)
>
> to
>
> bool hex2bin(u8 *dst, const char *src, size_t count)
>
> in order to do error checks like
>
> bool hex2bin_with_validation(u8 *dst, const char *src, size_t count)
> {
> while (count--) {
> int c = hex_to_bin(*src++);
> int d;
> if (c < 0)
> return false;
> d = hex_to_bin(*src++)
> if (d < 0)
> return false;
> *dst++ = (c << 4) | d;
> }
> return true;
> }
>
> and use hex2bin() rather than hex_to_bin()?
Perhaps, good idea. Could you submit a patch?
--
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy
next prev parent reply other threads:[~2011-07-18 12:23 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-18 8:26 [PATCH] net: can: remove custom hex_to_bin() Andy Shevchenko
2011-07-18 11:41 ` Tetsuo Handa
2011-07-18 12:23 ` Andy Shevchenko [this message]
2011-07-18 12:48 ` [PATCH] Add error check to hex2bin() Tetsuo Handa
2011-07-18 18:03 ` Mimi Zohar
2011-07-18 18:57 ` Andy Shevchenko
2011-07-18 19:20 ` Mimi Zohar
2011-07-18 19:44 ` Andy Shevchenko
2011-07-18 19:44 ` Andy Shevchenko
2011-07-18 21:43 ` Mimi Zohar
2011-07-18 20:49 ` Geert Uytterhoeven
2011-07-18 20:49 ` Geert Uytterhoeven
2011-07-18 21:18 ` Andy Shevchenko
2011-07-18 21:59 ` Mimi Zohar
2011-07-19 1:00 ` Mimi Zohar
2011-07-19 10:52 ` Mimi Zohar
2011-07-18 14:02 ` [PATCH] net: can: remove custom hex_to_bin() Oliver Hartkopp
2011-07-18 18:33 ` David Miller
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=1310991796.3903.6.camel@smile \
--to=andriy.shevchenko@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=penguin-kernel@I-love.SAKURA.ne.jp \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.