Skip to contentSkip to conversation

Trivial patch:changing const char foo* to const char foo[]

KJ [email protected] 2 participants 2 messages Apr 16, 2007 Kernel janitors

lore
Share & tools
lore
#0 lore raw

Files modified

arch/i386/boot/compressed/relocs.c
arch/i386/kernel/vmi.c

As suggested by Jeff Garzik,
----

Quoted 6 lines

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.

------

Cleaned up for the new modifications.

---

(quoted diff) +0 -0

b/arch/i386/boot/compressed/relocs.c
index ce4fda2..0beeea1 100644

arch/i386/boot/compressed/relocs.c +2 -2
@@ -71,7 +71,7 @@ static const char *sym_type(unsigned type)
 		SYM_TYPE(STT_TLS),
 #undef SYM_TYPE
 	};
-	const char *name = "unknown sym type name";
+	const char name[] = "unknown sym type name";
 	if (type < ARRAY_SIZE(type_name)) {
 		name = type_name[type];
 	}
@@ -87,7 +87,7 @@ static const char *sym_bind(unsigned bind)
 		SYM_BIND(STB_WEAK),
 #undef SYM_BIND
 	};
-	const char *name = "unknown sym bind name";
+	const char name[] = "unknown sym bind name";
 	if (bind < ARRAY_SIZE(bind_name)) {
 		name = bind_name[bind];
 	}
@@ -104,7 +104,7 @@ static const char *sym_visibility(unsigned

visibility)
SYM_VISIBILITY(STV_PROTECTED),
#undef SYM_VISIBILITY
};
- const char *name = "unknown sym visibility name";
+ const char name[] = "unknown sym visibility name";
if (visibility < ARRAY_SIZE(visibility_name)) {
name = visibility_name[visibility];
}
@@ -128,7 +128,7 @@ static const char *rel_type(unsigned type)
REL_TYPE(R_386_GOTPC),
#undef REL_TYPE
};
- const char *name = "unknown type rel type name";
+ const char name[] = "unknown type rel type name";
if (type < ARRAY_SIZE(type_name)) {
name = type_name[type];
}

arch/i386/kernel/vmi.c +0 -0
index edc339f..895f546 100644
@@ -599,9 +599,9 @@ static inline int __init check_vmi_rom(struct

vrom_header *rom)
{
struct pci_header *pci;
struct pnp_header *pnp;
- const char *manufacturer = "UNKNOWN";
- const char *product = "UNKNOWN";
- const char *license = "unspecified";
+ const char manufacturer[] = "UNKNOWN";
+ const char product[] = "UNKNOWN";
+ const char license[] = "unspecified";

if (rom->rom_signature != 0xaa55)
return 0;

Signature · 2 lines
surya.
16/04/2007

_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/kernel-janitors

#1 lore raw

2007/4/16, [email protected] <[email protected]>:

Quoted 80 lines

Files modified

arch/i386/boot/compressed/relocs.c
arch/i386/kernel/vmi.c

As suggested by Jeff Garzik,
----

Quoted 6 lines

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.

------

Cleaned up for the new modifications.

---

arch/i386/boot/compressed/relocs.c +3 -3
index ce4fda2..0beeea1 100644
@@ -71,7 +71,7 @@ static const char *sym_type(unsigned type)
                SYM_TYPE(STT_TLS),
 #undef SYM_TYPE
        };
-       const char *name = "unknown sym type name";
+       const char name[] = "unknown sym type name";
        if (type < ARRAY_SIZE(type_name)) {
                name = type_name[type];
        }
@@ -87,7 +87,7 @@ static const char *sym_bind(unsigned bind)
                SYM_BIND(STB_WEAK),
 #undef SYM_BIND
        };
-       const char *name = "unknown sym bind name";
+       const char name[] = "unknown sym bind name";
        if (bind < ARRAY_SIZE(bind_name)) {
                name = bind_name[bind];
        }
@@ -104,7 +104,7 @@ static const char *sym_visibility(unsigned
 visibility)
                SYM_VISIBILITY(STV_PROTECTED),
 #undef SYM_VISIBILITY
        };
-       const char *name = "unknown sym visibility name";
+       const char name[] = "unknown sym visibility name";
        if (visibility < ARRAY_SIZE(visibility_name)) {
                name = visibility_name[visibility];
        }
arch/i386/boot/compressed/relocs.c +1 -1
@@ -128,7 +128,7 @@ static const char *rel_type(unsigned type)
                REL_TYPE(R_386_GOTPC),
 #undef REL_TYPE
        };
-       const char *name = "unknown type rel type name";
+       const char name[] = "unknown type rel type name";
        if (type < ARRAY_SIZE(type_name)) {
                name = type_name[type];
        }
arch/i386/kernel/vmi.c +3 -3
index edc339f..895f546 100644
@@ -599,9 +599,9 @@ static inline int __init check_vmi_rom(struct
 vrom_header *rom)
 {
        struct pci_header *pci;
        struct pnp_header *pnp;
-       const char *manufacturer = "UNKNOWN";
-       const char *product = "UNKNOWN";
-       const char *license = "unspecified";
+       const char manufacturer[] = "UNKNOWN";
+       const char product[] = "UNKNOWN";
+       const char license[] = "unspecified";
 
        if (rom->rom_signature != 0xaa55)
Quoted 3 lines
                return 0;

i don't think you compiled it :/
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/kernel-janitors