From 2a3e1628a50b9de7c1462ee95eb79937795f5409 Mon Sep 17 00:00:00 2001 From: Thomas Jarosch Date: Sun, 11 Jan 2015 21:40:51 +0100 Subject: Limit more variables to file scope Change-Id: I30219d626316776eb73b4205d63376fa3dbc6361 --- lib/rbcodec/codecs/libfaad/codebook/hcb.h | 10 ---------- lib/rbcodec/codecs/libfaad/huffman.c | 21 ++++++++++++--------- lib/rbcodec/codecs/libfaad/syntax.c | 10 +++++----- lib/rbcodec/codecs/libgme/inflate/mallocer.c | 6 +++--- lib/rbcodec/codecs/libspeex/filters.c | 8 ++++---- lib/rbcodec/codecs/libwavpack/wputils.c | 2 +- lib/rbcodec/codecs/libwmapro/mdct_tables.c | 12 ++++++------ lib/rbcodec/codecs/mod.c | 8 ++++---- lib/rbcodec/codecs/sid.c | 22 +++++++++++----------- lib/rbcodec/codecs/wav64.c | 2 +- lib/skin_parser/skin_debug.c | 8 ++++---- lib/skin_parser/skin_parser.c | 2 +- 12 files changed, 52 insertions(+), 59 deletions(-) (limited to 'lib') diff --git a/lib/rbcodec/codecs/libfaad/codebook/hcb.h b/lib/rbcodec/codecs/libfaad/codebook/hcb.h index eaefdbf437..53e234ade9 100644 --- a/lib/rbcodec/codecs/libfaad/codebook/hcb.h +++ b/lib/rbcodec/codecs/libfaad/codebook/hcb.h @@ -112,16 +112,6 @@ typedef struct int8_t data[2]; } hcb_bin_pair; -hcb *hcb_table[]; -hcb_2_quad *hcb_2_quad_table[]; -hcb_2_pair *hcb_2_pair_table[]; -hcb_bin_pair *hcb_bin_table[]; -uint8_t hcbN[]; -uint8_t unsigned_cb[]; -int hcb_2_quad_table_size[]; -int hcb_2_pair_table_size[]; -int hcb_bin_table_size[]; - #include "codebook/hcb_1.h" #include "codebook/hcb_2.h" #include "codebook/hcb_3.h" diff --git a/lib/rbcodec/codecs/libfaad/huffman.c b/lib/rbcodec/codecs/libfaad/huffman.c index bea0dd7bf2..93e3a2dfc3 100644 --- a/lib/rbcodec/codecs/libfaad/huffman.c +++ b/lib/rbcodec/codecs/libfaad/huffman.c @@ -76,33 +76,33 @@ int8_t huffman_scale_factor(bitfile *ld) } -hcb *hcb_table[] ICONST_ATTR = { +static hcb *hcb_table[] ICONST_ATTR = { 0, hcb1_1, hcb2_1, 0, hcb4_1, 0, hcb6_1, 0, hcb8_1, 0, hcb10_1, hcb11_1 }; -hcb_2_quad *hcb_2_quad_table[] ICONST_ATTR = { +static hcb_2_quad *hcb_2_quad_table[] ICONST_ATTR = { 0, hcb1_2, hcb2_2, 0, hcb4_2, 0, 0, 0, 0, 0, 0, 0 }; -hcb_2_pair *hcb_2_pair_table[] ICONST_ATTR = { +static hcb_2_pair *hcb_2_pair_table[] ICONST_ATTR = { 0, 0, 0, 0, 0, 0, hcb6_2, 0, hcb8_2, 0, hcb10_2, hcb11_2 }; -hcb_bin_pair *hcb_bin_table[] ICONST_ATTR = { +static hcb_bin_pair *hcb_bin_table[] ICONST_ATTR = { 0, 0, 0, 0, 0, hcb5, 0, hcb7, 0, hcb9, 0, 0 }; -uint8_t hcbN[] ICONST_ATTR = { 0, 5, 5, 0, 5, 0, 5, 0, 5, 0, 6, 5 }; +static uint8_t hcbN[] ICONST_ATTR = { 0, 5, 5, 0, 5, 0, 5, 0, 5, 0, 6, 5 }; /* defines whether a huffman codebook is unsigned or not */ /* Table 4.6.2 */ -uint8_t unsigned_cb[] ICONST_ATTR = { 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, +static uint8_t unsigned_cb[] ICONST_ATTR = { 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, /* codebook 16 to 31 */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; -int hcb_2_quad_table_size[] ICONST_ATTR = { 0, 114, 86, 0, 185, 0, 0, 0, 0, 0, 0, 0 }; -int hcb_2_pair_table_size[] ICONST_ATTR = { 0, 0, 0, 0, 0, 0, 126, 0, 83, 0, 210, 373 }; -int hcb_bin_table_size[] ICONST_ATTR = { 0, 0, 0, 161, 0, 161, 0, 127, 0, 337, 0, 0 }; +static int hcb_2_quad_table_size[] ICONST_ATTR = { 0, 114, 86, 0, 185, 0, 0, 0, 0, 0, 0, 0 }; +static int hcb_2_pair_table_size[] ICONST_ATTR = { 0, 0, 0, 0, 0, 0, 126, 0, 83, 0, 210, 373 }; +static int hcb_bin_table_size[] ICONST_ATTR = { 0, 0, 0, 161, 0, 161, 0, 127, 0, 337, 0, 0 }; #define FAAD_GET_SIGN(idx) \ if (sp[idx]) \ @@ -113,6 +113,9 @@ static INLINE void huffman_sign_bits_pair(bitfile *ld, int16_t *sp) { FAAD_GET_SIGN(0) FAAD_GET_SIGN(1) + + /* silence compiler warning about unused globals */ + (void)unsigned_cb; } static INLINE void huffman_sign_bits_quad(bitfile *ld, int16_t *sp) diff --git a/lib/rbcodec/codecs/libfaad/syntax.c b/lib/rbcodec/codecs/libfaad/syntax.c index d3d7f9e3d4..65e1bf7744 100644 --- a/lib/rbcodec/codecs/libfaad/syntax.c +++ b/lib/rbcodec/codecs/libfaad/syntax.c @@ -558,8 +558,8 @@ void raw_data_block(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo, /* Table 4.4.4 and */ /* Table 4.4.9 */ -int16_t spec_data[FRAME_LEN] MEM_ALIGN_ATTR = {0}; -element sce; +static int16_t spec_data[FRAME_LEN] MEM_ALIGN_ATTR = {0}; +static element sce; static uint8_t single_lfe_channel_element(NeAACDecHandle hDecoder, bitfile *ld, uint8_t channel, uint8_t *tag) { @@ -604,9 +604,9 @@ static uint8_t single_lfe_channel_element(NeAACDecHandle hDecoder, bitfile *ld, /* Table 4.4.5 */ -int16_t spec_data1[FRAME_LEN] IBSS_ATTR MEM_ALIGN_ATTR; -int16_t spec_data2[FRAME_LEN] IBSS_ATTR MEM_ALIGN_ATTR; -element cpe; +static int16_t spec_data1[FRAME_LEN] IBSS_ATTR MEM_ALIGN_ATTR; +static int16_t spec_data2[FRAME_LEN] IBSS_ATTR MEM_ALIGN_ATTR; +static element cpe; static uint8_t channel_pair_element(NeAACDecHandle hDecoder, bitfile *ld, uint8_t channels, uint8_t *tag) { diff --git a/lib/rbcodec/codecs/libgme/inflate/mallocer.c b/lib/rbcodec/codecs/libgme/inflate/mallocer.c index 41abedd09f..1e9c235975 100644 --- a/lib/rbcodec/codecs/libgme/inflate/mallocer.c +++ b/lib/rbcodec/codecs/libgme/inflate/mallocer.c @@ -9,9 +9,9 @@ #include "mallocer.h" #include "codeclib.h" -unsigned char* mallocbuffer[MEMPOOL_MAX]; -long memory_ptr[MEMPOOL_MAX]; -size_t buffersize[MEMPOOL_MAX]; +static unsigned char* mallocbuffer[MEMPOOL_MAX]; +static long memory_ptr[MEMPOOL_MAX]; +static size_t buffersize[MEMPOOL_MAX]; int wpw_init_mempool(unsigned char mempool) { diff --git a/lib/rbcodec/codecs/libspeex/filters.c b/lib/rbcodec/codecs/libspeex/filters.c index 7c4c90a636..b6fb79c9e0 100644 --- a/lib/rbcodec/codecs/libspeex/filters.c +++ b/lib/rbcodec/codecs/libspeex/filters.c @@ -590,21 +590,21 @@ void qmf_synth(const spx_word16_t *x1, const spx_word16_t *x2, const spx_word16_ #ifdef FIXED_POINT #if 0 -const spx_word16_t shift_filt[3][7] = {{-33, 1043, -4551, 19959, 19959, -4551, 1043}, +static const spx_word16_t shift_filt[3][7] = {{-33, 1043, -4551, 19959, 19959, -4551, 1043}, {-98, 1133, -4425, 29179, 8895, -2328, 444}, {444, -2328, 8895, 29179, -4425, 1133, -98}}; #else -const spx_word16_t shift_filt[3][7] = {{-390, 1540, -4993, 20123, 20123, -4993, 1540}, +static const spx_word16_t shift_filt[3][7] = {{-390, 1540, -4993, 20123, 20123, -4993, 1540}, {-1064, 2817, -6694, 31589, 6837, -990, -209}, {-209, -990, 6837, 31589, -6694, 2817, -1064}}; #endif #else #if 0 -const float shift_filt[3][7] = {{-9.9369e-04, 3.1831e-02, -1.3889e-01, 6.0910e-01, 6.0910e-01, -1.3889e-01, 3.1831e-02}, +static const float shift_filt[3][7] = {{-9.9369e-04, 3.1831e-02, -1.3889e-01, 6.0910e-01, 6.0910e-01, -1.3889e-01, 3.1831e-02}, {-0.0029937, 0.0345613, -0.1350474, 0.8904793, 0.2714479, -0.0710304, 0.0135403}, {0.0135403, -0.0710304, 0.2714479, 0.8904793, -0.1350474, 0.0345613, -0.0029937}}; #else -const float shift_filt[3][7] = {{-0.011915f, 0.046995f, -0.152373f, 0.614108f, 0.614108f, -0.152373f, 0.046995f}, +static const float shift_filt[3][7] = {{-0.011915f, 0.046995f, -0.152373f, 0.614108f, 0.614108f, -0.152373f, 0.046995f}, {-0.0324855f, 0.0859768f, -0.2042986f, 0.9640297f, 0.2086420f, -0.0302054f, -0.0063646f}, {-0.0063646f, -0.0302054f, 0.2086420f, 0.9640297f, -0.2042986f, 0.0859768f, -0.0324855f}}; #endif diff --git a/lib/rbcodec/codecs/libwavpack/wputils.c b/lib/rbcodec/codecs/libwavpack/wputils.c index b0ccd3ba83..3487f980b2 100644 --- a/lib/rbcodec/codecs/libwavpack/wputils.c +++ b/lib/rbcodec/codecs/libwavpack/wputils.c @@ -23,7 +23,7 @@ static void strcpy_loc (char *dst, char *src) { while ((*dst++ = *src++) != 0); ///////////////////////////// local table storage //////////////////////////// -const uint32_t sample_rates [] = { 6000, 8000, 9600, 11025, 12000, 16000, 22050, +static const uint32_t sample_rates [] = { 6000, 8000, 9600, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000, 64000, 88200, 96000, 192000 }; ///////////////////////////// executable code //////////////////////////////// diff --git a/lib/rbcodec/codecs/libwmapro/mdct_tables.c b/lib/rbcodec/codecs/libwmapro/mdct_tables.c index bec3c37ee7..deea04f746 100644 --- a/lib/rbcodec/codecs/libwmapro/mdct_tables.c +++ b/lib/rbcodec/codecs/libwmapro/mdct_tables.c @@ -4,7 +4,7 @@ /* Tables for fixed-point trig tables for windowing and mdct */ /* Windowing trig tables in s.31 format */ -const int32_t sine_4096[] = { +static const int32_t sine_4096[] = { 0xFFF9B782, 0xFFED2685, 0xFFE09587, 0xFFD4048A, 0xFFC7738D, 0xFFBAE291, 0xFFAE5196, 0xFFA1C09B, 0xFF952FA1, 0xFF889EA8, 0xFF7C0DB1, 0xFF6F7CBB, 0xFF62EBC5, 0xFF565AD3, 0xFF49C9E1, 0xFF3D38F0, 0xFF30A803, 0xFF241716, @@ -690,7 +690,7 @@ const int32_t sine_4096[] = { 0x8000078F, 0x800003DC, 0x80000164, 0x80000028 }; -const int32_t sine_2048[] ICONST_ATTR_WMAPRO_WIN_VS_TMP = { +static const int32_t sine_2048[] ICONST_ATTR_WMAPRO_WIN_VS_TMP = { 0xFFF36F03, 0xFFDA4D09, 0xFFC12B0F, 0xFFA80918, 0xFF8EE725, 0xFF75C536, 0xFF5CA34B, 0xFF438168, 0xFF2A5F8C, 0xFF113DB7, 0xFEF81BEE, 0xFEDEFA2D, 0xFEC5D876, 0xFEACB6CE, 0xFE939531, 0xFE7A73A2, 0xFE615224, 0xFE4830B4, @@ -1035,7 +1035,7 @@ const int32_t sine_2048[] ICONST_ATTR_WMAPRO_WIN_VS_TMP = { 0x8000058E, 0x8000009F }; -const int32_t sine_1024[] = { +static const int32_t sine_1024[] = { 0xFFE6DE06, 0xFFB49A13, 0xFF82562D, 0xFF501259, 0xFF1DCEA1, 0xFEEB8B0C, 0xFEB947A0, 0xFE870468, 0xFE54C16A, 0xFE227EAD, 0xFDF03C3D, 0xFDBDFA1A, 0xFD8BB850, 0xFD5976EC, 0xFD2735EC, 0xFCF4F55C, 0xFCC2B548, 0xFC9075B1, @@ -1209,7 +1209,7 @@ const int32_t sine_1024[] = { 0x800078E8, 0x80003DB0, 0x80001636, 0x80000279 }; -const int32_t sine_512[] = { +static const int32_t sine_512[] = { 0xFFCDBC0C, 0xFF693440, 0xFF04ACD1, 0xFEA025FE, 0xFE3BA003, 0xFDD71B21, 0xFD72978F, 0xFD0E1595, 0xFCA9956C, 0xFC45174E, 0xFBE09B85, 0xFB7C223F, 0xFB17ABC2, 0xFAB33854, 0xFA4EC823, 0xF9EA5B74, 0xF985F28F, 0xF9218DA0, @@ -1298,7 +1298,7 @@ const int32_t sine_512[] = { 0x800058D4, 0x800009DF }; -const int32_t sine_256[] ICONST_ATTR_WMAPRO_WIN_VS_TMP = { +static const int32_t sine_256[] ICONST_ATTR_WMAPRO_WIN_VS_TMP = { 0xFF9B781E, 0xFED26950, 0xFE095D6B, 0xFD40565E, 0xFC775617, 0xFBAE5E8D, 0xFAE571A2, 0xFA1C9157, 0xF953BF94, 0xF88AFE40, 0xF7C24F61, 0xF6F9B4C9, 0xF6313075, 0xF568C463, 0xF4A07264, 0xF3D83C74, 0xF3102493, 0xF2482C8D, @@ -1344,7 +1344,7 @@ const int32_t sine_256[] ICONST_ATTR_WMAPRO_WIN_VS_TMP = { 0x80078E60, 0x8003DAF2, 0x8001634E, 0x8000277B }; -const int32_t sine_128[] ICONST_ATTR = { +static const int32_t sine_128[] ICONST_ATTR = { 0xFF36F079, 0xFDA4D929, 0xFC12D91C, 0xFA80FFCF, 0xF8EF5CBC, 0xF75DFF6C, 0xF5CCF73F, 0xF43C53CB, 0xF2AC2474, 0xF11C7895, 0xEF8D5FC8, 0xEDFEE931, 0xEC71244A, 0xEAE4208A, 0xE957ED00, 0xE7CC9912, 0xE642341D, 0xE4B8CD16, diff --git a/lib/rbcodec/codecs/mod.c b/lib/rbcodec/codecs/mod.c index 4dd0cde6e5..3d5f729235 100644 --- a/lib/rbcodec/codecs/mod.c +++ b/lib/rbcodec/codecs/mod.c @@ -234,9 +234,9 @@ struct s_mixer { struct s_channel channel[32]; }; -struct s_song modsong IDATA_ATTR; /* The Song */ -struct s_modplayer modplayer IDATA_ATTR; /* The Module Player */ -struct s_mixer mixer IDATA_ATTR; +static struct s_song modsong IDATA_ATTR; /* The Song */ +static struct s_modplayer modplayer IDATA_ATTR; /* The Module Player */ +static struct s_mixer mixer IDATA_ATTR; /* The Amiga Period Table (+1 because we use index 0 for period 0 = no new note) */ static unsigned short s_periodtable[37*8+1] IDATA_ATTR = @@ -290,7 +290,7 @@ static signed short s_sintable[0x40] IDATA_ATTR = -255, -254, -250, -244, -235, -224, -211, -197, -180, -161, -141, -119, -97, -73, -49, -24}; -const unsigned short mixingrate = 44100; +static const unsigned short mixingrate = 44100; static void mixer_playsample(int channel, int instrument) ICODE_ATTR; void mixer_playsample(int channel, int instrument) diff --git a/lib/rbcodec/codecs/sid.c b/lib/rbcodec/codecs/sid.c index 6e39d3f759..3c370961c7 100644 --- a/lib/rbcodec/codecs/sid.c +++ b/lib/rbcodec/codecs/sid.c @@ -155,27 +155,27 @@ struct sidflt { }; /* ------------------------ pseudo-constants (depending on mixing freq) */ -int mixing_frequency IDATA_ATTR; -unsigned long freqmul IDATA_ATTR; -int filtmul IDATA_ATTR; +static int mixing_frequency IDATA_ATTR; +static unsigned long freqmul IDATA_ATTR; +static int filtmul IDATA_ATTR; #ifndef ROCKBOX unsigned long attacks [16] IDATA_ATTR; unsigned long releases[16] IDATA_ATTR; #endif /* ------------------------------------------------------------ globals */ -struct s6581 sid IDATA_ATTR; -struct sidosc osc[3] IDATA_ATTR; -struct sidflt filter IDATA_ATTR; +static struct s6581 sid IDATA_ATTR; +static struct sidosc osc[3] IDATA_ATTR; +static struct sidflt filter IDATA_ATTR; /* ------------------------------------------------------ C64 Emu Stuff */ -unsigned char bval IDATA_ATTR; -unsigned short wval IDATA_ATTR; +static unsigned char bval IDATA_ATTR; +static unsigned short wval IDATA_ATTR; /* -------------------------------------------------- Register & memory */ -unsigned char a,x,y,s,p IDATA_ATTR; -unsigned short pc IDATA_ATTR; +static unsigned char a,x,y,s,p IDATA_ATTR; +static unsigned short pc IDATA_ATTR; -unsigned char memory[65536]; +static unsigned char memory[65536]; /* ----------------------------------------- Variables for sample stuff */ static int sample_active IDATA_ATTR; diff --git a/lib/rbcodec/codecs/wav64.c b/lib/rbcodec/codecs/wav64.c index 96e605faad..66bb3e3a11 100644 --- a/lib/rbcodec/codecs/wav64.c +++ b/lib/rbcodec/codecs/wav64.c @@ -60,7 +60,7 @@ enum WAVE_FORMAT_EXTENSIBLE = 0xFFFE }; -const struct pcm_entry wave_codecs[] = { +static const struct pcm_entry wave_codecs[] = { { WAVE_FORMAT_UNKNOWN, 0 }, { WAVE_FORMAT_PCM, get_linear_pcm_codec }, { WAVE_FORMAT_ADPCM, get_ms_adpcm_codec }, diff --git a/lib/skin_parser/skin_debug.c b/lib/skin_parser/skin_debug.c index a2042744b9..43cd746253 100644 --- a/lib/skin_parser/skin_debug.c +++ b/lib/skin_parser/skin_debug.c @@ -34,10 +34,10 @@ extern char* skin_start; extern char* skin_buffer; /* Global error variables */ -int error_line; -int error_col; -const char *error_line_start; -char* error_message; +static int error_line; +static int error_col; +static const char *error_line_start; +static char* error_message; static inline struct skin_element* diff --git a/lib/skin_parser/skin_parser.c b/lib/skin_parser/skin_parser.c index e47054b06a..1d784f918a 100644 --- a/lib/skin_parser/skin_parser.c +++ b/lib/skin_parser/skin_parser.c @@ -35,7 +35,7 @@ /* Global variables for the parser */ int skin_line = 0; char* skin_start = 0; -int viewport_line = 0; +static int viewport_line = 0; #ifdef ROCKBOX static skin_callback callback = NULL; -- cgit