]> git.alsa-project.org Git - alsa-lib.git/commitdiff
Mark static tables as constant when possible.
authorDiego E. 'Flameeyes' Pettenò <flameeyes@gmail.com>
Fri, 21 Nov 2008 21:19:28 +0000 (22:19 +0100)
committerDiego E. 'Flameeyes' Pettenò <flameeyes@gmail.com>
Fri, 21 Nov 2008 21:39:38 +0000 (22:39 +0100)
This makes it possible to write them to .data.rel.ro or to .rodata if
there is no relocation involved (arrays of character arrays).

Signed-off-by: Diego E. 'Flameeyes' Pettenò <flameeyes@gmail.com>
src/alisp/alisp.c
src/alisp/alisp_snd.c
src/confmisc.c
src/control/hcontrol.c
src/control/namehint.c
src/mixer/simple.c
src/mixer/simple_none.c
src/pcm/pcm_route.c
src/rawmidi/rawmidi.c

index 208cc28d95e54c755787f1b9ef441b94636dbe4e..4ad1d093b6a085d8dbda8bb78f552a98bcfd0b55 100644 (file)
@@ -2965,7 +2965,7 @@ struct intrinsic {
        struct alisp_object * (*func)(struct alisp_instance *instance, struct alisp_object * args);
 };
 
