Skip to contentSkip to conversation

arch/cris: fixes static strings declaration

PATCH In review Ricardo Nabinger Sanchez 3 participants 6 messages May 26, 2005 Kernel janitors

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arch/cris: fixes static strings declaration

o Fixes strings declaration from char *str = ""; to char str[] = "";, avoiding the extra pointer, as noted by Jeff Garzik. The strings' contents are not changed after declared.

 arch/cris/arch-v10/drivers/axisflashmap.c |    2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)
arch/cris/arch-v10/drivers/axisflashmap.c +1 -1
diff -urNp -X dontdiff linux-2.6.11.10/arch/cris/arch-v10/drivers/axisflashmap.c mod-linux-2.6.11.10/arch/cris/arch-v10/drivers/axisflashmap.c
@@ -393,7 +393,7 @@ static int __init init_axis_flash(void)
 	struct partitiontable_head *ptable_head = NULL;
 	struct partitiontable_entry *ptable;
 	int use_default_ptable = 1; /* Until proven otherwise. */
-	const char *pmsg = "  /dev/flash%d at 0x%08x, size 0x%08x\n";
+	const char pmsg[] = "  /dev/flash%d at 0x%08x, size 0x%08x\n";
 
 	if (!(mymtd = flash_probe())) {
 		/* There's no reason to use this module if no flash chip can

_______________________________________________
Kernel-janitors mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors

#2 lore raw
In reply to Ricardo Nabinger Sanchez

Quoting Alexey Dobriyan <[email protected]>
Sent on Thu, 26 May 2005 20:35:55 +0400

Quoted 1 line

What's the difference in .text and .data sizes?

It's small, but as there are lots of occurences which may be corrected (there are about 475 in total, including those which must be done that way -- ie, correct).

From the TODO:

=====
From: Jeff Garzik <jgarzik at mandrakesoft dot com>

1) The string form

        [const] char *foo = "blah";

creates two variables in the final assembly output, a static string, and a char pointer to the static string. The alternate string form

        [const] char foo[] = "blah";

is better because it declares a single variable.
...
=====

Signature · 6 lines
Ricardo Nabinger Sanchez
GNU/Linux #140696 [http://counter.li.org]
Slackware Linux + FreeBSD

    How long a minute is depends on which 
    side of the bathroom door you're on.

_______________________________________________
Kernel-janitors mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors

#3 lore raw
In reply to Ricardo Nabinger Sanchez
Quoted 6 lines · Ricardo Nabinger Sanchez

Quoting Alexey Dobriyan <[email protected]>
Sent on Thu, 26 May 2005 20:35:55 +0400

Quoted 1 line

What's the difference in .text and .data sizes?

It's small,

I want to see size(1) output on cross-compiled .o

IIRC the difference depends on gcc version and can even be positive.

_______________________________________________
Kernel-janitors mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors

#4 lore raw
In reply to Ricardo Nabinger Sanchez

hi Alexey,
you ask for it :)

cris-gcc -v
Reading specs from /usr/local/cris/lib/gcc-lib/cris/2.96/specs gcc version 2.96 Axis release R46/1.25

testprogramm:

#include <stdio.h>
//char *foo = "blah";
char foo[]="blah";
int main()
{
printf("%s\n",foo);

}

size test_string (char [])
text data bss dec hex filename

    769     252      36    1057     421 test_string

size test_string2 (char *)
text data bss dec hex filename

    777     248      40    1065     429 test_string2

sorry, i could not resist :)

re,
walter

Quoted 6 lines · Alexey Dobriyan
Quoted 4 lines · Ricardo Nabinger Sanchez

Quoting Alexey Dobriyan <[email protected]>
Sent on Thu, 26 May 2005 20:35:55 +0400

Quoted 9 lines
Quoted 3 lines
Quoted 1 line

What's the difference in .text and .data sizes?

It's small,

I want to see size(1) output on cross-compiled .o

IIRC the difference depends on gcc version and can even be positive.

_______________________________________________
Kernel-janitors mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors

#5 lore raw
In reply to Ricardo Nabinger Sanchez
Quoted 5 lines · walter harms

you ask for it :)

cris-gcc -v
Reading specs from /usr/local/cris/lib/gcc-lib/cris/2.96/specs gcc version 2.96 Axis release R46/1.25

Aha!

Quoted 14 lines

#include <stdio.h>
//char *foo = "blah";
char foo[]="blah";
int main()
{
printf("%s\n",foo);

}

size test_string (char [])
text data bss dec hex filename
769 252 36 1057 421 test_string

Quoted 6 lines

size test_string2 (char *)
text data bss dec hex filename
777 248 40 1065 429 test_string2

sorry, i could not resist :)

Care to repeat this on arch/cris/arch-v10/drivers/axisflashmap.o ? ;-)
_______________________________________________
Kernel-janitors mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors