From 6232f1c96cde1fee247e95cd97235c48cc7b168d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20E=2E=20=27Flameeyes=27=20Petten=C3=B2?= Date: Fri, 21 Nov 2008 13:10:02 +0100 Subject: [PATCH] Make some static tables and strings constants. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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ò --- alsactl/alsactl.c | 4 ++-- alsactl/init_parse.c | 2 +- alsamixer/alsamixer.c | 2 +- amidi/amidi.c | 4 ++-- amixer/amixer.c | 8 ++++---- aplay/aplay.c | 4 ++-- iecset/iecbits.c | 2 +- iecset/iecset.c | 2 +- seq/aconnect/aconnect.c | 2 +- seq/aplaymidi/aplaymidi.c | 6 +++--- seq/aplaymidi/arecordmidi.c | 4 ++-- seq/aseqdump/aseqdump.c | 4 ++-- seq/aseqnet/aseqnet.c | 2 +- speaker-test/speaker-test.c | 6 +++--- 14 files changed, 26 insertions(+), 26 deletions(-) diff --git a/alsactl/alsactl.c b/alsactl/alsactl.c index c1e09bb..e0bc276 100644 --- a/alsactl/alsactl.c +++ b/alsactl/alsactl.c @@ -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", diff --git a/alsactl/init_parse.c b/alsactl/init_parse.c index 0c96a4a..31ed56e 100644 --- a/alsactl/init_parse.c +++ b/alsactl/init_parse.c @@ -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; diff --git a/alsamixer/alsamixer.c b/alsamixer/alsamixer.c index 3b0dc53..414033e 100644 --- a/alsamixer/alsamixer.c +++ b/alsamixer/alsamixer.c @@ -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 }, diff --git a/amidi/amidi.c b/amidi/amidi.c index 82eeff4..2e970ae 100644 --- a/amidi/amidi.c +++ b/amidi/amidi.c @@ -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'}, diff --git a/amixer/amixer.c b/amixer/amixer.c index d5a77ba..9620721 100644 --- a/amixer/amixer.c +++ b/amixer/amixer.c @@ -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'}, diff --git a/aplay/aplay.c b/aplay/aplay.c index 9960f86..2e14d2a 100644 --- a/aplay/aplay.c +++ b/aplay/aplay.c @@ -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'}, diff --git a/iecset/iecbits.c b/iecset/iecbits.c index 84d439b..edea932 100644 --- a/iecset/iecbits.c +++ b/iecset/iecbits.c @@ -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" }, diff --git a/iecset/iecset.c b/iecset/iecset.c index 8e44078..92a93e8 100644 --- a/iecset/iecset.c +++ b/iecset/iecset.c @@ -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, diff --git a/seq/aconnect/aconnect.c b/seq/aconnect/aconnect.c index bab501a..1a50666 100644 --- a/seq/aconnect/aconnect.c +++ b/seq/aconnect/aconnect.c @@ -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'}, diff --git a/seq/aplaymidi/aplaymidi.c b/seq/aplaymidi/aplaymidi.c index b9377e5..5ed7bab 100644 --- a/seq/aplaymidi/aplaymidi.c +++ b/seq/aplaymidi/aplaymidi.c @@ -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'}, diff --git a/seq/aplaymidi/arecordmidi.c b/seq/aplaymidi/arecordmidi.c index 558fd6d..9628086 100644 --- a/seq/aplaymidi/arecordmidi.c +++ b/seq/aplaymidi/arecordmidi.c @@ -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'}, diff --git a/seq/aseqdump/aseqdump.c b/seq/aseqdump/aseqdump.c index 5122bbb..24c5d21 100644 --- a/seq/aseqdump/aseqdump.c +++ b/seq/aseqdump/aseqdump.c @@ -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'}, diff --git a/seq/aseqnet/aseqnet.c b/seq/aseqnet/aseqnet.c index ccf33e6..e071ad9 100644 --- a/seq/aseqnet/aseqnet.c +++ b/seq/aseqnet/aseqnet.c @@ -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'}, diff --git a/speaker-test/speaker-test.c b/speaker-test/speaker-test.c index c626ad7..d40342f 100644 --- a/speaker-test/speaker-test.c +++ b/speaker-test/speaker-test.c @@ -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'},