Skip to content

Commit

Permalink
Make some static tables and strings constants.
Browse files Browse the repository at this point in the history
By doing this we move them from the .data section to .rodata setion,
or from .data.rel to .data.rel.ro.

The .rodata section is mapped directly from the on-disk file, which is
always a save, while .data.rel.ro is mapped directly when using
prelink, which is a save in a lot of cases.

Signed-off-by: Diego E. 'Flameeyes' Pettenò <[email protected]>
  • Loading branch information
Flameeyes committed Nov 21, 2008
1 parent ca1ea1e commit 6232f1c
Show file tree
Hide file tree
Showing 14 changed files with 26 additions and 26 deletions.
4 changes: 2 additions & 2 deletions alsactl/alsactl.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ static void help(void)

int main(int argc, char *argv[])
{
struct option long_option[] =
static const struct option long_option[] =
{
{"help", 0, NULL, 'h'},
{"file", 1, NULL, 'f'},
Expand All @@ -88,7 +88,7 @@ int main(int argc, char *argv[])
{"version", 0, NULL, 'v'},
{NULL, 0, NULL, 0},
};
char *devfiles[] = {
static const char *const devfiles[] = {
"/dev/snd/controlC",
"/dev/snd/pcmC",
"/dev/snd/midiC",
Expand Down
2 changes: 1 addition & 1 deletion alsactl/init_parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ static const char *get_ctl_value(struct space *space)
snd_ctl_elem_type_t type;
unsigned int idx, count;
static char res[1024], tmp[16];
static const char *hex = "0123456789abcdef";
static const char hex[] = "0123456789abcdef";
char *pos;
const char *pos1;

Expand Down
2 changes: 1 addition & 1 deletion alsamixer/alsamixer.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ enum {
#define MIXER_ELEM_HAS_VOLUME 0x800

/* left and right channels for each type */
static snd_mixer_selem_channel_id_t mixer_elem_chn[][2] = {
static const snd_mixer_selem_channel_id_t mixer_elem_chn[][2] = {
{ SND_MIXER_SCHN_FRONT_LEFT, SND_MIXER_SCHN_FRONT_RIGHT },
{ SND_MIXER_SCHN_REAR_LEFT, SND_MIXER_SCHN_REAR_RIGHT },
{ SND_MIXER_SCHN_FRONT_CENTER, SND_MIXER_SCHN_UNKNOWN },
Expand Down
4 changes: 2 additions & 2 deletions amidi/amidi.c
Original file line number Diff line number Diff line change
Expand Up @@ -465,8 +465,8 @@ static void add_send_hex_data(const char *str)

int main(int argc, char *argv[])
{
static char short_options[] = "hVlLp:s:r:S::dt:a";
static struct option long_options[] = {
static const char short_options[] = "hVlLp:s:r:S::dt:a";
static const struct option long_options[] = {
{"help", 0, NULL, 'h'},
{"version", 0, NULL, 'V'},
{"list-devices", 0, NULL, 'l'},
Expand Down
8 changes: 4 additions & 4 deletions amixer/amixer.c
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ static int set_capture_dB(snd_mixer_elem_t *elem,
return snd_mixer_selem_set_capture_dB(elem, c, value, 0);
}

static struct volume_ops_set vol_ops[2] = {
static const struct volume_ops_set vol_ops[2] = {
{
.has_volume = snd_mixer_selem_has_playback_volume,
.v = {{ snd_mixer_selem_get_playback_volume_range,
Expand Down Expand Up @@ -1346,7 +1346,7 @@ typedef struct channel_mask {
char *name;
unsigned int mask;
} channel_mask_t;
static channel_mask_t chanmask[] = {
static const channel_mask_t chanmask[] = {
{"frontleft", 1 << SND_MIXER_SCHN_FRONT_LEFT},
{"frontright", 1 << SND_MIXER_SCHN_FRONT_RIGHT},
{"frontcenter", 1 << SND_MIXER_SCHN_FRONT_CENTER},
Expand All @@ -1363,7 +1363,7 @@ static channel_mask_t chanmask[] = {

static unsigned int channels_mask(char **arg, unsigned int def)
{
channel_mask_t *c;
const channel_mask_t *c;

for (c = chanmask; c->name; c++) {
if (strncasecmp(*arg, c->name, strlen(c->name)) == 0) {
Expand Down Expand Up @@ -1892,7 +1892,7 @@ int main(int argc, char *argv[])
{
int morehelp, level = 0;
int read_stdin = 0;
static struct option long_option[] =
static const struct option long_option[] =
{
{"help", 0, NULL, 'h'},
{"card", 1, NULL, 'c'},
Expand Down
4 changes: 2 additions & 2 deletions aplay/aplay.c
Original file line number Diff line number Diff line change
Expand Up @@ -356,8 +356,8 @@ enum {
int main(int argc, char *argv[])
{
int option_index;
char *short_options = "hnlLD:qt:c:f:r:d:MNF:A:R:T:B:vV:IPC";
static struct option long_options[] = {
static const char short_options[] = "hnlLD:qt:c:f:r:d:MNF:A:R:T:B:vV:IPC";
static const struct option long_options[] = {
{"help", 0, 0, 'h'},
{"version", 0, 0, OPT_VERSION},
{"list-devnames", 0, 0, 'n'},
Expand Down
2 changes: 1 addition & 1 deletion iecset/iecbits.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ struct category_str {
const char *name;
};

static struct category_str con_category[] = {
static const struct category_str con_category[] = {
{ IEC958_AES1_CON_GENERAL, "general" },

{ IEC958_AES1_CON_IEC908_CD, "CD" },
Expand Down
2 changes: 1 addition & 1 deletion iecset/iecset.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ struct cmdtbl {
const char *desc;
};

static struct cmdtbl cmds[] = {
static const struct cmdtbl cmds[] = {
{ "pro", IDX_PRO, CMD_BOOL,
"professional (common)\n\toff = consumer mode, on = professional mode" },
{ "aud", IDX_NOAUDIO, CMD_BOOL_INV,
Expand Down
2 changes: 1 addition & 1 deletion seq/aconnect/aconnect.c
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ enum {
SUBSCRIBE, UNSUBSCRIBE, LIST, REMOVE_ALL
};

static struct option long_option[] = {
static const struct option long_option[] = {
{"disconnect", 0, NULL, 'd'},
{"input", 0, NULL, 'i'},
{"output", 0, NULL, 'o'},
Expand Down
6 changes: 3 additions & 3 deletions seq/aplaymidi/aplaymidi.c
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ static int read_track(struct track *track, int track_end)

switch (cmd >> 4) {
/* maps SMF events to ALSA sequencer events */
static unsigned char cmd_type[] = {
static const unsigned char cmd_type[] = {
[0x8] = SND_SEQ_EVENT_NOTEOFF,
[0x9] = SND_SEQ_EVENT_NOTEON,
[0xa] = SND_SEQ_EVENT_KEYPRESS,
Expand Down Expand Up @@ -857,8 +857,8 @@ static void version(void)

int main(int argc, char *argv[])
{
static char short_options[] = "hVlp:d:";
static struct option long_options[] = {
static const char short_options[] = "hVlp:d:";
static const struct option long_options[] = {
{"help", 0, NULL, 'h'},
{"version", 0, NULL, 'V'},
{"list", 0, NULL, 'l'},
Expand Down
4 changes: 2 additions & 2 deletions seq/aplaymidi/arecordmidi.c
Original file line number Diff line number Diff line change
Expand Up @@ -706,8 +706,8 @@ static void sighandler(int sig)

int main(int argc, char *argv[])
{
static char short_options[] = "hVlp:b:f:t:sdm:i:";
static struct option long_options[] = {
static const char short_options[] = "hVlp:b:f:t:sdm:i:";
static const struct option long_options[] = {
{"help", 0, NULL, 'h'},
{"version", 0, NULL, 'V'},
{"list", 0, NULL, 'l'},
Expand Down
4 changes: 2 additions & 2 deletions seq/aseqdump/aseqdump.c
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,8 @@ static void sighandler(int sig)

int main(int argc, char *argv[])
{
static char short_options[] = "hVlp:";
static struct option long_options[] = {
static const char short_options[] = "hVlp:";
static const struct option long_options[] = {
{"help", 0, NULL, 'h'},
{"version", 0, NULL, 'V'},
{"list", 0, NULL, 'l'},
Expand Down
2 changes: 1 addition & 1 deletion seq/aseqnet/aseqnet.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ static int info = 0;
* main routine
*/

static struct option long_option[] = {
static const struct option long_option[] = {
{"port", 1, NULL, 'p'},
{"source", 1, NULL, 's'},
{"dest", 1, NULL, 'd'},
Expand Down
6 changes: 3 additions & 3 deletions speaker-test/speaker-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ static snd_pcm_uframes_t period_size;
static const char *given_test_wav_file = NULL;
static char *wav_file_dir = SOUNDSDIR;

static const char *channel_name[MAX_CHANNELS] = {
static const char *const channel_name[MAX_CHANNELS] = {
N_("Front Left"),
N_("Front Right"),
N_("Rear Left"),
Expand Down Expand Up @@ -620,7 +620,7 @@ static int check_wav_file(int channel, const char *name)

static int setup_wav_file(int chn)
{
static const char *wavs[MAX_CHANNELS] = {
static const char *const wavs[MAX_CHANNELS] = {
"Front_Left.wav",
"Front_Right.wav",
"Rear_Left.wav",
Expand Down Expand Up @@ -802,7 +802,7 @@ int main(int argc, char *argv[]) {
unsigned int n, nloops;
struct timeval tv1,tv2;

struct option long_option[] = {
static const struct option long_option[] = {
{"help", 0, NULL, 'h'},
{"device", 1, NULL, 'D'},
{"rate", 1, NULL, 'r'},
Expand Down

0 comments on commit 6232f1c

Please sign in to comment.