Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: [PATCH 4/5] fs: fat: use hex_asc_lo/hex_asc_hi instead of custom one

0 views
Skip to first unread message

OGAWA Hirofumi

unread,
Mar 10, 2010, 6:20:01 PM3/10/10
to
Andy Shevchenko <andy.sh...@gmail.com> writes:

> if (uni_xlate == 1) {
> - *op = ':';
> - for (k = 4; k > 0; k--) {
> - nc = ec & 0xF;
> - op[k] = nc > 9 ? nc + ('a' - 10)
> - : nc + '0';
> - ec >>= 4;
> - }
> - op += 5;
> + *op++ = ':';
> + *op++ = hex_asc_hi(ec >> 8);
> + *op++ = hex_asc_lo(ec >> 8);
> + *op++ = hex_asc_hi(ec);
> + *op++ = hex_asc_lo(ec);
> len -= 5;

Why doesn't this use pack_hex_byte()?

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

Andy Shevchenko

unread,
Mar 11, 2010, 2:20:01 AM3/11/10
to
On Thu, Mar 11, 2010 at 1:18 AM, OGAWA Hirofumi
<hiro...@mail.parknet.co.jp> wrote:
>> +                             *op++ = hex_asc_hi(ec >> 8);
>> +                             *op++ = hex_asc_lo(ec >> 8);
>> +                             *op++ = hex_asc_hi(ec);
>> +                             *op++ = hex_asc_lo(ec);
> Why doesn't this use pack_hex_byte()?
No specific reason, it could be so. Would you like me to change this?

--
With Best Regards,
Andy Shevchenko

Joe Perches

unread,
Mar 11, 2010, 2:30:03 AM3/11/10
to
On Thu, 2010-03-11 at 08:18 +0900, OGAWA Hirofumi wrote:
> Andy Shevchenko <andy.sh...@gmail.com> writes:
>
> > if (uni_xlate == 1) {
> > - *op = ':';
> > - for (k = 4; k > 0; k--) {
> > - nc = ec & 0xF;
> > - op[k] = nc > 9 ? nc + ('a' - 10)
> > - : nc + '0';
> > - ec >>= 4;
> > - }
> > - op += 5;
> > + *op++ = ':';
> > + *op++ = hex_asc_hi(ec >> 8);
> > + *op++ = hex_asc_lo(ec >> 8);
> > + *op++ = hex_asc_hi(ec);
> > + *op++ = hex_asc_lo(ec);
> > len -= 5;
>
> Why doesn't this use pack_hex_byte()?

or snprintf

Andy Shevchenko

unread,
Mar 11, 2010, 3:10:01 AM3/11/10
to
On Thu, Mar 11, 2010 at 9:21 AM, Joe Perches <j...@perches.com> wrote:
>> > +                           *op++ = hex_asc_hi(ec >> 8);
>> > +                           *op++ = hex_asc_lo(ec >> 8);
>> > +                           *op++ = hex_asc_hi(ec);
>> > +                           *op++ = hex_asc_lo(ec);
>> Why doesn't this use pack_hex_byte()?
> or snprintf
sprintf looks like overkill here.

Joe Perches

unread,
Mar 11, 2010, 3:20:03 AM3/11/10
to

It's shorter and more intelligible though

op += sprintf(op, ":%04x:%04x", etc)

cheers, Joe

OGAWA Hirofumi

unread,
Mar 11, 2010, 4:10:02 AM3/11/10
to
Andy Shevchenko <andy.sh...@gmail.com> writes:

Yes, please change it if you have no problem.

Andy Shevchenko

unread,
Mar 11, 2010, 10:10:01 AM3/11/10
to
From: Andy Shevchenko <ext-andriy...@nokia.com>

Signed-off-by: Andy Shevchenko <ext-andriy...@nokia.com>
---
fs/fat/dir.c | 14 +++++---------
1 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/fs/fat/dir.c b/fs/fat/dir.c
index 530b4ca..5de1a70 100644
--- a/fs/fat/dir.c
+++ b/fs/fat/dir.c
@@ -19,6 +19,7 @@
#include <linux/buffer_head.h>
#include <linux/compat.h>
#include <asm/uaccess.h>
+#include <linux/kernel.h>
#include "fat.h"

/*
@@ -149,19 +150,14 @@ static int uni16_to_x8(unsigned char *ascii, const wchar_t *uni, int len,

while (*ip && ((len - NLS_MAX_CHARSET_SIZE) > 0)) {
ec = *ip++;
- if ( (charlen = nls->uni2char(ec, op, NLS_MAX_CHARSET_SIZE)) > 0) {
+ if ((charlen = nls->uni2char(ec, op, NLS_MAX_CHARSET_SIZE)) > 0) {
op += charlen;
len -= charlen;
} else {


if (uni_xlate == 1) {
- *op = ':';
- for (k = 4; k > 0; k--) {
- nc = ec & 0xF;
- op[k] = nc > 9 ? nc + ('a' - 10)
- : nc + '0';
- ec >>= 4;
- }
- op += 5;
+ *op++ = ':';

+ op = pack_hex_byte(op, ec >> 8);
+ op = pack_hex_byte(op, ec);
len -= 5;
} else {
*op++ = '?';
--
1.5.6.5

OGAWA Hirofumi

unread,
Mar 11, 2010, 10:20:01 AM3/11/10
to
Andy Shevchenko <andy.sh...@gmail.com> writes:

> From: Andy Shevchenko <ext-andriy...@nokia.com>
>
> Signed-off-by: Andy Shevchenko <ext-andriy...@nokia.com>

Looks good to me.

Acked-by: OGAWA Hirofumi <hiro...@mail.parknet.co.jp>

(From 1/4 with previous patch, I guess it's series of patches) Or I
should take this patch into my tree?

Thanks.

--
OGAWA Hirofumi <hiro...@mail.parknet.co.jp>

Andy Shevchenko

unread,
Mar 11, 2010, 10:20:01 AM3/11/10
to
On Thu, Mar 11, 2010 at 5:12 PM, OGAWA Hirofumi
<hiro...@mail.parknet.co.jp> wrote:
> (From 1/4 with previous patch, I guess it's series of patches) Or I
> should take this patch into my tree?
It has only one in common - cleanup. Basically it's a bunch of
independent fixes.
Please, take it in your tree. thank you.

--
With Best Regards,
Andy Shevchenko

OGAWA Hirofumi

unread,
Mar 13, 2010, 6:10:01 AM3/13/10
to
Andy Shevchenko <andy.sh...@gmail.com> writes:

> const wchar_t *ip;
> wchar_t ec;
> - unsigned char *op, nc;
> + unsigned char *op;
> int charlen;
> - int k;

Ah, thanks. I fixed this myself before commit.

0 new messages