]> git.alsa-project.org Git - alsa-utils.git/commitdiff
Make some static tables and strings constants.
authorDiego E. 'Flameeyes' Pettenò <flameeyes@gmail.com>
Fri, 21 Nov 2008 12:10:02 +0000 (13:10 +0100)
committerDiego E. 'Flameeyes' Pettenò <flameeyes@gmail.com>
Fri, 21 Nov 2008 12:10:02 +0000 (13:10 +0100)
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>
14 files changed:
alsactl/alsactl.c
alsactl/init_parse.c
alsamixer/alsamixer.c
amidi/amidi.c
amixer/amixer.c
aplay/aplay.c
iecset/iecbits.c
iecset/iecset.c
seq/aconnect/aconnect.c
seq/aplaymidi/aplaymidi.c
seq/aplaymidi/arecordmidi.c
seq/aseqdump/aseqdump.c
seq/aseqnet/aseqnet.c
speaker-test/speaker-test.c

index c1e09bbb7951b50cd468139f69d9b8d40feb4cb5..e0bc276195c7ad56f3e219e28cc89b6d4c1f64d9 100644 (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",
index 0c96a4aed2587b2c00aa59d65bb50bba8f000b0b..31ed56ed465959576b9cdb1bf1d2dbafe119359e 100644 (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;
 
index 3b0dc53f41212b110510c229f5a11bab90c885b5..414033ef78f29116651780f2c98f4ab830de9a4a 100644 (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 },
index 82eeff44ac2eb45ca0ff74ca0ab057d53bdf4a84..2e970ae1fe744e451c3a9779fa6c10a2d3ee7051 100644 (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'},
index d5a77ba5b424251b2d42c8128bd7558c24e8b78e..962072133ccdaae8e23772ac1fcbb4d6c85a232a 100644 (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'},
index 9960f8623a8dc91a7f15ae689a20ff85e2508ace..2e14d2ac7c64e810a94de834c7ea8788364d72c8 100644 (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'},
index 84d439b5d8227e74206c314a669cf6b115a200d8..edea9326d273129f8e1b5db67375003aeda92dda 100644 (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" },
index 8e440788fc55a1e5407c705d15949c36613ec877..92a93e831e2db8f9ec0784d4c7e584aee58029dc 100644 (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,
index bab501ad7011fb283026a45da78dd744bcdf7414..1a50666966e98f459655b6ad4970f67991f443f3 100644 (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'},
index b9377e590c4a3e3d553814dd769a28cea1eac22e..5ed7bab8b5fb33d4fd5d50d1ac669736213c6ad3 100644 (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'},
index 558fd6d968c2a27ae6e8ae568193b5e290b2a3b4..96280868ce0dbd2a8795bf4d8912dca22ee66a7b 100644 (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'},
index 5122bbbca6d853fce6233c53ab069c00692ecf65..24c5d215355c427bde7db7d5b485e1c147622ee8 100644 (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'},
index ccf33e68ce31d8ee894f35c81897112b0c74ea01..e071ad9709c31e8c0188daaca0140280210e55df 100644 (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'},
index c626ad79556dc4709f6d0cb2058d149842a6f70d..d40342fa95106d9fb47779b399ff06f525992c2d 100644 (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'},