lkml.org 
[lkml]   [2011]   [Sep]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCHv4] fat: don't use custom hex_to_bin()
Date
Joe Perches <joe@perches.com> writes:

>> +
>> + if (hex2bin(uc, ip + 1, 2) < 0)
>> return -EINVAL;
>> - }
>> - *op++ = ec & 0xFF;
>> - *op++ = ec >> 8;
>> +
>> + *(wchar_t *)op++ = uc[0] << 8 | uc[1];
>
> perhaps:
>
> __le16 foo;
>
> if (hex2bin((u8 *)&foo, ip + 1, 2) < 0)
> return -EINVAL;
> *(u16 *)op = le16_to_cpu(foo);
>
> op += 2;

I also thought about it. But I think it is not so good, like you had
mistake. It should actually be "__be16 foo" and "be16_to_cpu()".

If we used sscanf() instead of hex2bin(), I might agree to use
"le16_to_cpu()" though.

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


\
 
 \ /
  Last update: 2011-09-29 20:31    [W:0.072 / U:0.364 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site