From: Frederic Weisbecker <fweisbec@gmail.com>
To: "André Goddard Rosa" <andre.goddard@gmail.com>
Cc: laijs@cn.fujitsu.com, mingo@elte.hu, davem@davemloft.net,
akpm@linux-foundation.org, harvey.harrison@gmail.com,
linux list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] vsprintf: reduce code size, clean up
Date: Mon, 2 Nov 2009 00:18:58 +0100 [thread overview]
Message-ID: <20091101231857.GD5263@nowhere> (raw)
In-Reply-To: <b8bf37780911011500o741bef51sf8a057e2cedcf22c@mail.gmail.com>
On Sun, Nov 01, 2009 at 09:00:48PM -0200, André Goddard Rosa wrote:
> Hi, Frederic!
>
> On Sun, Nov 1, 2009 at 8:45 PM, Frederic Weisbecker <fweisbec@gmail.com> wrote:
> > On Sun, Nov 01, 2009 at 03:01:40PM -0200, André Goddard Rosa wrote:
> >> +static char null[] = "(null)";
> >> +
> >
> >
> > This should be static const.
> > Also, may be chose a better name, as "null" is too much
> > generic and somehow collide with NULL.
> >
> > null_str ?
> >
>
> If I make it a "static const" it's necessary to cast it in two places
> to "char *" and code size goes up
>
> lib/vsprintf.c: In function ‘string’:
> lib/vsprintf.c:556: warning: assignment discards qualifiers from
> pointer target type
> lib/vsprintf.c: In function ‘pointer’:
> lib/vsprintf.c:828: warning: passing argument 3 of ‘string’ discards
> qualifiers from pointer target type
> lib/vsprintf.c:551: note: expected ‘char *’ but argument is of type
> ‘const char *’
>
> text data bss dec hex filename
> 15383 7 8 15398 3c26 lib/vsprintf.o-static-before
> 15431 0 8 15439 3c4f lib/vsprintf.o-static-const-after
>
> as it moves the variable from data section to code section. Is this
> the preferred method?
>
Hm, that:
static const char *null = "(null)";
is supposed to go to .rodata
Anyway, yeah better make it a const. When it's used, the variable
is not changed.
save_str in vbin_printf() is already a const char.
The "s" parameter in string() can be safely turned into const.
> Thanks for reviewing! I'll fix the other points per your suggestions
> and post back.
>
> With regards,
> André
Thanks.
next prev parent reply other threads:[~2009-11-01 23:18 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-01 17:01 [PATCH] vsprintf: reduce code size, clean up André Goddard Rosa
2009-11-01 22:45 ` Frederic Weisbecker
2009-11-01 23:00 ` André Goddard Rosa
2009-11-01 23:18 ` Frederic Weisbecker [this message]
2009-11-02 18:13 ` Andreas Schwab
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=20091101231857.GD5263@nowhere \
--to=fweisbec@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=andre.goddard@gmail.com \
--cc=davem@davemloft.net \
--cc=harvey.harrison@gmail.com \
--cc=laijs@cn.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
/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