Re: [RFC] cleanup patches for strings

From: cutaway
Date: Tue Jun 21 2005 - 18:55:38 EST

There is a way to defeat the GCC string alignments by putting the strings in
a dynamically sized structure if anyone cares. A bonus side effect of this
scheme is that kernel/driver NLS translations would become almost trivial
because all the string texts are collected in one place.

The basic idea looks like this:

#define MSG1 "Message text blah"
#define MSG2 "Message text blah, blah"
#define MSG3 "Message text blah, blah, blah"

static const struct
char m1[sizeof(MSG1)+1];
char m2[sizeof(MSG2)+1];
char m3[sizeof(MSG3)+1];
} msg = {
#undef MSG1
#undef MSG2
#undef MSG3
#define MSG1 msg.m1
#define MSG2 msg.m2
#define MSG3 msg.m3

The #ifdef allows for a "trial build" so GCC can type match parms to format
strings by just plugging the texts in verbatim like it is today.

The next logical step up from this would be to extract the #define "...."
stuff into a header, and voila, you've got trivial kernel/driver translation
(at least for pan-euro/western languages) essentially for free that doesn't
require anyone to fork off a special translation tree - they can keep using
mainline code base and just do a language specific header translation.

This scheme has saved several hundreds of bytes in couple of drivers I've
been diddling around with prototyping some changes on.

(Name == Tony Ingenoso)

----- Original Message -----
From: "Jean Delvare" <khali@xxxxxxxxxxxx>
To: <cutaway@xxxxxxxxxxxxx>
Cc: "Denis Vlasenko" <vda@xxxxxxxxxxxxx>; "LKML"
Sent: Tuesday, June 21, 2005 17:49
Subject: Re: [RFC] cleanup patches for strings

> Hi,... hm, don't you have a name?
> > Jean, the default string alignments GCC seems to insist on using are
> > going to screw you far more than the extra byte here or there ;->
> That's possible, however I can't do anything against GCC personally,
> while I can help cleanup the code and possibly actually space a few
> bytes here and there. So let's just do it.
> Oh, and GCC might end up being smart, who knows.
> --
> Jean Delvare

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at