-static struct intrinsic intrinsics[] = {
+static const struct intrinsic intrinsics[] = {
        { "!=", F_numneq },
        { "%", F_mod },
        { "&check-memory", F_check_memory },
index 147ed0a6c8d67e6fbd84b8a8d0fa1843359243e1..de429d9452627713f0c8971faafc1bed50ad451a 100644 (file)
@@ -286,7 +286,7 @@ static struct alisp_object * FA_int_pp_strp_int(struct alisp_instance * instance
        int err, mode;
        void *handle;
        struct alisp_object *p1, *p2;
-       static struct flags flags[] = {
+       static const struct flags flags[] = {
                { "nonblock", SND_CTL_NONBLOCK },
                { "async", SND_CTL_ASYNC },
                { "readonly", SND_CTL_READONLY },
@@ -789,7 +789,7 @@ static struct alisp_object * FA_pcm_info(struct alisp_instance * instance, struc
  *  main code
  */
 
-static struct acall_table acall_table[] = {
+static const struct acall_table acall_table[] = {
        { "card_get_index", &FA_int_str, (void *)snd_card_get_index, NULL },
        { "card_get_longname", &FA_int_int_strp, (void *)snd_card_get_longname, NULL },
        { "card_get_name", &FA_int_int_strp, (void *)snd_card_get_name, NULL },
@@ -933,7 +933,7 @@ static struct alisp_object * F_syserr(struct alisp_instance *instance, struct al
        return &alsa_lisp_t;
 }
 
-static struct intrinsic snd_intrinsics[] = {
+static const struct intrinsic snd_intrinsics[] = {
        { "Acall", F_acall },
        { "Aerror", F_aerror },
        { "Ahandle", F_ahandle },
index 49210b73f80eff339ad72fff9bdb2b7625d076c5..80b0027dc80f2a7731f08eaf4654c9a53766064d 100644 (file)
@@ -88,8 +88,8 @@
 int snd_config_get_bool_ascii(const char *ascii)
 {
        unsigned int k;
-       static struct {
-               const char *str;
+       static const struct {
+               const char str[8];
                int val;
        } b[] = {
                { "0", 0 },
index 50a5a736c221827dc494a99b4e3240c5686e02f7..181e7672ee428d8c670b56886b8aa6914edb12d9 100644 (file)
@@ -234,7 +234,7 @@ static int snd_hctl_compare_mixer_priority_lookup(const char **name, const char
 
 static int get_compare_weight(const snd_ctl_elem_id_t *id)
 {
-       static const char *names[] = {
+       static const char *const names[] = {
                "Master",
                "Hardware Master",
                "Headphone",
@@ -270,7 +270,7 @@ static int get_compare_weight(const snd_ctl_elem_id_t *id)
                "IEC958",
                NULL
        };
-       static const char *names1[] = {
+       static const char *const names1[] = {
                "Switch",
                "Volume",
                "Playback",
@@ -284,7 +284,7 @@ static int get_compare_weight(const snd_ctl_elem_id_t *id)
                "-",
                NULL
        };
-       static const char *names2[] = {
+       static const char *const names2[] = {
                "Switch",
                "Volume",
                "Bypass",
index 8bf739b922735fb5d0cc9ff2f9cc7b803ff9679e..e878f830c20ec2a35748c123fa6ca4756e86452b 100644 (file)
@@ -392,7 +392,7 @@ static int try_config(struct hint_list *list,
 
 typedef int (*next_devices_t)(snd_ctl_t *, int *);
 
-static next_devices_t next_devices[] = {
+static const next_devices_t next_devices[] = {
        IFACE(CARD, NULL),
        IFACE(HWDEP, snd_ctl_hwdep_next_device),
        IFACE(MIXER, NULL),
index c44f8b4225b6986ed333fd61ccb0b7bd6b5260dc..39790b2e05cbbbebaa8558816ec20b98f2fa70db 100644 (file)
@@ -217,7 +217,7 @@ int snd_mixer_selem_has_common_switch(snd_mixer_elem_t *elem)
  */
 const char *snd_mixer_selem_channel_name(snd_mixer_selem_channel_id_t channel)
 {
-       static const char *array[SND_MIXER_SCHN_LAST + 1] = {
+       static const char *const array[SND_MIXER_SCHN_LAST + 1] = {
                [SND_MIXER_SCHN_FRONT_LEFT] = "Front Left",
                [SND_MIXER_SCHN_FRONT_RIGHT] = "Front Right",
                [SND_MIXER_SCHN_REAR_LEFT] = "Rear Left",
index c43871d4dd42b41a7cee6b1a21d0776ae6124f92..0f4dd3a115a9c0af0f6fbd6f5cbfe6bebf9faf4f 100644 (file)
@@ -131,7 +131,7 @@ static int compare_mixer_priority_lookup(const char **name, const char * const *
 
 static int get_compare_weight(const char *name, unsigned int idx)
 {
-       static const char *names[] = {
+       static const char *const names[] = {
                "Master",
                "Headphone",
                "Tone",
@@ -165,11 +165,11 @@ static int get_compare_weight(const char *name, unsigned int idx)
                "Mix",
                NULL
        };
-       static const char *names1[] = {
+       static const char *const names1[] = {
                "-",
                NULL,
        };
-       static const char *names2[] = {
+       static const char *const names2[] = {
                "Mono",
                "Digital",
                "Switch",
@@ -883,7 +883,7 @@ static int simple_update(snd_mixer_elem_t *melem)
 }         
 
 #ifndef DOC_HIDDEN
-static struct suf {
+static const struct suf {
        const char *suffix;
        selem_ctl_type_t type;
 } suffixes[] = {
@@ -906,7 +906,7 @@ static struct suf {
 /* Return base length or 0 on failure */
 static int base_len(const char *name, selem_ctl_type_t *type)
 {
-       struct suf *p;
+       const struct suf *p;
        size_t nlen = strlen(name);
        p = suffixes;
        while (p->suffix) {
index 3455390966691f1a9cbf768bcf35cc1566ce390f..4da623f82e79345f4552839ee8faceb868cb319f 100644 (file)
@@ -236,14 +236,14 @@ static void snd_pcm_route_convert1_many(const snd_pcm_channel_area_t *dst_area,
 #include "plugin_ops.h"
 #undef GETS_LABELS
 #undef PUT32_LABELS
-       static void *zero_labels[3] = {
+       static void *const zero_labels[3] = {
                &&zero_int32, &&zero_int64,
 #if SND_PCM_PLUGIN_ROUTE_FLOAT
                &&zero_float
 #endif
        };
        /* sum_type att */
-       static void *add_labels[3 * 2] = {
+       static void *const add_labels[3 * 2] = {
                &&add_int32_noatt, &&add_int32_att,
                &&add_int64_noatt, &&add_int64_att,
 #if SND_PCM_PLUGIN_ROUTE_FLOAT
@@ -251,7 +251,7 @@ static void snd_pcm_route_convert1_many(const snd_pcm_channel_area_t *dst_area,
 #endif
        };
        /* sum_type att shift */
-       static void *norm_labels[3 * 2 * 4] = {
+       static void *const norm_labels[3 * 2 * 4] = {
                0,
                &&norm_int32_8_noatt,
                &&norm_int32_16_noatt,
index 3da1b4f205eb3704aae42745ca0cdd906337c029..f50cc0532107221d9da183795718c026ff9e47af 100644 (file)
@@ -989,7 +989,7 @@ ssize_t snd_rawmidi_read(snd_rawmidi_t *rawmidi, void *buffer, size_t size)
 
 int snd_rawmidi_conf_generic_id(const char *id)
 {
-       static const char *ids[] = {
+       static const char ids[][8] = {
                "comment",
                "type",
                "hint",