Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1236461
| From | Andy Shevchenko <andriy.shevchenko@linux.intel.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH v2 3/4] lib/vsprintf.c: Remove SPECIAL handling in pointer() |
| Date | 2015-09-30 17:50 +0200 |
| Message-ID | <qerNO-SV-63@gated-at.bofh.it> (permalink) |
| References | <qcFia-8p1-11@gated-at.bofh.it> <qerE6-Hh-7@gated-at.bofh.it> <qerE6-Hh-19@gated-at.bofh.it> |
| Organization | Intel Finland Oy |
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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread
[PATCH 0/4] printf stuff Rasmus Villemoes <linux@rasmusvillemoes.dk> - 2015-09-25 19:50 +0200
[PATCH 4/4] test_printf: test printf family at runtime Rasmus Villemoes <linux@rasmusvillemoes.dk> - 2015-09-25 19:50 +0200
Re: [PATCH 4/4] test_printf: test printf family at runtime Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2015-09-28 11:20 +0200
Re: [PATCH 4/4] test_printf: test printf family at runtime Rasmus Villemoes <linux@rasmusvillemoes.dk> - 2015-09-28 23:00 +0200
Re: [PATCH 4/4] test_printf: test printf family at runtime Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2015-09-30 08:40 +0200
Re: [PATCH 4/4] test_printf: test printf family at runtime Rasmus Villemoes <linux@rasmusvillemoes.dk> - 2015-09-30 11:00 +0200
Re: [PATCH 4/4] test_printf: test printf family at runtime Kees Cook <keescook@chromium.org> - 2015-09-29 00:40 +0200
Re: [PATCH 4/4] test_printf: test printf family at runtime Rasmus Villemoes <linux@rasmusvillemoes.dk> - 2015-09-29 09:20 +0200
Re: [PATCH 4/4] test_printf: test printf family at runtime Kees Cook <keescook@chromium.org> - 2015-09-29 19:40 +0200
Re: [PATCH 4/4] test_printf: test printf family at runtime Rasmus Villemoes <linux@rasmusvillemoes.dk> - 2015-09-30 11:10 +0200
[PATCH v2 1/4] lib/vsprintf.c: handle invalid format specifiers more robustly Rasmus Villemoes <linux@rasmusvillemoes.dk> - 2015-09-30 17:40 +0200
[PATCH v2 0/4] printf stuff Rasmus Villemoes <linux@rasmusvillemoes.dk> - 2015-09-30 17:40 +0200
[PATCH v2 4/4] test_printf: test printf family at runtime Rasmus Villemoes <linux@rasmusvillemoes.dk> - 2015-09-30 17:40 +0200
[PATCH v2 2/4] lib/vsprintf.c: also improve sanity check in bstr_printf() Rasmus Villemoes <linux@rasmusvillemoes.dk> - 2015-09-30 17:40 +0200
[PATCH v2 3/4] lib/vsprintf.c: Remove SPECIAL handling in pointer() Rasmus Villemoes <linux@rasmusvillemoes.dk> - 2015-09-30 17:40 +0200
Re: [PATCH v2 3/4] lib/vsprintf.c: Remove SPECIAL handling in pointer() Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2015-09-30 17:50 +0200
csiph-web