Fixing: char *foo = "blah";
Quoted 9 lines
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
Quoted 9 lines
[const] char foo[] = "blah";is better because it declares a single variable.
For variables marked
__initdata, the "*foo" form causes only the pointer, not the string itself, to be dropped from the kernel image, which is a bug. Using the "foo[]" form with regular 'ole local variables also makes the assembly shorter.
I plan to take on this task as described at:
http://www.kerneljanitors.org/TODO
I have a number of queries:
1. I presume that the [brackets] indicate that const is optional.
Therefore the following needs correcting: char *foo = "blah";
2. I suppose that the following form would also need correcting:
static const char *foo = "blah"
3. Does the following (with an empty string) need correcting?
[const] char *foo = "";
4. What about this?
static const char *class_name[] = { "off","UBR","CBR","VBR","ABR" };5. These changes are spread across the kernel code.
Do patches need to be submitted to individual subsystem maintainers, or will
a single patch be ok?
cheers,
felix
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
Quoting Felix Oxley <[email protected]>
Sent on Fri, 7 Oct 2005 12:34:03 +0100
Hello,
Quoted 14 lines
I plan to take on this task as described at:
http://www.kerneljanitors.org/TODO
I have a number of queries:1. I presume that the [brackets] indicate that const is optional.
Therefore the following needs correcting: char *foo = "blah";2. I suppose that the following form would also need correcting:
static const char *foo = "blah"3. Does the following (with an empty string) need correcting?
[const] char *foo = "";
Quoted 8 lines
4. What about this?
static const char *class_name[] ={ "off","UBR","CBR","VBR","ABR" };
5. These changes are spread across the kernel code.
Do patches need to be submitted to individual subsystem
maintainers, or will a single patch be ok?
By May, 2005, I was working on this. Alexey told me that besides what gcc should do, I had to confirm that the change made was actually better.
In some cases, it was not. I've made a testcase, and the results were pretty odd (I was expecting something else):
http://lists.osdl.org/pipermail/kernel-janitors/2005-May/004146.html
Different versions of gcc and cross-compilers should produce different results. I really don't know yet what is the best case (ie, which is good for (almost) all architectures/compilers).
Anyone?
Signature · 5 lines
Ricardo Nabinger Sanchez GNU/Linux #140696 [http://counter.li.org] Slackware Linux + FreeBSD Left to themselves, things tend to go from bad to worse.
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors