From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Rasmus Villemoes <linux@rasmusvillemoes.dk>,
Andrew Morton <akpm@linux-foundation.org>
Cc: Tejun Heo <tj@kernel.org>,
linux-kernel@vger.kernel.org, Kees Cook <keescook@chromium.org>,
Joe Perches <joe@perches.com>
Subject: Re: [PATCH v2 3/4] lib/vsprintf.c: Remove SPECIAL handling in pointer()
Date: Wed, 30 Sep 2015 18:40:54 +0300 [thread overview]
Message-ID: <1443627654.8361.315.camel@linux.intel.com> (raw)
In-Reply-To: <1443627051-14003-4-git-send-email-linux@rasmusvillemoes.dk>
On Wed, 2015-09-30 at 17:30 +0200, Rasmus Villemoes wrote:
> As a quick
>
> git grep -E '%[ +0#-]*#[ +0#-]*(\*|[0-9]+)?(\.(\*|[0-9]+)?)?p'
>
> shows, nobody uses the # flag with %p. Should one try to do so, one
> will be met with
>
> warning: `#' flag used with ‘%p’ gnu_printf format [-Wformat]
>
> (POSIX and C99 both say "... For other conversion specifiers, the
> behavior is undefined.". Obviously, the kernel can choose to define
> the behaviour however it wants, but as long as gcc issues that
> warning, users are unlikely to show up.)
>
> Since default_width is effectively always 2*sizeof(void*), we can
> simplify the prologue of pointer() and save a few instructions.
>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
> ---
> v2: reword slightly, refer to POSIX/C99.
>
> lib/vsprintf.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/vsprintf.c b/lib/vsprintf.c
> index 03fa10b4be96..98b0d7be3fb7 100644
> --- a/lib/vsprintf.c
> +++ b/lib/vsprintf.c
> @@ -1457,7 +1457,7 @@ static noinline_for_stack
> char *pointer(const char *fmt, char *buf, char *end, void *ptr,
> struct printf_spec spec)
> {
> - int default_width = 2 * sizeof(void *) + (spec.flags &
> SPECIAL ? 2 : 0);
> + const int default_width = 2 * sizeof(void *);
>
> if (!ptr && *fmt != 'K') {
> /*
--
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy
next prev parent reply other threads:[~2015-09-30 15:41 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-25 17:41 [PATCH 0/4] printf stuff Rasmus Villemoes
2015-09-25 17:41 ` [PATCH 1/4] lib/vsprintf.c: handle invalid format specifiers more robustly Rasmus Villemoes
2015-09-28 8:08 ` Andy Shevchenko
2015-09-28 20:12 ` Rasmus Villemoes
2015-09-28 22:30 ` Kees Cook
2015-09-25 17:41 ` [PATCH 2/4] lib/vsprintf.c: also improve sanity check in bstr_printf() Rasmus Villemoes
2015-09-28 22:31 ` Kees Cook
2015-09-25 17:41 ` [PATCH 3/4] lib/vsprintf.c: Remove SPECIAL handling in pointer() Rasmus Villemoes
2015-09-28 8:55 ` Andy Shevchenko
2015-09-25 17:41 ` [PATCH 4/4] test_printf: test printf family at runtime Rasmus Villemoes
2015-09-28 9:12 ` Andy Shevchenko
2015-09-28 20:55 ` Rasmus Villemoes
2015-09-30 6:38 ` Andy Shevchenko
2015-09-30 8:56 ` Rasmus Villemoes
2015-09-28 22:38 ` Kees Cook
2015-09-29 7:10 ` Rasmus Villemoes
2015-09-29 17:32 ` Kees Cook
2015-09-30 9:05 ` Rasmus Villemoes
2015-09-30 15:30 ` [PATCH v2 0/4] printf stuff Rasmus Villemoes
2015-09-30 15:30 ` [PATCH v2 1/4] lib/vsprintf.c: handle invalid format specifiers more robustly Rasmus Villemoes
2015-09-30 15:30 ` [PATCH v2 2/4] lib/vsprintf.c: also improve sanity check in bstr_printf() Rasmus Villemoes
2015-09-30 15:30 ` [PATCH v2 3/4] lib/vsprintf.c: Remove SPECIAL handling in pointer() Rasmus Villemoes
2015-09-30 15:40 ` Andy Shevchenko [this message]
2015-09-30 15:30 ` [PATCH v2 4/4] test_printf: test printf family at runtime Rasmus Villemoes
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1443627654.8361.315.camel@linux.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=akpm@linux-foundation.org \
--cc=joe@perches.com \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=tj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.