lkml.org 
[lkml]   [2011]   [Sep]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCHv2] fat: don't use custom hex_to_bin()
Date
Andy Shevchenko <andy.shevchenko@gmail.com> writes:

> Actually here we will change endianess.
> So, my question is what endianess is right here? If the original code
> okay, then patch should be rewritten like this:
>
> rc = hex2bin(op++, ip + 3, 1);
> if (rc < 0)
> return -EINVAL;
>
> rc = hex2bin(op++, ip + 1, 1);
> if (rc < 0)
> return -EINVAL;

Original code may work only for little endian. Well, anyway, the output
should be wchar_t (u16) of native endian.

So, I think it should be something like

u8 uc[2];
if (hex2bin(uc, ip + 1, 2) < 0)
return -EINVAL;
*(wchar_t *)op = uc[0] << 8 | uc[1];

This should be readable more.

Thanks.
--
OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>


\
 
 \ /
  Last update: 2011-09-28 01:19    [W:0.065 / U:0.916 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site