mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "George Spelvin" <linux@horizon.com>
To: keescook@chromium.org, linux-kernel@vger.kernel.org
Cc: akpm@linux-foundation.org, dan.carpenter@oracle.com,
	JBeulich@suse.com, joe@perches.com, kosaki.motohiro@gmail.com,
	linux@horizon.com, penguin-kernel@i-love.sakura.ne.jp,
	viro@zeniv.linux.org.uk
Subject: Re: [PATCH 1/2] remove all uses of printf's %n
Date: 16 Sep 2013 12:07:17 -0400	[thread overview]
Message-ID: <20130916160717.1621.qmail@science.horizon.com> (raw)
In-Reply-To: <1379317437-28329-2-git-send-email-keescook@chromium.org>

> All users of %n are calculating padding size when using seq_file, so
> instead use the new last_len member for discovering the length of the
> written strings.

Obviously, this comment needs to be updated, but once that is done,
Acked-by: George Spelvin <linux@horizon.com>.

I actually reviewed all the users and checked that things work
properly.  In the various VMA map and tcp state lists, the line
width (128 or the now-misnamed TMPSZ=150) is greatly in excess of
what's required, presumably to facilitate computing the iteration
index from the file position in pre-seqfile days.

If the line were to ever get longer than that, the semantics of
printf("%*s", -5, "") would give strange results, but that's
a pre-existing problem that is unlikely to occur, would probably
be harmless (as would deleting the trailing whitespace!), and
isn't made any worse by this.


HOWEVER, it gave me an idea.  We could put this padding logic straight
into vsprintf and clean up all the callers.

I'm currently thinking that a precision specifier in %c (%.*c) is
currently meaningless and ignored.  What if we usurped it and defined
it to mean "pad with this character until the total width so far this
rint reaches the specified precision"?

That would DTRT for all the callers.

Oh, bugger, gcc -Wformat warns about doing that.  And %#127c.  And
everything else I can think of.  The only way to sneak it past gcc
would be to usurp the rarely-used %-127c format.

Since the only pad character currently used is space, we could omit the
argument and use something like %127%, but gcc gets even more confused
by that.

The code is easy enough.  But any suggestions for ways to represent it
in the format string would be appreciated.

  parent reply	other threads:[~2013-09-16 16:07 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-16  7:43 [PATCH 0/2] vsprintf: ignore %n again Kees Cook
2013-09-16  7:43 ` [PATCH 1/2] remove all uses of printf's %n Kees Cook
2013-09-16  8:09   ` Geert Uytterhoeven
2013-09-16 15:00     ` Kees Cook
2013-09-17 13:06       ` Tetsuo Handa
2013-09-17 14:34         ` Kees Cook
2013-09-17 20:57           ` George Spelvin
2013-09-19  8:56             ` Tetsuo Handa
2013-09-19 14:28               ` Kees Cook
2013-09-20  4:09                 ` Tetsuo Handa
2013-09-20  4:23                   ` Joe Perches
2013-09-20  4:53                     ` Kees Cook
2013-09-20  8:08                   ` Jiri Slaby
2013-09-20 19:24                     ` Kees Cook
2013-09-20 19:33                       ` Joe Perches
2013-09-21  0:28                       ` Tetsuo Handa
2013-09-22  8:09                         ` George Spelvin
2013-09-22  8:16                         ` Geert Uytterhoeven
2013-09-23 21:24                   ` Kees Cook
2013-09-30  8:16                     ` Tetsuo Handa
2013-09-16 11:41   ` Tetsuo Handa
2013-09-16 14:59     ` Kees Cook
2013-09-16 15:09       ` Joe Perches
2013-09-16 15:25         ` Kees Cook
2013-09-16 15:44           ` Joe Perches
2013-09-16 17:21         ` George Spelvin
2013-09-16 18:03           ` Joe Perches
2013-09-16 16:07   ` George Spelvin [this message]
2013-09-16 16:13     ` Joe Perches
2013-09-16 16:39       ` George Spelvin
2013-09-16 17:53         ` Joe Perches
2013-09-16 19:15           ` George Spelvin
2013-09-16 19:25             ` Joe Perches
2013-09-16  7:43 ` [PATCH 2/2] vsprintf: ignore %n again Kees Cook
2013-09-16 15:55 ` [PATCH 0/2] " Al Viro
2013-09-16 16:15   ` Lars-Peter Clausen
2013-09-16 16:30   ` George Spelvin
2013-09-16 18:20   ` Kees Cook
2013-09-18 13:14     ` Tetsuo Handa
2013-09-18 14:11       ` Dan Carpenter
2013-09-18 14:28         ` Dan Carpenter
2013-09-18 15:22         ` George Spelvin
2013-09-18 14:32       ` Kees Cook
2013-09-19  2:11         ` Tetsuo Handa
2013-09-19  7:08           ` Tetsuo Handa
2013-09-18 14:47       ` Kees Cook

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=20130916160717.1621.qmail@science.horizon.com \
    --to=linux@horizon.com \
    --cc=JBeulich@suse.com \
    --cc=akpm@linux-foundation.org \
    --cc=dan.carpenter@oracle.com \
    --cc=joe@perches.com \
    --cc=keescook@chromium.org \
    --cc=kosaki.motohiro@gmail.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

all inboxes | Powered by JetHome®