[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHp75VfOjRL3w-tFLkyWAy3eh-wUOmCd9i5BGscoW=noqjbmBA@mail.gmail.com>
Date: Thu, 5 Jul 2012 11:02:28 +0300
From: Andy Shevchenko <andy.shevchenko@...il.com>
To: Joe Perches <joe@...ches.com>
Cc: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Andrew Morton <akpm@...ux-foundation.org>, proski@....org,
Andrei Emeltchenko <andrei.emeltchenko@...el.com>,
linux-wireless@...r.kernel.org,
LKML <linux-kernel@...r.kernel.org>,
Larry Finger <Larry.Finger@...inger.net>
Subject: Re: [PATCHv3 2/3] lib: printf: append support of '%*ph[CDN]'
On Wed, Jul 4, 2012 at 6:09 PM, Joe Perches <joe@...ches.com> wrote:
> On Wed, 2012-07-04 at 11:45 +0300, Andy Shevchenko wrote:
>> This patch adds a support of the variable width buffer to print it
>> as a hex string with a delimiter.
>> + if (spec.field_width <= 0)
>> + /* nothing to print */
>> + return buf;
>
> It may be better to default to a 1 and add
>
> if (addr == ZERO_OR_NULL_PTR)
>
> to avoid dereferencing a NULL or a pointer
> to a zero length object.
Good point.
>> + for (p = hex_str; *p != '\0'; p++) {
>> + if (buf < end)
>> + *buf = *p;
>> + ++buf;
>> + }
>
> why not just directly write to *buf as long as buf < end?
buf < end - 1, otherwise correct.
And yes, it eliminates hex_str array as well.
--
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists