* [PATCH 1/1] kernel/profile.c: use static const char instead of static char
@ 2014-05-07 20:35 Fabian Frederick
2014-05-07 22:30 ` Andrew Morton
0 siblings, 1 reply; 3+ messages in thread
From: Fabian Frederick @ 2014-05-07 20:35 UTC (permalink / raw)
To: linux-kernel; +Cc: akpm, Paul Gortmaker
schedstr, sleepstr and kvmstr are only used in strcmp & strlen
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: Fabian Frederick <fabf@skynet.be>
---
kernel/profile.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/kernel/profile.c b/kernel/profile.c
index cb980f0..f8132a2 100644
--- a/kernel/profile.c
+++ b/kernel/profile.c
@@ -52,9 +52,9 @@ static DEFINE_MUTEX(profile_flip_mutex);
int profile_setup(char *str)
{
- static char schedstr[] = "schedule";
- static char sleepstr[] = "sleep";
- static char kvmstr[] = "kvm";
+ static const char schedstr[] = "schedule";
+ static const char sleepstr[] = "sleep";
+ static const char kvmstr[] = "kvm";
int par;
if (!strncmp(str, sleepstr, strlen(sleepstr))) {
--
1.8.4.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 1/1] kernel/profile.c: use static const char instead of static char
2014-05-07 20:35 [PATCH 1/1] kernel/profile.c: use static const char instead of static char Fabian Frederick
@ 2014-05-07 22:30 ` Andrew Morton
2014-05-07 22:35 ` Joe Perches
0 siblings, 1 reply; 3+ messages in thread
From: Andrew Morton @ 2014-05-07 22:30 UTC (permalink / raw)
To: Fabian Frederick; +Cc: linux-kernel, Paul Gortmaker
On Wed, 7 May 2014 22:35:08 +0200 Fabian Frederick <fabf@skynet.be> wrote:
> schedstr, sleepstr and kvmstr are only used in strcmp & strlen
>
> ...
>
> --- a/kernel/profile.c
> +++ b/kernel/profile.c
> @@ -52,9 +52,9 @@ static DEFINE_MUTEX(profile_flip_mutex);
>
> int profile_setup(char *str)
> {
> - static char schedstr[] = "schedule";
> - static char sleepstr[] = "sleep";
> - static char kvmstr[] = "kvm";
> + static const char schedstr[] = "schedule";
> + static const char sleepstr[] = "sleep";
> + static const char kvmstr[] = "kvm";
> int par;
>
I'd expect this to either make no change or to make text larger and
data smaller.
In fact,
text data bss dec hex filename
7631 811 3016 11458 2cc2 kernel/profile.o-before
7520 779 3016 11315 2c33 kernel/profile.o-after
Both text and data got smaller and the total reduction was a whopping
143 bytes. Weirdness.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1/1] kernel/profile.c: use static const char instead of static char
2014-05-07 22:30 ` Andrew Morton
@ 2014-05-07 22:35 ` Joe Perches
0 siblings, 0 replies; 3+ messages in thread
From: Joe Perches @ 2014-05-07 22:35 UTC (permalink / raw)
To: Andrew Morton; +Cc: Fabian Frederick, linux-kernel, Paul Gortmaker
On Wed, 2014-05-07 at 15:30 -0700, Andrew Morton wrote:
> On Wed, 7 May 2014 22:35:08 +0200 Fabian Frederick <fabf@skynet.be> wrote:
> > schedstr, sleepstr and kvmstr are only used in strcmp & strlen
[]
> > +++ b/kernel/profile.c
> > @@ -52,9 +52,9 @@ static DEFINE_MUTEX(profile_flip_mutex);
> >
> > int profile_setup(char *str)
> > {
> > - static char schedstr[] = "schedule";
> > - static char sleepstr[] = "sleep";
> > - static char kvmstr[] = "kvm";
> > + static const char schedstr[] = "schedule";
> > + static const char sleepstr[] = "sleep";
> > + static const char kvmstr[] = "kvm";
> > int par;
> >
>
> I'd expect this to either make no change or to make text larger and
> data smaller.
>
> In fact,
>
> text data bss dec hex filename
> 7631 811 3016 11458 2cc2 kernel/profile.o-before
> 7520 779 3016 11315 2c33 kernel/profile.o-after
>
> Both text and data got smaller and the total reduction was a whopping
> 143 bytes. Weirdness.
Now there's no code required to initialize/memcpy
the strings every function invocation.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-05-07 22:35 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-07 20:35 [PATCH 1/1] kernel/profile.c: use static const char instead of static char Fabian Frederick
2014-05-07 22:30 ` Andrew Morton
2014-05-07 22:35 ` Joe Perches
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).