Make some static tables and strings constants.

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ò <flameeyes@gmail.com>
This commit is contained in:
Diego E. 'Flameeyes' Pettenò 2008-11-21 13:10:02 +01:00
parent ca1ea1e904
commit 6232f1c96c
14 changed files with 26 additions and 26 deletions

View file

@ -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'},
@ -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",

View file

@ -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;

View file

@ -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 },

View file

@ -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'},

View file

@ -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,
@ -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},
@ -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) {
@ -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'},

View file

@ -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'},

View file

@ -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" },

View file

@ -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,

View file

@ -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'},

View file

@ -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,
@ -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'},

View file

@ -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'},

View file

@ -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'},

View file

@ -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'},

View file

@ -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"),
@ -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",
@ -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'},