The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>,
	Jiri Kosina <jkosina@suse.cz>, Joe Perches <joe@perches.com>,
	Al Viro <viro@zeniv.linux.org.uk>,
	"David S. Miller" <davem@davemloft.net>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] lib/vsprintf: add %pT[C012] format specifier
Date: Sat, 28 Dec 2013 11:25:09 -0800	[thread overview]
Message-ID: <20131228112509.8a62548c.akpm@linux-foundation.org> (raw)
In-Reply-To: <CAMuHMdXVrL-9Fq3ixCZvh1TubGg7HFc0HKPbq-YYu+Q1zxWcEA@mail.gmail.com>

On Sat, 28 Dec 2013 19:57:50 +0100 Geert Uytterhoeven <geert@linux-m68k.org> wrote:

> > If we introduce a character which compiler does not know that follows the %
> > character, compiler would be confused when checking type of corresponding
> > argument.
> >
> >> I wonder if there's some way in which we can invent a vsprintf token
> >> which means "insert corrent->comm here" and which doesn't require that
> >> the caller pass in the additional argument?
> >
> > Therefore, if we want to omit passing corresponding argument, we should not
> > introduce new character which compiler does not know that follows the %
> > character.
> >
> > Also, % is the only character which everybody knows that it is reserved for the
> > beginning of format specifier and %% is the only characters which everybody
> > knows that it is reserved for literal % character.
> >
> > Therefore, what we could do for printing current thread's attributes would be
> > either reserve a new character and add EXTENSION like
> >
> >   pr_warn("$comm$: hair on fire\n");
> >   pr_warn("Process $pid$: hair on fire\n");
> >
> > or add EXTENSION after the %% characters like
> >
> >   pr_warn("%%comm%%: hair on fire\n");
> >   pr_warn("Process %%pid%%: hair on fire\n");
> 
> ESC sequences? So far printk() doesn't parse them (a bit unfortunate, as I
> always liked the idea of printing error messages in red, warnings in yellow,
> etc.).
> 
> Is any of the "\x" (backslash + character) unused and thus available?

I guess control characters would work.

#define PRINTK_COMM	"\001"
#define PRINTK_PID	"\002"
#define PRINTK_TASK_ID	"\003"	/* "comm:pid" */

	printk(PRINTK_TASK_ID ": hair on fire\n");

It's certainly compact.  I doubt if there's any existing code which
deliberately prints control chars?


  reply	other threads:[~2013-12-28 19:23 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-25 12:37 [PATCH] lib/vsprintf: add %pT[C012] format specifier Tetsuo Handa
2013-12-26  8:43 ` Joe Perches
2013-12-27 23:02 ` Andrew Morton
2013-12-28  3:43   ` Tetsuo Handa
2013-12-28 18:57     ` Geert Uytterhoeven
2013-12-28 19:25       ` Andrew Morton [this message]
2013-12-28 19:25         ` Geert Uytterhoeven
2013-12-28 19:53           ` Joe Perches
2013-12-28 20:08             ` Andrew Morton
2013-12-28 20:24               ` Joe Perches
2013-12-29  0:32                 ` Tetsuo Handa
2013-12-29  2:07                   ` Joe Perches
2013-12-29 12:13                     ` Tetsuo Handa
2013-12-30 16:55                       ` Joe Perches
2013-12-31  6:53                         ` Tetsuo Handa
2013-12-31 16:24                           ` Joe Perches
2014-01-01  5:34                             ` Tetsuo Handa
2014-01-01  5:49                               ` Joe Perches
2014-01-01 10:02                                 ` Tetsuo Handa
2014-01-02  1:33                                   ` Joe Perches
2014-01-02  4:49                                     ` Tetsuo Handa
2014-01-03 17:08                                       ` Kees Cook
2014-01-03 17:39                                         ` Joe Perches
2014-01-03 17:49                                           ` Kees Cook
2014-01-04  2:26                                             ` Tetsuo Handa
2014-01-05  3:15                                               ` Tetsuo Handa
2014-01-05 18:09                                                 ` Joe Perches
2014-01-06 14:00                                                   ` Tetsuo Handa
2014-01-06 17:34                                                     ` Joe Perches
2014-01-06 21:41                                                       ` Tetsuo Handa
2014-01-06 22:25                                                         ` Joe Perches
2014-01-07  0:16                                                           ` Pavel Machek
2014-01-07  1:03                                                             ` Joe Perches
2014-01-07  8:37                                                               ` Pavel Machek
2014-01-07 17:34                                                                 ` Joe Perches
2014-01-07 17:56                                                                   ` Pavel Machek
2014-01-07 18:28                                                                     ` Geert Uytterhoeven
2014-01-08 14:19                                                                     ` Tetsuo Handa
2014-01-08 14:46                                                                       ` Pavel Machek
2014-01-06 21:34                                                     ` Pavel Machek
2014-01-05 22:27                                                 ` Pavel Machek
2014-01-06 14:02                                                   ` Tetsuo Handa
2014-01-10 13:15                                                     ` Tetsuo Handa
2014-01-02  1:38                                   ` Joe Perches
2014-01-02 11:51               ` Pavel Machek

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=20131228112509.8a62548c.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=davem@davemloft.net \
    --cc=geert@linux-m68k.org \
    --cc=jkosina@suse.cz \
    --cc=joe@perches.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=penguin-kernel@i-love.sakura.ne.jp \
    --cc=viro@zeniv.linux.org.uk \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox