From: Jiri Slaby <jslaby@suse•cz>
To: Tetsuo Handa <penguin-kernel@I-love•SAKURA.ne.jp>,
viro@zeniv•linux.org.uk, xemul@openvz•org,
remi.denis-courmont@nokia•com
Cc: keescook@chromium•org, linux-kernel@vger•kernel.org,
netdev@vger•kernel.org, linux-sctp@vger•kernel.org,
linux@horizon•com, akpm@linux-foundation•org,
dan.carpenter@oracle•com, geert@linux-m68k•org,
JBeulich@suse•com, joe@perches•com, kosaki.motohiro@gmail•com
Subject: Re: [PATCH 1/2] remove all uses of printf's %n
Date: Fri, 20 Sep 2013 10:08:08 +0200 [thread overview]
Message-ID: <523C0268.20404@suse.cz> (raw)
In-Reply-To: <201309201309.GFB52620.OQOtSFLMJVHOFF@I-love.SAKURA.ne.jp>
On 09/20/2013 06:09 AM, Tetsuo Handa wrote:
> --- a/fs/proc/consoles.c
> +++ b/fs/proc/consoles.c
...
> @@ -47,11 +46,10 @@ static int show_console_dev(struct seq_file *m, void *v)
> con_flags[a].name : ' ';
> flags[a] = 0;
>
> - seq_printf(m, "%s%d%n", con->name, con->index, &len);
> - len = 21 - len;
> - if (len < 1)
> - len = 1;
> - seq_printf(m, "%*c%c%c%c (%s)", len, ' ', con->read ? 'R' : '-',
> + seq_setwidth(m, 21 - 1);
> + seq_printf(m, "%s%d", con->name, con->index);
> + seq_pad(m, ' ');
> + seq_printf(m, "%c%c%c (%s)", con->read ? 'R' : '-',
> con->write ? 'W' : '-', con->unblank ? 'U' : '-',
> flags);
Hello, do you really need seq_setwidth? It makes it really ugly...
Or do we need that all? Couldn't we simply have seq_printf_padded? Or
maybe some % modifier in seq_printf to pad the string?
> --- a/net/ipv4/fib_trie.c
> +++ b/net/ipv4/fib_trie.c
...
> @@ -2548,15 +2549,15 @@ static int fib_route_seq_show(struct seq_file *seq, void *v)
> (fi->fib_advmss ?
> fi->fib_advmss + 40 : 0),
> fi->fib_window,
> - fi->fib_rtt >> 3, &len);
> + fi->fib_rtt >> 3);
> else
> seq_printf(seq,
> "*\t%08X\t%08X\t%04X\t%d\t%u\t"
> - "%d\t%08X\t%d\t%u\t%u%n",
> + "%d\t%08X\t%d\t%u\t%u",
> prefix, 0, flags, 0, 0, 0,
> - mask, 0, 0, 0, &len);
> + mask, 0, 0, 0);
>
> - seq_printf(seq, "%*s\n", 127 - len, "");
> + seq_pad(seq, '\n');
Hmm, seq_pad is unintuitive. I would say it pads the string by '\n'. Of
course it does not, but...
thanks,
--
js
suse labs
next prev parent reply other threads:[~2013-09-20 8:08 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CAGXu5jL+NeBw2_vXymM81UdtS6UO7KZA2S4rf3gwM_7nSJ2h6g@mail.gmail.com>
[not found] ` <20130917205742.16147.qmail@science.horizon.com>
[not found] ` <201309191756.BCF65661.MQFOLSJOFHFtOV@I-love.SAKURA.ne.jp>
[not found] ` <CAGXu5jK_D1BJOQr=1A-UFrpM5Ad+Qu894HT_XjkZh4EmsbCkTQ@mail.gmail.com>
2013-09-20 4:09 ` [PATCH 1/2] remove all uses of printf's %n Tetsuo Handa
2013-09-20 4:23 ` Joe Perches
2013-09-20 4:53 ` Kees Cook
2013-09-20 8:08 ` Jiri Slaby [this message]
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
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=523C0268.20404@suse.cz \
--to=jslaby@suse$(echo .)cz \
--cc=JBeulich@suse$(echo .)com \
--cc=akpm@linux-foundation$(echo .)org \
--cc=dan.carpenter@oracle$(echo .)com \
--cc=geert@linux-m68k$(echo .)org \
--cc=joe@perches$(echo .)com \
--cc=keescook@chromium$(echo .)org \
--cc=kosaki.motohiro@gmail$(echo .)com \
--cc=linux-kernel@vger$(echo .)kernel.org \
--cc=linux-sctp@vger$(echo .)kernel.org \
--cc=linux@horizon$(echo .)com \
--cc=netdev@vger$(echo .)kernel.org \
--cc=penguin-kernel@I-love$(echo .)SAKURA.ne.jp \
--cc=remi.denis-courmont@nokia$(echo .)com \
--cc=viro@zeniv$(echo .)linux.org.uk \
--cc=xemul@openvz$(echo .)org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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