Re: [PATCHv3] fat: don't use custom hex_to_bin()

From: OGAWA Hirofumi
Date: Thu Sep 29 2011 - 10:51:59 EST


Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx> writes:

> + /* The ip contains 2 bytes in little
> + * endian format. We need to get them
> + * in native endian. */
> +
> + rc = hex2bin(op++, ip + 3, 1);
> + if (rc < 0)
> + return -EINVAL;
> +
> + rc = hex2bin(op++, ip + 1, 1);
> + if (rc < 0)
> return -EINVAL;
> - }
> - *op++ = ec & 0xFF;
> - *op++ = ec >> 8;
> +

It will not work for big endian arch correctly like original code.

"ip" is made like following,

if (uni_xlate == 1) {
*op++ = ':';
op = pack_hex_byte(op, ec >> 8);
op = pack_hex_byte(op, ec);
len -= 5;
} else {


Maybe, my explanation was not good. Like above, "ip" format is like
":1234" (can say big endian, it's the string though), so, this code made
a unicode char (op) as little endian.

Thanks.
--
OGAWA Hirofumi <hirofumi@xxxxxxxxxxxxxxxxxx>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/