summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/alarm_menu.c1
-rw-r--r--apps/apps.make5
-rw-r--r--apps/bookmark.c6
-rw-r--r--apps/buffering.c1
-rw-r--r--apps/codecs.c3
-rw-r--r--apps/codecs.h2
-rw-r--r--apps/codecs/adx.c2
-rw-r--r--apps/codecs/demac/demac.c1
-rw-r--r--apps/codecs/demac/libdemac/parser.c2
-rw-r--r--apps/codecs/demac/wavwrite.c2
-rw-r--r--apps/codecs/lib/codeclib.h10
-rw-r--r--apps/codecs/lib/tlsf/src/tlsf.c2
-rw-r--r--apps/codecs/lib/tlsf/src/tlsf.h2
-rw-r--r--apps/codecs/libatrac/main.c2
-rw-r--r--apps/codecs/libcook/main.c2
-rw-r--r--apps/codecs/libfaad/common.h2
-rw-r--r--apps/codecs/libmad/libmad.make2
-rw-r--r--apps/codecs/libpcm/adpcm_seek.h2
-rw-r--r--apps/codecs/libpcm/ima_adpcm_common.c16
-rw-r--r--apps/codecs/libpcm/ima_adpcm_common.h1
-rw-r--r--apps/codecs/libpcm/pcm_common.h2
-rw-r--r--apps/codecs/librm/rm.c2
-rw-r--r--apps/codecs/libtremor/config-tremor.h2
-rw-r--r--apps/codecs/libtremor/ctype.c4
-rw-r--r--apps/codecs/libwavpack/words.c6
-rw-r--r--apps/cuesheet.c1
-rw-r--r--apps/debug_menu.c1
-rw-r--r--apps/enc_config.c1
-rw-r--r--apps/filetree.c1
-rw-r--r--apps/filetypes.c1
-rw-r--r--apps/gui/bitmap/list.c1
-rw-r--r--apps/gui/charcell/list.c1
-rw-r--r--apps/gui/list.c2
-rw-r--r--apps/gui/option_select.c3
-rw-r--r--apps/gui/pitchscreen.c15
-rw-r--r--apps/gui/skin_engine/skin_backdrops.c3
-rw-r--r--apps/gui/skin_engine/skin_display.c2
-rw-r--r--apps/gui/skin_engine/skin_tokens.c14
-rw-r--r--apps/gui/statusbar.c2
-rw-r--r--apps/gui/usb_screen.c1
-rw-r--r--apps/gui/viewport.c1
-rw-r--r--apps/gui/wps.c1
-rw-r--r--apps/main.c1
-rw-r--r--apps/menus/eq_menu.c1
-rw-r--r--apps/menus/recording_menu.c1
-rw-r--r--apps/menus/settings_menu.c1
-rw-r--r--apps/menus/time_menu.c30
-rw-r--r--apps/metadata.c3
-rw-r--r--apps/metadata/metadata_common.c2
-rw-r--r--apps/metadata/metadata_common.h1
-rw-r--r--apps/metadata/mp3.c4
-rw-r--r--apps/metadata/smaf.c2
-rw-r--r--apps/misc.c10
-rw-r--r--apps/onplay.c1
-rw-r--r--apps/player/keyboard.c1
-rw-r--r--apps/playlist.c7
-rw-r--r--apps/playlist_catalog.c3
-rw-r--r--apps/playlist_viewer.c1
-rw-r--r--apps/plugin.c1
-rw-r--r--apps/plugin.h9
-rw-r--r--apps/plugins/calculator.c3
-rw-r--r--apps/plugins/doom/d_deh.c2
-rw-r--r--apps/plugins/doom/doom.make2
-rw-r--r--apps/plugins/doom/rockmacros.h20
-rw-r--r--apps/plugins/frotz/frotz.c6
-rw-r--r--apps/plugins/frotz/frotzplugin.h9
-rw-r--r--apps/plugins/imageviewer/png/png.c2
-rw-r--r--apps/plugins/invadrox.c4
-rw-r--r--apps/plugins/lib/buflib.c4
-rw-r--r--apps/plugins/lib/jhash.h4
-rw-r--r--apps/plugins/lib/strncpy.c1
-rw-r--r--apps/plugins/lua/gmtime.c6
-rw-r--r--apps/plugins/midi/midiplay.c2
-rw-r--r--apps/plugins/midi/midiutil.c5
-rw-r--r--apps/plugins/midi/midiutil.h3
-rw-r--r--apps/plugins/mpegplayer/disk_buf.c2
-rw-r--r--apps/plugins/random_folder_advance_config.c10
-rw-r--r--apps/plugins/rockboy/menu.c8
-rw-r--r--apps/plugins/rockboy/rockboy.make2
-rw-r--r--apps/plugins/rockboy/rtc.c1
-rw-r--r--apps/plugins/search.c2
-rw-r--r--apps/plugins/shortcuts/shortcuts.h2
-rw-r--r--apps/plugins/shortcuts/shortcuts_common.c2
-rw-r--r--apps/plugins/stats.c10
-rw-r--r--apps/plugins/wav2wv.c8
-rw-r--r--apps/plugins/zxbox/helpers.h7
-rw-r--r--apps/plugins/zxbox/snapshot.c8
-rw-r--r--apps/plugins/zxbox/spconf.c8
-rw-r--r--apps/plugins/zxbox/sptape.c1
-rw-r--r--apps/plugins/zxbox/tapefile.c2
-rw-r--r--apps/plugins/zxbox/zxmisc.h2
-rw-r--r--apps/recorder/albumart.c3
-rw-r--r--apps/recorder/icons.c1
-rw-r--r--apps/recorder/jpeg_load.c18
-rw-r--r--apps/recorder/keyboard.c2
-rw-r--r--apps/recorder/peakmeter.c1
-rw-r--r--apps/recorder/radio.c3
-rw-r--r--apps/recorder/recording.c4
-rw-r--r--apps/replaygain.c9
-rw-r--r--apps/root_menu.c2
-rw-r--r--apps/screen_access.c5
-rw-r--r--apps/screens.c1
-rw-r--r--apps/scrobbler.c2
-rw-r--r--apps/settings.c4
-rw-r--r--apps/settings_list.c2
-rw-r--r--apps/tagcache.c6
-rw-r--r--apps/tagtree.c2
-rw-r--r--apps/talk.c2
-rw-r--r--apps/tree.c3
-rw-r--r--apps/voice_thread.c1
110 files changed, 225 insertions, 206 deletions
diff --git a/apps/alarm_menu.c b/apps/alarm_menu.c
index 3a44fa472a..1cd0bc4670 100644
--- a/apps/alarm_menu.c
+++ b/apps/alarm_menu.c
@@ -25,7 +25,6 @@
25#include "lcd.h" 25#include "lcd.h"
26#include "action.h" 26#include "action.h"
27#include "kernel.h" 27#include "kernel.h"
28#include "sprintf.h"
29#include <string.h> 28#include <string.h>
30#include "settings.h" 29#include "settings.h"
31#include "power.h" 30#include "power.h"
diff --git a/apps/apps.make b/apps/apps.make
index 3717c5bd34..8814147102 100644
--- a/apps/apps.make
+++ b/apps/apps.make
@@ -15,9 +15,10 @@ SRC += $(call preprocess, $(APPSDIR)/SOURCES)
15# to genlang and thus (translated) phrases can be used based on those names. 15# to genlang and thus (translated) phrases can be used based on those names.
16# button.h is included for the HAS_BUTTON_HOLD define. 16# button.h is included for the HAS_BUTTON_HOLD define.
17# 17#
18# Kludge: depends on ctype.o only to depend on config-*.h ... 18# Kludge: depends on config.o which only depends on config-*.h to have config.h
19# changes trigger a genlang re-run
19# 20#
20features $(BUILDDIR)/apps/features $(BUILDDIR)/apps/genlang-features: $(APPSDIR)/features.txt $(BUILDDIR)/firmware/common/ctype.o 21features $(BUILDDIR)/apps/features $(BUILDDIR)/apps/genlang-features: $(APPSDIR)/features.txt $(BUILDDIR)/firmware/common/config.o
21 $(SILENT)mkdir -p $(BUILDDIR)/apps 22 $(SILENT)mkdir -p $(BUILDDIR)/apps
22 $(SILENT)mkdir -p $(BUILDDIR)/lang 23 $(SILENT)mkdir -p $(BUILDDIR)/lang
23 $(call PRINTS,PP $(<F)) 24 $(call PRINTS,PP $(<F))
diff --git a/apps/bookmark.c b/apps/bookmark.c
index c48810c19c..3d8df3ec0b 100644
--- a/apps/bookmark.c
+++ b/apps/bookmark.c
@@ -342,7 +342,7 @@ static char* create_bookmark()
342 /* new optional bookmark token descriptors should be inserted 342 /* new optional bookmark token descriptors should be inserted
343 just before the "%s;%s" in this line... */ 343 just before the "%s;%s" in this line... */
344#if CONFIG_CODEC == SWCODEC 344#if CONFIG_CODEC == SWCODEC
345 ">%d;%d;%ld;%d;%ld;%d;%d;%d;%d;%s;%s", 345 ">%d;%d;%ld;%d;%ld;%d;%d;%ld;%ld;%s;%s",
346#else 346#else
347 ">%d;%d;%ld;%d;%ld;%d;%d;%s;%s", 347 ">%d;%d;%ld;%d;%ld;%d;%d;%s;%s",
348#endif 348#endif
@@ -360,8 +360,8 @@ static char* create_bookmark()
360 global_settings.playlist_shuffle, 360 global_settings.playlist_shuffle,
361 /* ...and their values should go here */ 361 /* ...and their values should go here */
362#if CONFIG_CODEC == SWCODEC 362#if CONFIG_CODEC == SWCODEC
363 sound_get_pitch(), 363 (long)sound_get_pitch(),
364 dsp_get_timestretch(), 364 (long)dsp_get_timestretch(),
365#endif 365#endif
366 /* more mandatory tokens */ 366 /* more mandatory tokens */
367 playlist_get_name(NULL, global_temp_buffer, 367 playlist_get_name(NULL, global_temp_buffer,
diff --git a/apps/buffering.c b/apps/buffering.c
index afc7c7ad6b..2c26c6634d 100644
--- a/apps/buffering.c
+++ b/apps/buffering.c
@@ -38,7 +38,6 @@
38#include "kernel.h" 38#include "kernel.h"
39#include "tree.h" 39#include "tree.h"
40#include "debug.h" 40#include "debug.h"
41#include "sprintf.h"
42#include "settings.h" 41#include "settings.h"
43#include "codecs.h" 42#include "codecs.h"
44#include "audio.h" 43#include "audio.h"
diff --git a/apps/codecs.c b/apps/codecs.c
index b20aa7f969..4d97baacbe 100644
--- a/apps/codecs.c
+++ b/apps/codecs.c
@@ -26,12 +26,13 @@
26#include <stdlib.h> 26#include <stdlib.h>
27#include <timefuncs.h> 27#include <timefuncs.h>
28#include <ctype.h> 28#include <ctype.h>
29#include <stdarg.h>
30#include "string-extra.h"
29#include "debug.h" 31#include "debug.h"
30#include "button.h" 32#include "button.h"
31#include "dir.h" 33#include "dir.h"
32#include "file.h" 34#include "file.h"
33#include "kernel.h" 35#include "kernel.h"
34#include "sprintf.h"
35#include "screens.h" 36#include "screens.h"
36#include "misc.h" 37#include "misc.h"
37#include "mas.h" 38#include "mas.h"
diff --git a/apps/codecs.h b/apps/codecs.h
index 34fd3940ad..27c9caba13 100644
--- a/apps/codecs.h
+++ b/apps/codecs.h
@@ -31,8 +31,10 @@
31#define MEM 2 31#define MEM 2
32#endif 32#endif
33 33
34#include <_ansi.h>
34#include <stdbool.h> 35#include <stdbool.h>
35#include <stdlib.h> 36#include <stdlib.h>
37#include "strlcpy.h"
36#include "config.h" 38#include "config.h"
37#include "system.h" 39#include "system.h"
38#include "metadata.h" 40#include "metadata.h"
diff --git a/apps/codecs/adx.c b/apps/codecs/adx.c
index fe32653b18..dd5bba16e7 100644
--- a/apps/codecs/adx.c
+++ b/apps/codecs/adx.c
@@ -18,6 +18,8 @@
18 * KIND, either express or implied. 18 * KIND, either express or implied.
19 * 19 *
20 ****************************************************************************/ 20 ****************************************************************************/
21
22#include <limits.h>
21#include "codeclib.h" 23#include "codeclib.h"
22#include "inttypes.h" 24#include "inttypes.h"
23#include "math.h" 25#include "math.h"
diff --git a/apps/codecs/demac/demac.c b/apps/codecs/demac/demac.c
index 5e9893687d..3e97fff2c9 100644
--- a/apps/codecs/demac/demac.c
+++ b/apps/codecs/demac/demac.c
@@ -46,7 +46,6 @@ avoided by writing the decoded data one sample at a time.
46#include <stdio.h> 46#include <stdio.h>
47#include <inttypes.h> 47#include <inttypes.h>
48#include <stdlib.h> 48#include <stdlib.h>
49#include <sys/types.h>
50#include <sys/stat.h> 49#include <sys/stat.h>
51#include <fcntl.h> 50#include <fcntl.h>
52#include <unistd.h> 51#include <unistd.h>
diff --git a/apps/codecs/demac/libdemac/parser.c b/apps/codecs/demac/libdemac/parser.c
index ebde36deed..2af4a292b8 100644
--- a/apps/codecs/demac/libdemac/parser.c
+++ b/apps/codecs/demac/libdemac/parser.c
@@ -27,7 +27,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
27#ifndef ROCKBOX 27#ifndef ROCKBOX
28#include <stdio.h> 28#include <stdio.h>
29#include <stdlib.h> 29#include <stdlib.h>
30#include <sys/types.h> 30#include "inttypes.h"
31#include <sys/stat.h> 31#include <sys/stat.h>
32#include <fcntl.h> 32#include <fcntl.h>
33#include <unistd.h> 33#include <unistd.h>
diff --git a/apps/codecs/demac/wavwrite.c b/apps/codecs/demac/wavwrite.c
index 72c7950dd4..71d2b7bb97 100644
--- a/apps/codecs/demac/wavwrite.c
+++ b/apps/codecs/demac/wavwrite.c
@@ -25,7 +25,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
25#include <stdio.h> 25#include <stdio.h>
26#include <inttypes.h> 26#include <inttypes.h>
27#include <stdlib.h> 27#include <stdlib.h>
28#include <sys/types.h> 28#include "inttypes.h"
29#include <sys/stat.h> 29#include <sys/stat.h>
30#include <fcntl.h> 30#include <fcntl.h>
31#include <unistd.h> 31#include <unistd.h>
diff --git a/apps/codecs/lib/codeclib.h b/apps/codecs/lib/codeclib.h
index 817d86a6a3..b7685ebbcb 100644
--- a/apps/codecs/lib/codeclib.h
+++ b/apps/codecs/lib/codeclib.h
@@ -22,9 +22,10 @@
22#ifndef __CODECLIB_H__ 22#ifndef __CODECLIB_H__
23#define __CODECLIB_H__ 23#define __CODECLIB_H__
24 24
25#include <inttypes.h>
26#include <string.h>
25#include "config.h" 27#include "config.h"
26#include "codecs.h" 28#include "codecs.h"
27#include <sys/types.h>
28#include "mdct.h" 29#include "mdct.h"
29#include "fft.h" 30#include "fft.h"
30 31
@@ -44,6 +45,7 @@ extern unsigned char* filebuf; /* The rest of the MP3 buffer
44#define calloc(x,y) codec_calloc(x,y) 45#define calloc(x,y) codec_calloc(x,y)
45#define realloc(x,y) codec_realloc(x,y) 46#define realloc(x,y) codec_realloc(x,y)
46#define free(x) codec_free(x) 47#define free(x) codec_free(x)
48#undef alloca
47#define alloca(x) __builtin_alloca(x) 49#define alloca(x) __builtin_alloca(x)
48 50
49void* codec_malloc(size_t size); 51void* codec_malloc(size_t size);
@@ -59,7 +61,11 @@ void *memmove(void *s1, const void *s2, size_t n);
59size_t strlen(const char *s); 61size_t strlen(const char *s);
60char *strcpy(char *dest, const char *src); 62char *strcpy(char *dest, const char *src);
61char *strcat(char *dest, const char *src); 63char *strcat(char *dest, const char *src);
62int strcmp(const char *, const char *); 64
65/* on some platforms strcmp() seems to be a tricky define which
66 * breaks if we write down strcmp's prototype */
67#undef strcmp
68int strcmp(const char *s1, const char *s2);
63 69
64void qsort(void *base, size_t nmemb, size_t size, int(*compar)(const void *, const void *)); 70void qsort(void *base, size_t nmemb, size_t size, int(*compar)(const void *, const void *));
65 71
diff --git a/apps/codecs/lib/tlsf/src/tlsf.c b/apps/codecs/lib/tlsf/src/tlsf.c
index 6d15c3a3f6..570e472607 100644
--- a/apps/codecs/lib/tlsf/src/tlsf.c
+++ b/apps/codecs/lib/tlsf/src/tlsf.c
@@ -165,7 +165,7 @@
165#endif 165#endif
166 166
167#if defined(ROCKBOX) && defined(SIMULATOR) || !defined(ROCKBOX) 167#if defined(ROCKBOX) && defined(SIMULATOR) || !defined(ROCKBOX)
168int printf(char*, ...); 168int printf(const char* fmt, ...);
169#define PRINT_MSG(fmt, args...) printf(fmt, ## args) 169#define PRINT_MSG(fmt, args...) printf(fmt, ## args)
170#define ERROR_MSG(fmt, args...) printf(fmt, ## args) 170#define ERROR_MSG(fmt, args...) printf(fmt, ## args)
171#else 171#else
diff --git a/apps/codecs/lib/tlsf/src/tlsf.h b/apps/codecs/lib/tlsf/src/tlsf.h
index 5d016f4369..4feb5c42cc 100644
--- a/apps/codecs/lib/tlsf/src/tlsf.h
+++ b/apps/codecs/lib/tlsf/src/tlsf.h
@@ -19,7 +19,7 @@
19#ifndef _TLSF_H_ 19#ifndef _TLSF_H_
20#define _TLSF_H_ 20#define _TLSF_H_
21 21
22#include <sys/types.h> 22#include <string.h> /* defines size_t */
23 23
24extern size_t init_memory_pool(size_t, void *); 24extern size_t init_memory_pool(size_t, void *);
25extern size_t get_used_size(void *); 25extern size_t get_used_size(void *);
diff --git a/apps/codecs/libatrac/main.c b/apps/codecs/libatrac/main.c
index e0a3f8507d..30307c2946 100644
--- a/apps/codecs/libatrac/main.c
+++ b/apps/codecs/libatrac/main.c
@@ -1,6 +1,6 @@
1#include <stdio.h> 1#include <stdio.h>
2#include <stdint.h> 2#include <stdint.h>
3#include <sys/types.h> 3#include <inttypes.h>
4#include <sys/stat.h> 4#include <sys/stat.h>
5#include <fcntl.h> 5#include <fcntl.h>
6#include <unistd.h> 6#include <unistd.h>
diff --git a/apps/codecs/libcook/main.c b/apps/codecs/libcook/main.c
index 25e263dd60..928cad298e 100644
--- a/apps/codecs/libcook/main.c
+++ b/apps/codecs/libcook/main.c
@@ -19,7 +19,7 @@
19 * 19 *
20 ****************************************************************************/ 20 ****************************************************************************/
21#include <stdint.h> 21#include <stdint.h>
22#include <sys/types.h> 22#include <inttypes.h>
23#include <sys/stat.h> 23#include <sys/stat.h>
24#include <fcntl.h> 24#include <fcntl.h>
25#include <unistd.h> 25#include <unistd.h>
diff --git a/apps/codecs/libfaad/common.h b/apps/codecs/libfaad/common.h
index 658e92f23f..01164e3746 100644
--- a/apps/codecs/libfaad/common.h
+++ b/apps/codecs/libfaad/common.h
@@ -185,7 +185,7 @@ typedef float float32_t;
185 185
186#include <stdio.h> 186#include <stdio.h>
187#ifdef HAVE_SYS_TYPES_H 187#ifdef HAVE_SYS_TYPES_H
188# include <sys/types.h> 188# include "inttypes.h"
189#endif 189#endif
190#ifdef HAVE_SYS_STAT_H 190#ifdef HAVE_SYS_STAT_H
191# include <sys/stat.h> 191# include <sys/stat.h>
diff --git a/apps/codecs/libmad/libmad.make b/apps/codecs/libmad/libmad.make
index c5b197ead8..331ee8916f 100644
--- a/apps/codecs/libmad/libmad.make
+++ b/apps/codecs/libmad/libmad.make
@@ -11,7 +11,7 @@
11# (one for codec, one for mpegplayer) 11# (one for codec, one for mpegplayer)
12# so a little trickery is necessary 12# so a little trickery is necessary
13 13
14MADFLAGS = $(CODECFLAGS) -UDEBUG -DNDEBUG -O2 -I$(APPSDIR)/codecs/libmad 14MADFLAGS = $(CODECFLAGS) -UDEBUG -DNDEBUG -O2 -I$(APPSDIR)/codecs/libmad -DHAVE_LIMITS_H
15MPEGMADFLAGS = $(MADFLAGS) -DMPEGPLAYER 15MPEGMADFLAGS = $(MADFLAGS) -DMPEGPLAYER
16 16
17# libmad 17# libmad
diff --git a/apps/codecs/libpcm/adpcm_seek.h b/apps/codecs/libpcm/adpcm_seek.h
index 66ec390097..2dd3f000b1 100644
--- a/apps/codecs/libpcm/adpcm_seek.h
+++ b/apps/codecs/libpcm/adpcm_seek.h
@@ -21,9 +21,9 @@
21#ifndef CODEC_LIBPCM_ADPCM_SEEK_H 21#ifndef CODEC_LIBPCM_ADPCM_SEEK_H
22#define CODEC_LIBPCM_ADPCM_SEEK_H 22#define CODEC_LIBPCM_ADPCM_SEEK_H
23 23
24#include <sys/types.h>
25#include <stdbool.h> 24#include <stdbool.h>
26#include <inttypes.h> 25#include <inttypes.h>
26#include <string.h>
27 27
28struct adpcm_data { 28struct adpcm_data {
29 int16_t pcmdata[2]; 29 int16_t pcmdata[2];
diff --git a/apps/codecs/libpcm/ima_adpcm_common.c b/apps/codecs/libpcm/ima_adpcm_common.c
index ff5051f166..724cce31b0 100644
--- a/apps/codecs/libpcm/ima_adpcm_common.c
+++ b/apps/codecs/libpcm/ima_adpcm_common.c
@@ -63,7 +63,7 @@ static const int index_tables[4][16] ICONST_ATTR = {
63}; 63};
64 64
65static int32_t pcmdata[2]; 65static int32_t pcmdata[2];
66static int8_t index[2]; 66static int8_t indices[2];
67 67
68static int adpcm_data_size; 68static int adpcm_data_size;
69static uint8_t step_mask; 69static uint8_t step_mask;
@@ -107,7 +107,7 @@ void set_decode_parameters(int channels, int32_t *init_pcmdata, int8_t *init_ind
107 for (ch = 0; ch < channels; ch++) 107 for (ch = 0; ch < channels; ch++)
108 { 108 {
109 pcmdata[ch] = init_pcmdata[ch]; 109 pcmdata[ch] = init_pcmdata[ch];
110 index[ch] = init_index[ch]; 110 indices[ch] = init_index[ch];
111 } 111 }
112} 112}
113 113
@@ -121,7 +121,7 @@ int16_t create_pcmdata(int ch, uint8_t nibble)
121{ 121{
122 int check_bit = 1 << step_shift; 122 int check_bit = 1 << step_shift;
123 int32_t delta = 0; 123 int32_t delta = 0;
124 int16_t step = step_table[index[ch]]; 124 int16_t step = step_table[indices[ch]];
125 125
126 do { 126 do {
127 if (nibble & check_bit) 127 if (nibble & check_bit)
@@ -136,8 +136,8 @@ int16_t create_pcmdata(int ch, uint8_t nibble)
136 else 136 else
137 pcmdata[ch] += delta; 137 pcmdata[ch] += delta;
138 138
139 index[ch] += use_index_table[nibble & step_mask]; 139 indices[ch] += use_index_table[nibble & step_mask];
140 CLIP(index[ch], 0, 88); 140 CLIP(indices[ch], 0, 88);
141 141
142 CLIP(pcmdata[ch], -32768, 32767); 142 CLIP(pcmdata[ch], -32768, 32767);
143 143
@@ -150,7 +150,7 @@ int16_t create_pcmdata(int ch, uint8_t nibble)
150int16_t create_pcmdata_size4(int ch, uint8_t nibble) 150int16_t create_pcmdata_size4(int ch, uint8_t nibble)
151{ 151{
152 int32_t delta; 152 int32_t delta;
153 int16_t step = step_table[index[ch]]; 153 int16_t step = step_table[indices[ch]];
154 154
155 delta = (step >> 3); 155 delta = (step >> 3);
156 if (nibble & 4) delta += step; 156 if (nibble & 4) delta += step;
@@ -162,8 +162,8 @@ int16_t create_pcmdata_size4(int ch, uint8_t nibble)
162 else 162 else
163 pcmdata[ch] += delta; 163 pcmdata[ch] += delta;
164 164
165 index[ch] += use_index_table[nibble & 0x07]; 165 indices[ch] += use_index_table[nibble & 0x07];
166 CLIP(index[ch], 0, 88); 166 CLIP(indices[ch], 0, 88);
167 167
168 CLIP(pcmdata[ch], -32768, 32767); 168 CLIP(pcmdata[ch], -32768, 32767);
169 169
diff --git a/apps/codecs/libpcm/ima_adpcm_common.h b/apps/codecs/libpcm/ima_adpcm_common.h
index 0a2129bdf2..46fd6083ec 100644
--- a/apps/codecs/libpcm/ima_adpcm_common.h
+++ b/apps/codecs/libpcm/ima_adpcm_common.h
@@ -21,7 +21,6 @@
21#ifndef CODEC_LIBPCM_IMA_ADPCM_COMMON_H 21#ifndef CODEC_LIBPCM_IMA_ADPCM_COMMON_H
22#define CODEC_LIBPCM_IMA_ADPCM_COMMON_H 22#define CODEC_LIBPCM_IMA_ADPCM_COMMON_H
23 23
24#include <sys/types.h>
25#include <stdbool.h> 24#include <stdbool.h>
26#include <inttypes.h> 25#include <inttypes.h>
27 26
diff --git a/apps/codecs/libpcm/pcm_common.h b/apps/codecs/libpcm/pcm_common.h
index 91c3ab7f1e..90e29c98ee 100644
--- a/apps/codecs/libpcm/pcm_common.h
+++ b/apps/codecs/libpcm/pcm_common.h
@@ -21,9 +21,9 @@
21#ifndef CODEC_LIBPCM_PCM_COMMON_H 21#ifndef CODEC_LIBPCM_PCM_COMMON_H
22#define CODEC_LIBPCM_PCM_COMMON_H 22#define CODEC_LIBPCM_PCM_COMMON_H
23 23
24#include <sys/types.h>
25#include <stdbool.h> 24#include <stdbool.h>
26#include <inttypes.h> 25#include <inttypes.h>
26#include <string.h>
27 27
28/* decoded pcm sample depth (sample 28bit + sign 1bit) */ 28/* decoded pcm sample depth (sample 28bit + sign 1bit) */
29#define PCM_OUTPUT_DEPTH 29 29#define PCM_OUTPUT_DEPTH 29
diff --git a/apps/codecs/librm/rm.c b/apps/codecs/librm/rm.c
index a179688e7a..b543da50d7 100644
--- a/apps/codecs/librm/rm.c
+++ b/apps/codecs/librm/rm.c
@@ -32,7 +32,7 @@
32#ifdef TEST 32#ifdef TEST
33#include <fcntl.h> 33#include <fcntl.h>
34#include <unistd.h> 34#include <unistd.h>
35#include <sys/types.h> 35#include "inttypes.h"
36#include <sys/stat.h> 36#include <sys/stat.h>
37 37
38int filesize(int fd) 38int filesize(int fd)
diff --git a/apps/codecs/libtremor/config-tremor.h b/apps/codecs/libtremor/config-tremor.h
index 8a68ce325f..abed96533b 100644
--- a/apps/codecs/libtremor/config-tremor.h
+++ b/apps/codecs/libtremor/config-tremor.h
@@ -7,6 +7,7 @@
7#define _ARM_ASSEM_ 7#define _ARM_ASSEM_
8#endif 8#endif
9 9
10#ifndef BYTE_ORDER
10#ifdef ROCKBOX_BIG_ENDIAN 11#ifdef ROCKBOX_BIG_ENDIAN
11#define BIG_ENDIAN 1 12#define BIG_ENDIAN 1
12#define LITTLE_ENDIAN 0 13#define LITTLE_ENDIAN 0
@@ -16,6 +17,7 @@
16#define LITTLE_ENDIAN 1 17#define LITTLE_ENDIAN 1
17#define BIG_ENDIAN 0 18#define BIG_ENDIAN 0
18#endif 19#endif
20#endif
19 21
20#ifndef ICODE_ATTR_TREMOR_MDCT 22#ifndef ICODE_ATTR_TREMOR_MDCT
21#define ICODE_ATTR_TREMOR_MDCT ICODE_ATTR 23#define ICODE_ATTR_TREMOR_MDCT ICODE_ATTR
diff --git a/apps/codecs/libtremor/ctype.c b/apps/codecs/libtremor/ctype.c
index 10468bc27d..359be61e5a 100644
--- a/apps/codecs/libtremor/ctype.c
+++ b/apps/codecs/libtremor/ctype.c
@@ -1 +1,3 @@
1#include "common/ctype.c" 1#ifndef SIMULATOR
2#include "libc/ctype.c"
3#endif
diff --git a/apps/codecs/libwavpack/words.c b/apps/codecs/libwavpack/words.c
index 6da716119c..c3ae50dcf4 100644
--- a/apps/codecs/libwavpack/words.c
+++ b/apps/codecs/libwavpack/words.c
@@ -141,7 +141,7 @@ void init_words (WavpackStream *wps)
141 CLEAR (wps->w); 141 CLEAR (wps->w);
142} 142}
143 143
144static int mylog2 (unsigned int32_t avalue); 144static int mylog2 (uint32_t avalue);
145 145
146// Read the median log2 values from the specifed metadata structure, convert 146// Read the median log2 values from the specifed metadata structure, convert
147// them back to 32-bit unsigned values and store them. If length is not 147// them back to 32-bit unsigned values and store them. If length is not
@@ -553,7 +553,7 @@ void send_words (int32_t *buffer, int nsamples, uint32_t flags,
553 if (sign) 553 if (sign)
554 value = ~value; 554 value = ~value;
555 555
556 if ((unsigned int32_t) value < GET_MED (0)) { 556 if ((uint32_t) value < GET_MED (0)) {
557 ones_count = low = 0; 557 ones_count = low = 0;
558 high = GET_MED (0) - 1; 558 high = GET_MED (0) - 1;
559 DEC_MED0 (); 559 DEC_MED0 ();
@@ -709,7 +709,7 @@ void flush_word (struct words_data *w, Bitstream *bs)
709// This function returns the log2 for the specified 32-bit unsigned value. 709// This function returns the log2 for the specified 32-bit unsigned value.
710// The maximum value allowed is about 0xff800000 and returns 8447. 710// The maximum value allowed is about 0xff800000 and returns 8447.
711 711
712static int mylog2 (unsigned int32_t avalue) 712static int mylog2 (uint32_t avalue)
713{ 713{
714 int dbits; 714 int dbits;
715 715
diff --git a/apps/cuesheet.c b/apps/cuesheet.c
index cb3ba6569a..c75ea65334 100644
--- a/apps/cuesheet.c
+++ b/apps/cuesheet.c
@@ -28,7 +28,6 @@
28#include "audio.h" 28#include "audio.h"
29#include "kernel.h" 29#include "kernel.h"
30#include "logf.h" 30#include "logf.h"
31#include "sprintf.h"
32#include "misc.h" 31#include "misc.h"
33#include "screens.h" 32#include "screens.h"
34#include "list.h" 33#include "list.h"
diff --git a/apps/debug_menu.c b/apps/debug_menu.c
index 054bfd4c99..e8104f74dc 100644
--- a/apps/debug_menu.c
+++ b/apps/debug_menu.c
@@ -28,7 +28,6 @@
28#include "menu.h" 28#include "menu.h"
29#include "debug_menu.h" 29#include "debug_menu.h"
30#include "kernel.h" 30#include "kernel.h"
31#include "sprintf.h"
32#include "structec.h" 31#include "structec.h"
33#include "action.h" 32#include "action.h"
34#include "debug.h" 33#include "debug.h"
diff --git a/apps/enc_config.c b/apps/enc_config.c
index 48ad18f771..ca8aebb451 100644
--- a/apps/enc_config.c
+++ b/apps/enc_config.c
@@ -19,7 +19,6 @@
19 * 19 *
20 ****************************************************************************/ 20 ****************************************************************************/
21#include <stdio.h> 21#include <stdio.h>
22#include <sprintf.h>
23#include <string.h> 22#include <string.h>
24#include <stdlib.h> 23#include <stdlib.h>
25#include "config.h" 24#include "config.h"
diff --git a/apps/filetree.c b/apps/filetree.c
index e3977e5a44..9ff48dc451 100644
--- a/apps/filetree.c
+++ b/apps/filetree.c
@@ -38,7 +38,6 @@
38#include "screens.h" 38#include "screens.h"
39#include "plugin.h" 39#include "plugin.h"
40#include "rolo.h" 40#include "rolo.h"
41#include "sprintf.h"
42#include "splash.h" 41#include "splash.h"
43#include "cuesheet.h" 42#include "cuesheet.h"
44#include "filetree.h" 43#include "filetree.h"
diff --git a/apps/filetypes.c b/apps/filetypes.c
index 4aefef1f0d..3c8f4b9a39 100644
--- a/apps/filetypes.c
+++ b/apps/filetypes.c
@@ -26,7 +26,6 @@
26#include "string.h" 26#include "string.h"
27#include <ctype.h> 27#include <ctype.h>
28 28
29#include "sprintf.h"
30#include "settings.h" 29#include "settings.h"
31#include "debug.h" 30#include "debug.h"
32#include "lang.h" 31#include "lang.h"
diff --git a/apps/gui/bitmap/list.c b/apps/gui/bitmap/list.c
index 10616c9df4..0da67c7c1e 100644
--- a/apps/gui/bitmap/list.c
+++ b/apps/gui/bitmap/list.c
@@ -25,7 +25,6 @@
25#include "lcd.h" 25#include "lcd.h"
26#include "font.h" 26#include "font.h"
27#include "button.h" 27#include "button.h"
28#include "sprintf.h"
29#include "string.h" 28#include "string.h"
30#include "settings.h" 29#include "settings.h"
31#include "kernel.h" 30#include "kernel.h"
diff --git a/apps/gui/charcell/list.c b/apps/gui/charcell/list.c
index f36d3c9f7d..8eebfe7fa1 100644
--- a/apps/gui/charcell/list.c
+++ b/apps/gui/charcell/list.c
@@ -25,7 +25,6 @@
25#include "lcd.h" 25#include "lcd.h"
26#include "font.h" 26#include "font.h"
27#include "button.h" 27#include "button.h"
28#include "sprintf.h"
29#include "string.h" 28#include "string.h"
30#include "settings.h" 29#include "settings.h"
31#include "kernel.h" 30#include "kernel.h"
diff --git a/apps/gui/list.c b/apps/gui/list.c
index 11a4c36015..de76310e0b 100644
--- a/apps/gui/list.c
+++ b/apps/gui/list.c
@@ -19,11 +19,11 @@
19 * 19 *
20 ****************************************************************************/ 20 ****************************************************************************/
21 21
22#include <stdarg.h>
22#include "config.h" 23#include "config.h"
23#include "lcd.h" 24#include "lcd.h"
24#include "font.h" 25#include "font.h"
25#include "button.h" 26#include "button.h"
26#include "sprintf.h"
27#include "string.h" 27#include "string.h"
28#include "settings.h" 28#include "settings.h"
29#include "kernel.h" 29#include "kernel.h"
diff --git a/apps/gui/option_select.c b/apps/gui/option_select.c
index 71a28cb520..feed1dc2db 100644
--- a/apps/gui/option_select.c
+++ b/apps/gui/option_select.c
@@ -20,10 +20,9 @@
20 * 20 *
21 ****************************************************************************/ 21 ****************************************************************************/
22#include <stdlib.h> 22#include <stdlib.h>
23#include <string.h> 23#include "string-extra.h"
24#include "config.h" 24#include "config.h"
25#include "option_select.h" 25#include "option_select.h"
26#include "sprintf.h"
27#include "kernel.h" 26#include "kernel.h"
28#include "lang.h" 27#include "lang.h"
29#include "talk.h" 28#include "talk.h"
diff --git a/apps/gui/pitchscreen.c b/apps/gui/pitchscreen.c
index 77b5739be1..a0058724ec 100644
--- a/apps/gui/pitchscreen.c
+++ b/apps/gui/pitchscreen.c
@@ -23,9 +23,8 @@
23#include <string.h> 23#include <string.h>
24#include <stdio.h> 24#include <stdio.h>
25#include <math.h> 25#include <math.h>
26#include <stdlib.h> /* for ABS() */ 26#include <stdlib.h> /* for abs() */
27#include "config.h" 27#include "config.h"
28#include "sprintf.h"
29#include "action.h" 28#include "action.h"
30#include "dsp.h" 29#include "dsp.h"
31#include "sound.h" 30#include "sound.h"
@@ -248,10 +247,10 @@ static void pitchscreen_draw(struct screen *display, int max_lines,
248 /* Pitch:XXX.X% */ 247 /* Pitch:XXX.X% */
249 if(global_settings.pitch_mode_semitone) 248 if(global_settings.pitch_mode_semitone)
250 { 249 {
251 snprintf(buf, sizeof(buf), "%s: %s%ld.%02ld", str(LANG_PITCH), 250 snprintf(buf, sizeof(buf), "%s: %s%d.%02d", str(LANG_PITCH),
252 semitone >= 0 ? "+" : "-", 251 semitone >= 0 ? "+" : "-",
253 ABS(semitone / PITCH_SPEED_PRECISION), 252 abs(semitone / PITCH_SPEED_PRECISION),
254 ABS((semitone % PITCH_SPEED_PRECISION) / 253 abs((semitone % PITCH_SPEED_PRECISION) /
255 (PITCH_SPEED_PRECISION / 100)) 254 (PITCH_SPEED_PRECISION / 100))
256 ); 255 );
257 } 256 }
@@ -290,10 +289,10 @@ static void pitchscreen_draw(struct screen *display, int max_lines,
290 { 289 {
291 if(global_settings.pitch_mode_semitone) 290 if(global_settings.pitch_mode_semitone)
292 { 291 {
293 snprintf(buf, sizeof(buf), "%s%ld.%02ld", 292 snprintf(buf, sizeof(buf), "%s%d.%02d",
294 semitone >= 0 ? "+" : "-", 293 semitone >= 0 ? "+" : "-",
295 ABS(semitone / PITCH_SPEED_PRECISION), 294 abs(semitone / PITCH_SPEED_PRECISION),
296 ABS((semitone % PITCH_SPEED_PRECISION) / 295 abs((semitone % PITCH_SPEED_PRECISION) /
297 (PITCH_SPEED_PRECISION / 100)) 296 (PITCH_SPEED_PRECISION / 100))
298 ); 297 );
299 } 298 }
diff --git a/apps/gui/skin_engine/skin_backdrops.c b/apps/gui/skin_engine/skin_backdrops.c
index fd786a7882..77de8bdc1a 100644
--- a/apps/gui/skin_engine/skin_backdrops.c
+++ b/apps/gui/skin_engine/skin_backdrops.c
@@ -21,9 +21,8 @@
21 21
22#include "config.h" 22#include "config.h"
23#include <stdio.h> 23#include <stdio.h>
24#include <string.h>
25#include <stdlib.h> 24#include <stdlib.h>
26 25#include "string-extra.h"
27#include "settings.h" 26#include "settings.h"
28#include "skin_buffer.h" 27#include "skin_buffer.h"
29#include "wps_internals.h" 28#include "wps_internals.h"
diff --git a/apps/gui/skin_engine/skin_display.c b/apps/gui/skin_engine/skin_display.c
index 0d7824aaf6..d3169be43a 100644
--- a/apps/gui/skin_engine/skin_display.c
+++ b/apps/gui/skin_engine/skin_display.c
@@ -21,7 +21,7 @@
21 ****************************************************************************/ 21 ****************************************************************************/
22#include "config.h" 22#include "config.h"
23#include <stdio.h> 23#include <stdio.h>
24#include <string.h> 24#include "string-extra.h"
25#include "misc.h" 25#include "misc.h"
26#include "font.h" 26#include "font.h"
27#include "system.h" 27#include "system.h"
diff --git a/apps/gui/skin_engine/skin_tokens.c b/apps/gui/skin_engine/skin_tokens.c
index 4ee8c74cdd..6e5a2eae85 100644
--- a/apps/gui/skin_engine/skin_tokens.c
+++ b/apps/gui/skin_engine/skin_tokens.c
@@ -21,7 +21,7 @@
21 ****************************************************************************/ 21 ****************************************************************************/
22#include "font.h" 22#include "font.h"
23#include <stdio.h> 23#include <stdio.h>
24#include <string.h> 24#include "string-extra.h"
25#include <stdlib.h> 25#include <stdlib.h>
26#include "action.h" 26#include "action.h"
27#include "system.h" 27#include "system.h"
@@ -247,7 +247,7 @@ const char *get_id3_token(struct wps_token *token, struct mp3entry *id3,
247 { 247 {
248 *intval = limit * elapsed / length + 1; 248 *intval = limit * elapsed / length + 1;
249 } 249 }
250 snprintf(buf, buf_size, "%d", 100 * elapsed / length); 250 snprintf(buf, buf_size, "%lu", 100 * elapsed / length);
251 return buf; 251 return buf;
252 252
253 253
@@ -269,7 +269,7 @@ const char *get_id3_token(struct wps_token *token, struct mp3entry *id3,
269 if ((id3->frequency % 1000) < 100) 269 if ((id3->frequency % 1000) < 100)
270 snprintf(buf, buf_size, "%ld", id3->frequency / 1000); 270 snprintf(buf, buf_size, "%ld", id3->frequency / 1000);
271 else 271 else
272 snprintf(buf, buf_size, "%ld.%d", 272 snprintf(buf, buf_size, "%ld.%lu",
273 id3->frequency / 1000, 273 id3->frequency / 1000,
274 (id3->frequency % 1000) / 100); 274 (id3->frequency % 1000) / 100);
275 return buf; 275 return buf;
@@ -302,12 +302,12 @@ const char *get_id3_token(struct wps_token *token, struct mp3entry *id3,
302 case WPS_TOKEN_DATABASE_RATING: 302 case WPS_TOKEN_DATABASE_RATING:
303 if (intval) 303 if (intval)
304 *intval = id3->rating + 1; 304 *intval = id3->rating + 1;
305 snprintf(buf, buf_size, "%ld", id3->rating); 305 snprintf(buf, buf_size, "%d", id3->rating);
306 return buf; 306 return buf;
307 case WPS_TOKEN_DATABASE_AUTOSCORE: 307 case WPS_TOKEN_DATABASE_AUTOSCORE:
308 if (intval) 308 if (intval)
309 *intval = id3->score + 1; 309 *intval = id3->score + 1;
310 snprintf(buf, buf_size, "%ld", id3->score); 310 snprintf(buf, buf_size, "%d", id3->score);
311 return buf; 311 return buf;
312#endif 312#endif
313 313
@@ -1064,7 +1064,7 @@ const char *get_token_value(struct gui_wps *gwps,
1064 break;) 1064 break;)
1065 } 1065 }
1066 } 1066 }
1067 snprintf(buf, buf_size, "%d.%1d", samprk/1000,samprk%1000); 1067 snprintf(buf, buf_size, "%lu.%1lu", samprk/1000,samprk%1000);
1068#else /* HWCODEC */ 1068#else /* HWCODEC */
1069 1069
1070 static const char * const freq_strings[] = 1070 static const char * const freq_strings[] =
@@ -1164,7 +1164,7 @@ const char *get_token_value(struct gui_wps *gwps,
1164 #endif 1164 #endif
1165 *intval = global_settings.mp3_enc_config.bitrate+1; 1165 *intval = global_settings.mp3_enc_config.bitrate+1;
1166 } 1166 }
1167 snprintf(buf, buf_size, "%d", global_settings.mp3_enc_config.bitrate+1); 1167 snprintf(buf, buf_size, "%lu", global_settings.mp3_enc_config.bitrate+1);
1168 return buf; 1168 return buf;
1169 } 1169 }
1170 else 1170 else
diff --git a/apps/gui/statusbar.c b/apps/gui/statusbar.c
index bc5570ee4e..901615d98a 100644
--- a/apps/gui/statusbar.c
+++ b/apps/gui/statusbar.c
@@ -19,11 +19,11 @@
19 * 19 *
20 ****************************************************************************/ 20 ****************************************************************************/
21 21
22#include <stdio.h>
22#include "config.h" 23#include "config.h"
23#include "font.h" 24#include "font.h"
24#include "kernel.h" 25#include "kernel.h"
25#include "string.h" /* for memcmp oO*/ 26#include "string.h" /* for memcmp oO*/
26#include "sprintf.h"
27#include "sound.h" 27#include "sound.h"
28#include "settings.h" 28#include "settings.h"
29#include "viewport.h" 29#include "viewport.h"
diff --git a/apps/gui/usb_screen.c b/apps/gui/usb_screen.c
index 019aec61ff..9895defc2b 100644
--- a/apps/gui/usb_screen.c
+++ b/apps/gui/usb_screen.c
@@ -30,7 +30,6 @@
30#include "usb_core.h" 30#include "usb_core.h"
31#ifdef USB_ENABLE_HID 31#ifdef USB_ENABLE_HID
32#include "usb_keymaps.h" 32#include "usb_keymaps.h"
33#include "sprintf.h"
34#endif 33#endif
35#endif 34#endif
36#include "settings.h" 35#include "settings.h"
diff --git a/apps/gui/viewport.c b/apps/gui/viewport.c
index 03f004ba87..7d128188c3 100644
--- a/apps/gui/viewport.c
+++ b/apps/gui/viewport.c
@@ -41,7 +41,6 @@
41/* all below isn't needed for pc tools (i.e. checkwps/wps editor) 41/* all below isn't needed for pc tools (i.e. checkwps/wps editor)
42 * only viewport_parse_viewport() is */ 42 * only viewport_parse_viewport() is */
43#ifndef __PCTOOL__ 43#ifndef __PCTOOL__
44#include "sprintf.h"
45#include "string.h" 44#include "string.h"
46#include "kernel.h" 45#include "kernel.h"
47#include "system.h" 46#include "system.h"
diff --git a/apps/gui/wps.c b/apps/gui/wps.c
index afd7f3f2d0..916ca2cbcf 100644
--- a/apps/gui/wps.c
+++ b/apps/gui/wps.c
@@ -31,7 +31,6 @@
31#include "action.h" 31#include "action.h"
32#include "kernel.h" 32#include "kernel.h"
33#include "filetypes.h" 33#include "filetypes.h"
34#include "sprintf.h"
35#include "settings.h" 34#include "settings.h"
36#include "skin_engine/skin_engine.h" 35#include "skin_engine/skin_engine.h"
37#include "mp3_playback.h" 36#include "mp3_playback.h"
diff --git a/apps/main.c b/apps/main.c
index 5b9ecdad79..b043dacede 100644
--- a/apps/main.c
+++ b/apps/main.c
@@ -49,7 +49,6 @@
49#include "status.h" 49#include "status.h"
50#include "debug_menu.h" 50#include "debug_menu.h"
51#include "version.h" 51#include "version.h"
52#include "sprintf.h"
53#include "font.h" 52#include "font.h"
54#include "language.h" 53#include "language.h"
55#include "wps.h" 54#include "wps.h"
diff --git a/apps/menus/eq_menu.c b/apps/menus/eq_menu.c
index 16d5b82c91..066787a896 100644
--- a/apps/menus/eq_menu.c
+++ b/apps/menus/eq_menu.c
@@ -35,7 +35,6 @@
35#include "icons.h" 35#include "icons.h"
36#include "font.h" 36#include "font.h"
37#include "lang.h" 37#include "lang.h"
38#include "sprintf.h"
39#include "talk.h" 38#include "talk.h"
40#include "misc.h" 39#include "misc.h"
41#include "sound.h" 40#include "sound.h"
diff --git a/apps/menus/recording_menu.c b/apps/menus/recording_menu.c
index 800918b755..daea1ea8fc 100644
--- a/apps/menus/recording_menu.c
+++ b/apps/menus/recording_menu.c
@@ -38,7 +38,6 @@
38#include "scrollbar.h" 38#include "scrollbar.h"
39#endif 39#endif
40#include "lang.h" 40#include "lang.h"
41#include "sprintf.h"
42#include "talk.h" 41#include "talk.h"
43#include "misc.h" 42#include "misc.h"
44#include "sound.h" 43#include "sound.h"
diff --git a/apps/menus/settings_menu.c b/apps/menus/settings_menu.c
index db2ad78fdc..1007d2aeb0 100644
--- a/apps/menus/settings_menu.c
+++ b/apps/menus/settings_menu.c
@@ -35,7 +35,6 @@
35#include "usb.h" 35#include "usb.h"
36#include "splash.h" 36#include "splash.h"
37#include "talk.h" 37#include "talk.h"
38#include "sprintf.h"
39#include "powermgmt.h" 38#include "powermgmt.h"
40#if CONFIG_CODEC == SWCODEC 39#if CONFIG_CODEC == SWCODEC
41#include "playback.h" 40#include "playback.h"
diff --git a/apps/menus/time_menu.c b/apps/menus/time_menu.c
index 597f7e0c3a..a529837b07 100644
--- a/apps/menus/time_menu.c
+++ b/apps/menus/time_menu.c
@@ -22,9 +22,9 @@
22#include <stdbool.h> 22#include <stdbool.h>
23#include <stddef.h> 23#include <stddef.h>
24#include <limits.h> 24#include <limits.h>
25#include <stdio.h>
25#include "config.h" 26#include "config.h"
26#include "string.h" 27#include "string.h"
27#include "sprintf.h"
28#include "lang.h" 28#include "lang.h"
29#include "action.h" 29#include "action.h"
30#include "settings.h" 30#include "settings.h"
@@ -201,7 +201,7 @@ static void draw_timedate(struct viewport *vp, struct screen *display)
201} 201}
202 202
203 203
204static struct viewport clock[NB_SCREENS], menu[NB_SCREENS]; 204static struct viewport clock_vps[NB_SCREENS], menu[NB_SCREENS];
205static bool menu_was_pressed; 205static bool menu_was_pressed;
206static int time_menu_callback(int action, 206static int time_menu_callback(int action,
207 const struct menu_item_ex *this_item) 207 const struct menu_item_ex *this_item)
@@ -233,7 +233,7 @@ static int time_menu_callback(int action,
233 { 233 {
234 last_redraw = current_tick; 234 last_redraw = current_tick;
235 FOR_NB_SCREENS(i) 235 FOR_NB_SCREENS(i)
236 draw_timedate(&clock[i], &screens[i]); 236 draw_timedate(&clock_vps[i], &screens[i]);
237 } 237 }
238 return action; 238 return action;
239} 239}
@@ -257,30 +257,30 @@ int time_screen(void* ignored)
257 257
258 FOR_NB_SCREENS(i) 258 FOR_NB_SCREENS(i)
259 { 259 {
260 viewport_set_defaults(&clock[i], i); 260 viewport_set_defaults(&clock_vps[i], i);
261#ifdef HAVE_BUTTONBAR 261#ifdef HAVE_BUTTONBAR
262 if (global_settings.buttonbar) 262 if (global_settings.buttonbar)
263 { 263 {
264 clock[i].height -= BUTTONBAR_HEIGHT; 264 clock_vps[i].height -= BUTTONBAR_HEIGHT;
265 } 265 }
266#endif 266#endif
267 nb_lines = viewport_get_nb_lines(&clock[i]); 267 nb_lines = viewport_get_nb_lines(&clock_vps[i]);
268 268
269 menu[i] = clock[i]; 269 menu[i] = clock_vps[i];
270 /* force time to be drawn centered */ 270 /* force time to be drawn centered */
271 clock[i].flags |= VP_FLAG_ALIGN_CENTER; 271 clock_vps[i].flags |= VP_FLAG_ALIGN_CENTER;
272 272
273 font_h = font_get(clock[i].font)->height; 273 font_h = font_get(clock_vps[i].font)->height;
274 nb_lines -= 2; /* at least 2 lines for menu */ 274 nb_lines -= 2; /* at least 2 lines for menu */
275 if (nb_lines > 4) 275 if (nb_lines > 4)
276 nb_lines = 4; 276 nb_lines = 4;
277 if (nb_lines >= 2) 277 if (nb_lines >= 2)
278 clock[i].height = nb_lines*font_h; 278 clock_vps[i].height = nb_lines*font_h;
279 else /* disable the clock drawing */ 279 else /* disable the clock_vps drawing */
280 clock[i].height = 0; 280 clock_vps[i].height = 0;
281 menu[i].y += clock[i].height; 281 menu[i].y += clock_vps[i].height;
282 menu[i].height -= clock[i].height; 282 menu[i].height -= clock_vps[i].height;
283 draw_timedate(&clock[i], &screens[i]); 283 draw_timedate(&clock_vps[i], &screens[i]);
284 } 284 }
285 285
286 ret = do_menu(&time_menu, NULL, menu, false); 286 ret = do_menu(&time_menu, NULL, menu, false);
diff --git a/apps/metadata.c b/apps/metadata.c
index 1dfc3763c6..2a49392193 100644
--- a/apps/metadata.c
+++ b/apps/metadata.c
@@ -19,10 +19,9 @@
19 * 19 *
20 ****************************************************************************/ 20 ****************************************************************************/
21#include <stdio.h> 21#include <stdio.h>
22#include <string.h>
23#include <stdlib.h> 22#include <stdlib.h>
24#include <ctype.h> 23#include <ctype.h>
25#include <inttypes.h> 24#include "string-extra.h"
26 25
27#include "debug.h" 26#include "debug.h"
28#include "logf.h" 27#include "logf.h"
diff --git a/apps/metadata/metadata_common.c b/apps/metadata/metadata_common.c
index fd1cd553e8..e1ef9a0d62 100644
--- a/apps/metadata/metadata_common.c
+++ b/apps/metadata/metadata_common.c
@@ -19,7 +19,7 @@
19 * 19 *
20 ****************************************************************************/ 20 ****************************************************************************/
21#include <stdio.h> 21#include <stdio.h>
22#include <string.h> 22#include "string-extra.h"
23#include <stdlib.h> 23#include <stdlib.h>
24#include <ctype.h> 24#include <ctype.h>
25#include <inttypes.h> 25#include <inttypes.h>
diff --git a/apps/metadata/metadata_common.h b/apps/metadata/metadata_common.h
index 3962e2cd17..b2c76afb45 100644
--- a/apps/metadata/metadata_common.h
+++ b/apps/metadata/metadata_common.h
@@ -18,6 +18,7 @@
18 * KIND, either express or implied. 18 * KIND, either express or implied.
19 * 19 *
20 ****************************************************************************/ 20 ****************************************************************************/
21#include <inttypes.h>
21#include "metadata.h" 22#include "metadata.h"
22 23
23#ifdef ROCKBOX_BIG_ENDIAN 24#ifdef ROCKBOX_BIG_ENDIAN
diff --git a/apps/metadata/mp3.c b/apps/metadata/mp3.c
index 84c565b8be..49d5c7362e 100644
--- a/apps/metadata/mp3.c
+++ b/apps/metadata/mp3.c
@@ -30,11 +30,11 @@
30 30
31#include <stdio.h> 31#include <stdio.h>
32#include <stdlib.h> 32#include <stdlib.h>
33#include <string.h>
34#include <errno.h> 33#include <errno.h>
35#include <stdbool.h> 34#include <stdbool.h>
36#include <stddef.h> 35#include <stddef.h>
37#include <ctype.h> 36#include <ctype.h>
37#include "string-extra.h"
38#include "config.h" 38#include "config.h"
39#include "file.h" 39#include "file.h"
40#include "logf.h" 40#include "logf.h"
diff --git a/apps/metadata/smaf.c b/apps/metadata/smaf.c
index ca5b690e0b..fa12c99fb9 100644
--- a/apps/metadata/smaf.c
+++ b/apps/metadata/smaf.c
@@ -18,9 +18,9 @@
18 * KIND, either express or implied. 18 * KIND, either express or implied.
19 * 19 *
20 ****************************************************************************/ 20 ****************************************************************************/
21#include <string.h>
22#include <inttypes.h> 21#include <inttypes.h>
23 22
23#include "string-extra.h"
24#include "system.h" 24#include "system.h"
25#include "metadata.h" 25#include "metadata.h"
26#include "metadata_common.h" 26#include "metadata_common.h"
diff --git a/apps/misc.c b/apps/misc.c
index 22f21d2106..3dfc2892ca 100644
--- a/apps/misc.c
+++ b/apps/misc.c
@@ -20,17 +20,15 @@
20 ****************************************************************************/ 20 ****************************************************************************/
21#include <stdlib.h> 21#include <stdlib.h>
22#include <ctype.h> 22#include <ctype.h>
23#include <string.h> 23#include <stdio.h>
24#include <stdarg.h>
24#include <errno.h> 25#include <errno.h>
26#include "string-extra.h"
25#include "config.h" 27#include "config.h"
26#include "misc.h" 28#include "misc.h"
27#include "lcd.h" 29#include "lcd.h"
28#include "file.h" 30#include "file.h"
29#ifdef __PCTOOL__ 31#ifndef __PCTOOL__
30#include <stdarg.h>
31#include <stdio.h>
32#else
33#include "sprintf.h"
34#include "lang.h" 32#include "lang.h"
35#include "dir.h" 33#include "dir.h"
36#include "lcd-remote.h" 34#include "lcd-remote.h"
diff --git a/apps/onplay.c b/apps/onplay.c
index 617f523879..009b375871 100644
--- a/apps/onplay.c
+++ b/apps/onplay.c
@@ -25,7 +25,6 @@
25#include <stdbool.h> 25#include <stdbool.h>
26 26
27#include "debug.h" 27#include "debug.h"
28#include "sprintf.h"
29#include "lcd.h" 28#include "lcd.h"
30#include "dir.h" 29#include "dir.h"
31#include "file.h" 30#include "file.h"
diff --git a/apps/player/keyboard.c b/apps/player/keyboard.c
index e657f36697..1c6dc9bb0d 100644
--- a/apps/player/keyboard.c
+++ b/apps/player/keyboard.c
@@ -23,7 +23,6 @@
23#include "kernel.h" 23#include "kernel.h"
24#include "system.h" 24#include "system.h"
25#include "version.h" 25#include "version.h"
26#include "sprintf.h"
27#include <string.h> 26#include <string.h>
28#include "settings.h" 27#include "settings.h"
29#include "statusbar.h" 28#include "statusbar.h"
diff --git a/apps/playlist.c b/apps/playlist.c
index da801968ef..21e1eed083 100644
--- a/apps/playlist.c
+++ b/apps/playlist.c
@@ -68,15 +68,14 @@
68 */ 68 */
69 69
70#include <stdio.h> 70#include <stdio.h>
71#include <stdlib.h> 71#include <stdlib.h>
72#include <string.h> 72#include <ctype.h>
73#include <ctype.h> 73#include "string-extra.h"
74#include "playlist.h" 74#include "playlist.h"
75#include "ata_idle_notify.h" 75#include "ata_idle_notify.h"
76#include "file.h" 76#include "file.h"
77#include "action.h" 77#include "action.h"
78#include "dir.h" 78#include "dir.h"
79#include "sprintf.h"
80#include "debug.h" 79#include "debug.h"
81#include "audio.h" 80#include "audio.h"
82#include "lcd.h" 81#include "lcd.h"
diff --git a/apps/playlist_catalog.c b/apps/playlist_catalog.c
index 4f3c8af231..f9a43da411 100644
--- a/apps/playlist_catalog.c
+++ b/apps/playlist_catalog.c
@@ -22,7 +22,7 @@
22#include <stdbool.h> 22#include <stdbool.h>
23#include <stdio.h> 23#include <stdio.h>
24#include <stdlib.h> 24#include <stdlib.h>
25#include <string.h> 25#include "string-extra.h"
26#include "action.h" 26#include "action.h"
27#include "dir.h" 27#include "dir.h"
28#include "file.h" 28#include "file.h"
@@ -36,7 +36,6 @@
36#include "playlist.h" 36#include "playlist.h"
37#include "settings.h" 37#include "settings.h"
38#include "splash.h" 38#include "splash.h"
39#include "sprintf.h"
40#include "tree.h" 39#include "tree.h"
41#include "yesno.h" 40#include "yesno.h"
42#include "filetypes.h" 41#include "filetypes.h"
diff --git a/apps/playlist_viewer.c b/apps/playlist_viewer.c
index e2be36ce5d..e0ab3bb9bd 100644
--- a/apps/playlist_viewer.c
+++ b/apps/playlist_viewer.c
@@ -24,7 +24,6 @@
24 * multi-screen support, rewrote a lot of code 24 * multi-screen support, rewrote a lot of code
25 */ 25 */
26#include <string.h> 26#include <string.h>
27#include <sprintf.h>
28#include "playlist.h" 27#include "playlist.h"
29#include "audio.h" 28#include "audio.h"
30#include "screens.h" 29#include "screens.h"
diff --git a/apps/plugin.c b/apps/plugin.c
index baf9b60eb8..8a32a159b4 100644
--- a/apps/plugin.c
+++ b/apps/plugin.c
@@ -21,7 +21,6 @@
21#include "plugin.h" 21#include "plugin.h"
22#include <ctype.h> 22#include <ctype.h>
23#include <string.h> 23#include <string.h>
24#include <sprintf.h>
25#include <stdlib.h> 24#include <stdlib.h>
26#include "debug.h" 25#include "debug.h"
27#include "i2c.h" 26#include "i2c.h"
diff --git a/apps/plugin.h b/apps/plugin.h
index 5f594e6cf5..e6e41e1a3f 100644
--- a/apps/plugin.h
+++ b/apps/plugin.h
@@ -32,11 +32,13 @@
32#endif 32#endif
33 33
34#include <stdbool.h> 34#include <stdbool.h>
35#include <inttypes.h>
35#include <sys/types.h> 36#include <sys/types.h>
36#include <stdarg.h> 37#include <stdarg.h>
37#include <stdio.h> 38#include <stdio.h>
38#include <stdlib.h> 39#include <stdlib.h>
39#include <string.h> 40#include <string.h>
41#include "string-extra.h"
40 42
41char* strncpy(char *, const char *, size_t); 43char* strncpy(char *, const char *, size_t);
42void* plugin_get_buffer(size_t *buffer_size); 44void* plugin_get_buffer(size_t *buffer_size);
@@ -111,6 +113,11 @@ void* plugin_get_buffer(size_t *buffer_size);
111#include "usbstack/usb_hid_usage_tables.h" 113#include "usbstack/usb_hid_usage_tables.h"
112#endif 114#endif
113 115
116
117/* on some platforms strcmp() seems to be a tricky define which
118 * breaks if we write down strcmp's prototype */
119#undef strcmp
120
114#ifdef PLUGIN 121#ifdef PLUGIN
115 122
116#if defined(DEBUG) || defined(SIMULATOR) 123#if defined(DEBUG) || defined(SIMULATOR)
@@ -529,7 +536,7 @@ struct plugin_api {
529 /* strings and memory */ 536 /* strings and memory */
530 int (*snprintf)(char *buf, size_t size, const char *fmt, ...) 537 int (*snprintf)(char *buf, size_t size, const char *fmt, ...)
531 ATTRIBUTE_PRINTF(3, 4); 538 ATTRIBUTE_PRINTF(3, 4);
532 int (*vsnprintf)(char *buf, int size, const char *fmt, va_list ap); 539 int (*vsnprintf)(char *buf, size_t size, const char *fmt, va_list ap);
533 char* (*strcpy)(char *dst, const char *src); 540 char* (*strcpy)(char *dst, const char *src);
534 size_t (*strlcpy)(char *dst, const char *src, size_t length); 541 size_t (*strlcpy)(char *dst, const char *src, size_t length);
535 size_t (*strlen)(const char *str); 542 size_t (*strlen)(const char *str);
diff --git a/apps/plugins/calculator.c b/apps/plugins/calculator.c
index 942f031890..c19d6bbc5b 100644
--- a/apps/plugins/calculator.c
+++ b/apps/plugins/calculator.c
@@ -102,6 +102,9 @@ PLUGIN_HEADER
102#define X_5_POS (X_4_POS + REC_WIDTH) /* x5 = 110, column 111 left blank */ 102#define X_5_POS (X_4_POS + REC_WIDTH) /* x5 = 110, column 111 left blank */
103 103
104#define SIGN(x) ((x)<0?-1:1) 104#define SIGN(x) ((x)<0?-1:1)
105#ifndef ABS
106#define ABS(a) (((a) < 0) ? -(a) : (a))
107#endif
105 108
106/* variable button definitions */ 109/* variable button definitions */
107#if CONFIG_KEYPAD == RECORDER_PAD 110#if CONFIG_KEYPAD == RECORDER_PAD
diff --git a/apps/plugins/doom/d_deh.c b/apps/plugins/doom/d_deh.c
index d3f7496885..82426c1bab 100644
--- a/apps/plugins/doom/d_deh.c
+++ b/apps/plugins/doom/d_deh.c
@@ -44,7 +44,7 @@
44#include "d_think.h" 44#include "d_think.h"
45#include "w_wad.h" 45#include "w_wad.h"
46 46
47#include "sscanf.h" 47#include <stdio.h> /* sscanf */
48#include "rockmacros.h" 48#include "rockmacros.h"
49 49
50#define TRUE 1 50#define TRUE 1
diff --git a/apps/plugins/doom/doom.make b/apps/plugins/doom/doom.make
index bdc32230eb..54a63eb707 100644
--- a/apps/plugins/doom/doom.make
+++ b/apps/plugins/doom/doom.make
@@ -13,7 +13,7 @@ DOOMBUILDDIR := $(BUILDDIR)/apps/plugins/doom
13ROCKS += $(DOOMBUILDDIR)/doom.rock 13ROCKS += $(DOOMBUILDDIR)/doom.rock
14 14
15DOOM_SRC := $(call preprocess, $(DOOMSRCDIR)/SOURCES) 15DOOM_SRC := $(call preprocess, $(DOOMSRCDIR)/SOURCES)
16DOOM_SRC += $(ROOTDIR)/firmware/common/sscanf.c 16DOOM_SRC += $(ROOTDIR)/firmware/libc/sscanf.c
17DOOM_OBJ := $(call c2obj, $(DOOM_SRC)) 17DOOM_OBJ := $(call c2obj, $(DOOM_SRC))
18 18
19# add source files to OTHER_SRC to get automatic dependencies 19# add source files to OTHER_SRC to get automatic dependencies
diff --git a/apps/plugins/doom/rockmacros.h b/apps/plugins/doom/rockmacros.h
index e066fe861c..89c943622a 100644
--- a/apps/plugins/doom/rockmacros.h
+++ b/apps/plugins/doom/rockmacros.h
@@ -33,9 +33,13 @@ extern bool doomexit;
33int printf(const char *fmt, ...); 33int printf(const char *fmt, ...);
34int fileexists(const char * fname); 34int fileexists(const char * fname);
35char *my_strtok( char * s, const char * delim ); 35char *my_strtok( char * s, const char * delim );
36#undef alloca
36#define alloca __builtin_alloca 37#define alloca __builtin_alloca
37#define fdprintf(...) rb->fdprintf(__VA_ARGS__) 38#undef fdprintf
39#define fdprintf(...) rb->fdprintf(__VA_ARGS__)
40#undef vsnprintf
38#define vsnprintf(...) rb->vsnprintf(__VA_ARGS__) 41#define vsnprintf(...) rb->vsnprintf(__VA_ARGS__)
42#undef read_line
39#define read_line(a,b,c) rb->read_line((a),(b),(c)) 43#define read_line(a,b,c) rb->read_line((a),(b),(c))
40 44
41#ifdef SIMULATOR 45#ifdef SIMULATOR
@@ -52,19 +56,33 @@ int my_close(int id);
52#define filesize(a) rb->filesize((a)) 56#define filesize(a) rb->filesize((a))
53#define read(a,b,c) rb->read((a),(b),(c)) 57#define read(a,b,c) rb->read((a),(b),(c))
54#define write(a,b,c) rb->write((a),(b),(c)) 58#define write(a,b,c) rb->write((a),(b),(c))
59#undef strtok
55#define strtok(a,b) my_strtok((a),(b)) 60#define strtok(a,b) my_strtok((a),(b))
61#undef strcat
56#define strcat(a,b) rb->strcat((a),(b)) 62#define strcat(a,b) rb->strcat((a),(b))
63#undef memset
57#define memset(a,b,c) rb->memset((a),(b),(c)) 64#define memset(a,b,c) rb->memset((a),(b),(c))
65#undef memmove
58#define memmove(a,b,c) rb->memmove((a),(b),(c)) 66#define memmove(a,b,c) rb->memmove((a),(b),(c))
67#undef memcmp
59#define memcmp(a,b,c) rb->memcmp((a),(b),(c)) 68#define memcmp(a,b,c) rb->memcmp((a),(b),(c))
69#undef memchr
60#define memchr(a,b,c) rb->memchr((a),(b),(c)) 70#define memchr(a,b,c) rb->memchr((a),(b),(c))
71#undef strcpy
61#define strcpy(a,b) rb->strcpy((a),(b)) 72#define strcpy(a,b) rb->strcpy((a),(b))
73#undef strlen
62#define strlen(a) rb->strlen((a)) 74#define strlen(a) rb->strlen((a))
75#undef strcmp
63#define strcmp(a,b) rb->strcmp((a),(b)) 76#define strcmp(a,b) rb->strcmp((a),(b))
77#undef strncmp
64#define strncmp(a,b,c) rb->strncmp((a),(b),(c)) 78#define strncmp(a,b,c) rb->strncmp((a),(b),(c))
79#undef strchr
65#define strchr(a,b) rb->strchr((a),(b)) 80#define strchr(a,b) rb->strchr((a),(b))
81#undef strrchr
66#define strrchr(a,b) rb->strrchr((a),(b)) 82#define strrchr(a,b) rb->strrchr((a),(b))
83#undef strcasecmp
67#define strcasecmp(a,b) rb->strcasecmp((a),(b)) 84#define strcasecmp(a,b) rb->strcasecmp((a),(b))
85#undef strncasecmp
68#define strncasecmp(a,b,c) rb->strncasecmp((a),(b),(c)) 86#define strncasecmp(a,b,c) rb->strncasecmp((a),(b),(c))
69#define srand(a) rb->srand((a)) 87#define srand(a) rb->srand((a))
70#define rand() rb->rand() 88#define rand() rb->rand()
diff --git a/apps/plugins/frotz/frotz.c b/apps/plugins/frotz/frotz.c
index 96029b85cb..f64431f14e 100644
--- a/apps/plugins/frotz/frotz.c
+++ b/apps/plugins/frotz/frotz.c
@@ -285,14 +285,14 @@ void os_beep(int volume)
285static unsigned char unget_buf; 285static unsigned char unget_buf;
286static int unget_file; 286static int unget_file;
287 287
288int ungetc(int c, int f) 288int frotz_ungetc(int c, int f)
289{ 289{
290 unget_file = f; 290 unget_file = f;
291 unget_buf = c; 291 unget_buf = c;
292 return c; 292 return c;
293} 293}
294 294
295int fgetc(int f) 295int frotz_fgetc(int f)
296{ 296{
297 unsigned char cb; 297 unsigned char cb;
298 if (unget_file == f) 298 if (unget_file == f)
@@ -305,7 +305,7 @@ int fgetc(int f)
305 return cb; 305 return cb;
306} 306}
307 307
308int fputc(int c, int f) 308int frotz_fputc(int c, int f)
309{ 309{
310 unsigned char cb = c; 310 unsigned char cb = c;
311 if (rb->write(f, &cb, 1) != 1) 311 if (rb->write(f, &cb, 1) != 1)
diff --git a/apps/plugins/frotz/frotzplugin.h b/apps/plugins/frotz/frotzplugin.h
index 8caddb470d..1a52bdb913 100644
--- a/apps/plugins/frotz/frotzplugin.h
+++ b/apps/plugins/frotz/frotzplugin.h
@@ -37,9 +37,12 @@
37/* 37/*
38 * we need functions for character io 38 * we need functions for character io
39 */ 39 */
40extern int ungetc(int c, int f); 40extern int frotz_ungetc(int c, int f);
41extern int fgetc(int f); 41#define ungetc frotz_ungetc
42extern int fputc(int c, int f); 42extern int frotz_fgetc(int f);
43#define fgetc frotz_fgetc
44extern int frotz_fputc(int c, int f);
45#define fputc frotz_fputc
43 46
44/* 47/*
45 * this is used instead of os_read_key for more prompts and the like 48 * this is used instead of os_read_key for more prompts and the like
diff --git a/apps/plugins/imageviewer/png/png.c b/apps/plugins/imageviewer/png/png.c
index 310b08d990..c398af70c5 100644
--- a/apps/plugins/imageviewer/png/png.c
+++ b/apps/plugins/imageviewer/png/png.c
@@ -1359,7 +1359,7 @@ int load_image(char *filename, struct image_info *info,
1359 1359
1360 } else { 1360 } else {
1361 if (!running_slideshow) { 1361 if (!running_slideshow) {
1362 rb->snprintf(print, sizeof(print), "loading %lu bytes", image_size); 1362 rb->snprintf(print, sizeof(print), "loading %zu bytes", image_size);
1363 rb->lcd_puts(0, 1, print); 1363 rb->lcd_puts(0, 1, print);
1364 rb->lcd_update(); 1364 rb->lcd_update();
1365 } 1365 }
diff --git a/apps/plugins/invadrox.c b/apps/plugins/invadrox.c
index 3e5c98e2a3..851487cf9a 100644
--- a/apps/plugins/invadrox.c
+++ b/apps/plugins/invadrox.c
@@ -81,6 +81,10 @@ PLUGIN_HEADER
81#define DBG(format, arg...) {} 81#define DBG(format, arg...) {}
82#endif 82#endif
83 83
84#ifndef ABS
85#define ABS(a) (((a) < 0) ? -(a) : (a))
86#endif
87
84#if CONFIG_KEYPAD == IRIVER_H100_PAD 88#if CONFIG_KEYPAD == IRIVER_H100_PAD
85 89
86#define QUIT BUTTON_OFF 90#define QUIT BUTTON_OFF
diff --git a/apps/plugins/lib/buflib.c b/apps/plugins/lib/buflib.c
index 5d03ca4bb9..930e49d02e 100644
--- a/apps/plugins/lib/buflib.c
+++ b/apps/plugins/lib/buflib.c
@@ -23,8 +23,8 @@
23* 23*
24****************************************************************************/ 24****************************************************************************/
25 25
26#include <stdlib.h> /* for abs() */
26#include "buflib.h" 27#include "buflib.h"
27
28/* The main goal of this design is fast fetching of the pointer for a handle. 28/* The main goal of this design is fast fetching of the pointer for a handle.
29 * For that reason, the handles are stored in a table at the end of the buffer 29 * For that reason, the handles are stored in a table at the end of the buffer
30 * with a fixed address, so that returning the pointer for a handle is a simple 30 * with a fixed address, so that returning the pointer for a handle is a simple
@@ -311,7 +311,7 @@ buflib_free(struct buflib_context *ctx, int handle_num)
311 while (next_block < freed_block) 311 while (next_block < freed_block)
312 { 312 {
313 block = next_block; 313 block = next_block;
314 next_block += ABS(block->val); 314 next_block += abs(block->val);
315 } 315 }
316 /* If next_block == block, the above loop didn't go anywhere. If it did, 316 /* If next_block == block, the above loop didn't go anywhere. If it did,
317 * and the block before this one is empty, we can combine them. 317 * and the block before this one is empty, we can combine them.
diff --git a/apps/plugins/lib/jhash.h b/apps/plugins/lib/jhash.h
index 97d1ac3d93..7699e24587 100644
--- a/apps/plugins/lib/jhash.h
+++ b/apps/plugins/lib/jhash.h
@@ -24,8 +24,8 @@
24#ifndef _LIB_JHASH_H_ 24#ifndef _LIB_JHASH_H_
25#define _LIB_JHASH_H_ 25#define _LIB_JHASH_H_
26#include <inttypes.h> /* defines uint32_t etc */ 26#include <inttypes.h> /* defines uint32_t etc */
27#include <sys/types.h> 27#include <string.h> /* size_t */
28#include <plugin.h> 28#include "plugin.h"
29 29
30/* 30/*
31hashw() -- hash an array of uint32_t into a 32-bit value 31hashw() -- hash an array of uint32_t into a 32-bit value
diff --git a/apps/plugins/lib/strncpy.c b/apps/plugins/lib/strncpy.c
index 7c1973ba66..f80e759969 100644
--- a/apps/plugins/lib/strncpy.c
+++ b/apps/plugins/lib/strncpy.c
@@ -39,6 +39,7 @@ QUICKREF
39 39
40#include <string.h> 40#include <string.h>
41#include <limits.h> 41#include <limits.h>
42#include "plugin.h"
42 43
43/*SUPPRESS 560*/ 44/*SUPPRESS 560*/
44/*SUPPRESS 530*/ 45/*SUPPRESS 530*/
diff --git a/apps/plugins/lua/gmtime.c b/apps/plugins/lua/gmtime.c
index f13c855de8..deb24e08c9 100644
--- a/apps/plugins/lua/gmtime.c
+++ b/apps/plugins/lua/gmtime.c
@@ -20,7 +20,7 @@ const short __spm[13] =
20 (31+28+31+30+31+30+31+31+30+31+30+31), 20 (31+28+31+30+31+30+31+31+30+31+30+31),
21 }; 21 };
22 22
23int __isleap(int year) { 23static inline int isleap(int year) {
24 /* every fourth year is a leap year except for century years that are 24 /* every fourth year is a leap year except for century years that are
25 * not divisible by 400. */ 25 * not divisible by 400. */
26/* return (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)); */ 26/* return (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)); */
@@ -36,7 +36,7 @@ struct tm *gmtime(const time_t *timep) {
36 work=*timep/(SPD); 36 work=*timep/(SPD);
37 r.tm_wday=(4+work)%7; 37 r.tm_wday=(4+work)%7;
38 for (i=1970; ; ++i) { 38 for (i=1970; ; ++i) {
39 register time_t k=__isleap(i)?366:365; 39 register time_t k=isleap(i)?366:365;
40 if (work>=k) 40 if (work>=k)
41 work-=k; 41 work-=k;
42 else 42 else
@@ -46,7 +46,7 @@ struct tm *gmtime(const time_t *timep) {
46 r.tm_yday=work; 46 r.tm_yday=work;
47 47
48 r.tm_mday=1; 48 r.tm_mday=1;
49 if (__isleap(i) && (work>58)) { 49 if (isleap(i) && (work>58)) {
50 if (work==59) r.tm_mday=2; /* 29.2. */ 50 if (work==59) r.tm_mday=2; /* 29.2. */
51 work-=1; 51 work-=1;
52 } 52 }
diff --git a/apps/plugins/midi/midiplay.c b/apps/plugins/midi/midiplay.c
index b225014fce..2c685f2e4b 100644
--- a/apps/plugins/midi/midiplay.c
+++ b/apps/plugins/midi/midiplay.c
@@ -450,6 +450,8 @@ static int midimain(const void * filename)
450enum plugin_status plugin_start(const void* parameter) 450enum plugin_status plugin_start(const void* parameter)
451{ 451{
452 int retval; 452 int retval;
453 PLUGINLIB_EXIT_INIT;
454
453 PLUGIN_IRAM_INIT(rb) 455 PLUGIN_IRAM_INIT(rb)
454 456
455 if (parameter == NULL) 457 if (parameter == NULL)
diff --git a/apps/plugins/midi/midiutil.c b/apps/plugins/midi/midiutil.c
index f1b6668be2..87e0f9d9a4 100644
--- a/apps/plugins/midi/midiutil.c
+++ b/apps/plugins/midi/midiutil.c
@@ -163,8 +163,3 @@ int printf(const char *fmt, ...)
163 return 1; 163 return 1;
164} 164}
165 165
166void exit(int code)
167{
168 code = code; /* Stub function, kill warning for now */
169}
170
diff --git a/apps/plugins/midi/midiutil.h b/apps/plugins/midi/midiutil.h
index f984e71aff..b1ed6569b7 100644
--- a/apps/plugins/midi/midiutil.h
+++ b/apps/plugins/midi/midiutil.h
@@ -21,6 +21,8 @@
21 21
22#define FRACTSIZE 12 22#define FRACTSIZE 12
23 23
24#include "lib/pluginlib_exit.h"
25
24#define BUF_SIZE 16384 /* 64 kB output buffers */ 26#define BUF_SIZE 16384 /* 64 kB output buffers */
25#define NBUF 2 27#define NBUF 2
26 28
@@ -145,7 +147,6 @@ int readFourBytes(int file);
145int readVarData(int file); 147int readVarData(int file);
146int eof(int fd); 148int eof(int fd);
147unsigned char * readData(int file, int len); 149unsigned char * readData(int file, int len);
148void exit(int code);
149 150
150#define malloc(n) my_malloc(n) 151#define malloc(n) my_malloc(n)
151void * my_malloc(int size); 152void * my_malloc(int size);
diff --git a/apps/plugins/mpegplayer/disk_buf.c b/apps/plugins/mpegplayer/disk_buf.c
index 4f37bfa5bf..59d4816fb4 100644
--- a/apps/plugins/mpegplayer/disk_buf.c
+++ b/apps/plugins/mpegplayer/disk_buf.c
@@ -855,7 +855,7 @@ bool disk_buf_init(void)
855 disk_buf.pos_last = 0; 855 disk_buf.pos_last = 0;
856 disk_buf.low_wm = DISK_BUF_LOW_WATERMARK; 856 disk_buf.low_wm = DISK_BUF_LOW_WATERMARK;
857 857
858 disk_buf.start = mpeg_malloc_all(&disk_buf.size, MPEG_ALLOC_DISKBUF); 858 disk_buf.start = mpeg_malloc_all((size_t*)&disk_buf.size, MPEG_ALLOC_DISKBUF);
859 if (disk_buf.start == NULL) 859 if (disk_buf.start == NULL)
860 return false; 860 return false;
861 861
diff --git a/apps/plugins/random_folder_advance_config.c b/apps/plugins/random_folder_advance_config.c
index d5e7a10cdc..f7bb790dc1 100644
--- a/apps/plugins/random_folder_advance_config.c
+++ b/apps/plugins/random_folder_advance_config.c
@@ -23,7 +23,7 @@
23 23
24PLUGIN_HEADER 24PLUGIN_HEADER
25 25
26static bool abort; 26static bool cancel;
27static int fd; 27static int fd;
28static int dirs_count; 28static int dirs_count;
29static int lasttick; 29static int lasttick;
@@ -70,7 +70,7 @@ void traversedir(char* location, char* name)
70 if (dir) { 70 if (dir) {
71 entry = rb->readdir(dir); 71 entry = rb->readdir(dir);
72 while (entry) { 72 while (entry) {
73 if (abort) 73 if (cancel)
74 break; 74 break;
75 /* Skip .. and . */ 75 /* Skip .. and . */
76 if (entry->d_name[0] == '.') 76 if (entry->d_name[0] == '.')
@@ -113,7 +113,7 @@ void traversedir(char* location, char* name)
113 lasttick = *rb->current_tick; 113 lasttick = *rb->current_tick;
114 if (rb->action_userabort(TIMEOUT_NOBLOCK)) 114 if (rb->action_userabort(TIMEOUT_NOBLOCK))
115 { 115 {
116 abort = true; 116 cancel = true;
117 break; 117 break;
118 } 118 }
119 } 119 }
@@ -213,7 +213,7 @@ bool custom_dir(void)
213void generate(void) 213void generate(void)
214{ 214{
215 dirs_count = 0; 215 dirs_count = 0;
216 abort = false; 216 cancel = false;
217 fd = rb->open(RFA_FILE,O_CREAT|O_WRONLY, 0666); 217 fd = rb->open(RFA_FILE,O_CREAT|O_WRONLY, 0666);
218 rb->write(fd,&dirs_count,sizeof(int)); 218 rb->write(fd,&dirs_count,sizeof(int));
219 if (fd < 0) 219 if (fd < 0)
@@ -621,7 +621,7 @@ enum plugin_status plugin_start(const void* parameter)
621{ 621{
622 (void)parameter; 622 (void)parameter;
623 623
624 abort = false; 624 cancel = false;
625 625
626 return main_menu(); 626 return main_menu();
627} 627}
diff --git a/apps/plugins/rockboy/menu.c b/apps/plugins/rockboy/menu.c
index 2f6c3102ff..e081a81d18 100644
--- a/apps/plugins/rockboy/menu.c
+++ b/apps/plugins/rockboy/menu.c
@@ -158,7 +158,7 @@ static void build_slot_path(char *buf, size_t bufsiz, size_t slot_id) {
158 munge_name(name_buf, strlen(name_buf)); 158 munge_name(name_buf, strlen(name_buf));
159 159
160 /* glom the whole mess together */ 160 /* glom the whole mess together */
161 snprintf(buf, bufsiz, "%s/%s-%ld.rbs", STATE_DIR, name_buf, slot_id + 1); 161 snprintf(buf, bufsiz, "%s/%s-%zud.rbs", STATE_DIR, name_buf, slot_id + 1);
162} 162}
163 163
164/* 164/*
@@ -253,17 +253,17 @@ static void slot_info(char *info_buf, size_t info_bufsiz, size_t slot_id) {
253 if (read(fd, buf, 20) > 0) 253 if (read(fd, buf, 20) > 0)
254 { 254 {
255 buf[20] = '\0'; 255 buf[20] = '\0';
256 snprintf(info_buf, info_bufsiz, "%ld. %s", slot_id + 1, buf); 256 snprintf(info_buf, info_bufsiz, "%zud. %s", slot_id + 1, buf);
257 } 257 }
258 else 258 else
259 snprintf(info_buf, info_bufsiz, "%ld. ERROR", slot_id + 1); 259 snprintf(info_buf, info_bufsiz, "%zud. ERROR", slot_id + 1);
260 260
261 close(fd); 261 close(fd);
262 } 262 }
263 else 263 else
264 { 264 {
265 /* if we couldn't open the file, then the slot is empty */ 265 /* if we couldn't open the file, then the slot is empty */
266 snprintf(info_buf, info_bufsiz, "%ld. %s", slot_id + 1, "<Empty>"); 266 snprintf(info_buf, info_bufsiz, "%zu. %s", slot_id + 1, "<Empty>");
267 } 267 }
268} 268}
269 269
diff --git a/apps/plugins/rockboy/rockboy.make b/apps/plugins/rockboy/rockboy.make
index ca0ed17a0a..81e9a1f798 100644
--- a/apps/plugins/rockboy/rockboy.make
+++ b/apps/plugins/rockboy/rockboy.make
@@ -11,7 +11,7 @@ ROCKBOY_SRCDIR = $(APPSDIR)/plugins/rockboy
11ROCKBOY_OBJDIR = $(BUILDDIR)/apps/plugins/rockboy 11ROCKBOY_OBJDIR = $(BUILDDIR)/apps/plugins/rockboy
12 12
13ROCKBOY_SRC := $(call preprocess, $(ROCKBOY_SRCDIR)/SOURCES) 13ROCKBOY_SRC := $(call preprocess, $(ROCKBOY_SRCDIR)/SOURCES)
14ROCKBOY_SRC += $(ROOTDIR)/firmware/common/sscanf.c 14ROCKBOY_SRC += $(ROOTDIR)/firmware/libc/sscanf.c
15ROCKBOY_OBJ := $(call c2obj, $(ROCKBOY_SRC)) 15ROCKBOY_OBJ := $(call c2obj, $(ROCKBOY_SRC))
16 16
17OTHER_SRC += $(ROCKBOY_SRC) 17OTHER_SRC += $(ROCKBOY_SRC)
diff --git a/apps/plugins/rockboy/rtc.c b/apps/plugins/rockboy/rtc.c
index 6f33bc4f9d..248ebc0714 100644
--- a/apps/plugins/rockboy/rtc.c
+++ b/apps/plugins/rockboy/rtc.c
@@ -7,7 +7,6 @@
7#include "defs.h" 7#include "defs.h"
8#include "mem.h" 8#include "mem.h"
9#include "rtc-gb.h" 9#include "rtc-gb.h"
10#include "sscanf.h"
11 10
12struct rtc rtc; 11struct rtc rtc;
13 12
diff --git a/apps/plugins/search.c b/apps/plugins/search.c
index ba16b8821b..7edb7e229a 100644
--- a/apps/plugins/search.c
+++ b/apps/plugins/search.c
@@ -20,7 +20,7 @@
20 * 20 *
21 ****************************************************************************/ 21 ****************************************************************************/
22#include "plugin.h" 22#include "plugin.h"
23#include "ctype.h" 23#include <ctype.h>
24 24
25PLUGIN_HEADER 25PLUGIN_HEADER
26 26
diff --git a/apps/plugins/shortcuts/shortcuts.h b/apps/plugins/shortcuts/shortcuts.h
index bfe3540c4d..3d6c421c5a 100644
--- a/apps/plugins/shortcuts/shortcuts.h
+++ b/apps/plugins/shortcuts/shortcuts.h
@@ -51,7 +51,7 @@ typedef struct sc_file_s
51 51
52 52
53extern void *memory_buf; 53extern void *memory_buf;
54extern long memory_bufsize; 54extern size_t memory_bufsize;
55 55
56 56
57extern sc_file_t sc_file; 57extern sc_file_t sc_file;
diff --git a/apps/plugins/shortcuts/shortcuts_common.c b/apps/plugins/shortcuts/shortcuts_common.c
index dee1657afc..da212a55a3 100644
--- a/apps/plugins/shortcuts/shortcuts_common.c
+++ b/apps/plugins/shortcuts/shortcuts_common.c
@@ -35,7 +35,7 @@
35 35
36/* Memory (will be used for entries) */ 36/* Memory (will be used for entries) */
37void *memory_buf; 37void *memory_buf;
38long memory_bufsize; /* Size of memory_buf in bytes */ 38size_t memory_bufsize; /* Size of memory_buf in bytes */
39 39
40 40
41/* The file we're processing */ 41/* The file we're processing */
diff --git a/apps/plugins/stats.c b/apps/plugins/stats.c
index eaa1055a73..3420579881 100644
--- a/apps/plugins/stats.c
+++ b/apps/plugins/stats.c
@@ -24,7 +24,7 @@ PLUGIN_HEADER
24 24
25static int files, dirs, musicfiles, largestdir; 25static int files, dirs, musicfiles, largestdir;
26static int lasttick; 26static int lasttick;
27static bool abort; 27static bool cancel;
28 28
29#if CONFIG_KEYPAD == PLAYER_PAD 29#if CONFIG_KEYPAD == PLAYER_PAD
30#define STATS_STOP BUTTON_STOP 30#define STATS_STOP BUTTON_STOP
@@ -173,7 +173,7 @@ void traversedir(char* location, char* name)
173 if (dir) { 173 if (dir) {
174 entry = rb->readdir(dir); 174 entry = rb->readdir(dir);
175 while (entry) { 175 while (entry) {
176 if (abort) 176 if (cancel)
177 break; 177 break;
178 /* Skip .. and . */ 178 /* Skip .. and . */
179 if (rb->strcmp(entry->d_name, ".") && rb->strcmp(entry->d_name, "..")) 179 if (rb->strcmp(entry->d_name, ".") && rb->strcmp(entry->d_name, ".."))
@@ -206,7 +206,7 @@ void traversedir(char* location, char* name)
206 || button == STATS_STOP_REMOTE 206 || button == STATS_STOP_REMOTE
207#endif 207#endif
208 ) { 208 ) {
209 abort = true; 209 cancel = true;
210 break; 210 break;
211 } 211 }
212 } 212 }
@@ -229,14 +229,14 @@ enum plugin_status plugin_start(const void* parameter)
229 dirs = 0; 229 dirs = 0;
230 musicfiles = 0; 230 musicfiles = 0;
231 largestdir = 0; 231 largestdir = 0;
232 abort = false; 232 cancel = false;
233 233
234 rb->splash(HZ, "Counting..."); 234 rb->splash(HZ, "Counting...");
235 update_screen(); 235 update_screen();
236 lasttick = *rb->current_tick; 236 lasttick = *rb->current_tick;
237 237
238 traversedir("", ""); 238 traversedir("", "");
239 if (abort) { 239 if (cancel) {
240 rb->splash(HZ, "Aborted"); 240 rb->splash(HZ, "Aborted");
241 return PLUGIN_OK; 241 return PLUGIN_OK;
242 } 242 }
diff --git a/apps/plugins/wav2wv.c b/apps/plugins/wav2wv.c
index 03900884f9..3211203db9 100644
--- a/apps/plugins/wav2wv.c
+++ b/apps/plugins/wav2wv.c
@@ -97,8 +97,8 @@ static int32_t temp_buffer [TEMP_SAMPLES] IDATA_ATTR;
97static int wav2wv(const char *infile) 97static int wav2wv(const char *infile)
98{ 98{
99 int in_fd, out_fd, num_chans, error = false, last_buttons; 99 int in_fd, out_fd, num_chans, error = false, last_buttons;
100 unsigned int32_t total_bytes_read = 0, total_bytes_written = 0; 100 uint32_t total_bytes_read = 0, total_bytes_written = 0;
101 unsigned int32_t total_samples, samples_remaining; 101 uint32_t total_samples, samples_remaining;
102 int32_t *input_buffer = (int32_t *) audiobuf; 102 int32_t *input_buffer = (int32_t *) audiobuf;
103 unsigned char *output_buffer = (unsigned char *)(audiobuf + 0x100000); 103 unsigned char *output_buffer = (unsigned char *)(audiobuf + 0x100000);
104 char outfile[MAX_PATH]; 104 char outfile[MAX_PATH];
@@ -180,7 +180,7 @@ static int wav2wv(const char *infile)
180 wvupdate (start_tick, native_header.SampleRate, total_samples, 0, 0, 0); 180 wvupdate (start_tick, native_header.SampleRate, total_samples, 0, 0, 0);
181 181
182 for (samples_remaining = total_samples; samples_remaining;) { 182 for (samples_remaining = total_samples; samples_remaining;) {
183 unsigned int32_t samples_count, samples_to_pack, bytes_count; 183 uint32_t samples_count, samples_to_pack, bytes_count;
184 int cnt, buttons; 184 int cnt, buttons;
185 int32_t value, *lp; 185 int32_t value, *lp;
186 signed char *cp; 186 signed char *cp;
@@ -204,7 +204,7 @@ static int wav2wv(const char *infile)
204 cp = (signed char *) input_buffer; 204 cp = (signed char *) input_buffer;
205 205
206 while (samples_to_pack) { 206 while (samples_to_pack) {
207 unsigned int32_t samples_this_pass = TEMP_SAMPLES / num_chans; 207 uint32_t samples_this_pass = TEMP_SAMPLES / num_chans;
208 208
209 if (samples_this_pass > samples_to_pack) 209 if (samples_this_pass > samples_to_pack)
210 samples_this_pass = samples_to_pack; 210 samples_this_pass = samples_to_pack;
diff --git a/apps/plugins/zxbox/helpers.h b/apps/plugins/zxbox/helpers.h
index ba8607d5cb..c8cb9c1554 100644
--- a/apps/plugins/zxbox/helpers.h
+++ b/apps/plugins/zxbox/helpers.h
@@ -7,9 +7,12 @@ extern off_t my_ftell(int);
7extern void *my_malloc(size_t size); 7extern void *my_malloc(size_t size);
8 8
9 9
10#undef getc
10#define getc my_getc 11#define getc my_getc
11#define malloc my_malloc 12#undef putc
12#define ftell my_ftell
13#define putc my_putc 13#define putc my_putc
14#undef ftell
15#define ftell my_ftell
16#define malloc my_malloc
14 17
15#endif /* HELPERS_H */ 18#endif /* HELPERS_H */
diff --git a/apps/plugins/zxbox/snapshot.c b/apps/plugins/zxbox/snapshot.c
index 0b80b64497..468f46667e 100644
--- a/apps/plugins/zxbox/snapshot.c
+++ b/apps/plugins/zxbox/snapshot.c
@@ -18,8 +18,9 @@
18 * 18 *
19 */ 19 */
20 20
21#include <stdlib.h>
22#include <string.h> /* size_t */
21#include "zxmisc.h" 23#include "zxmisc.h"
22#include "helpers.h"
23#include "spperif.h" 24#include "spperif.h"
24#include "z80.h" 25#include "z80.h"
25 26
@@ -29,9 +30,8 @@
29 30
30#include "spconf.h" 31#include "spconf.h"
31 32
32#include <stdio.h> 33/* include this at last to avoid clashes with stdio functions */
33#include <stdlib.h> 34#include "helpers.h"
34#include <sys/types.h>
35 35
36#define COMPRESS_SAVE 1 36#define COMPRESS_SAVE 1
37 37
diff --git a/apps/plugins/zxbox/spconf.c b/apps/plugins/zxbox/spconf.c
index 728f78638c..0daabc7d77 100644
--- a/apps/plugins/zxbox/spconf.c
+++ b/apps/plugins/zxbox/spconf.c
@@ -17,6 +17,10 @@
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 * 18 *
19 */ 19 */
20
21#include <stdio.h>
22#include <string.h>
23#include <ctype.h>
20#include "zxmisc.h" 24#include "zxmisc.h"
21#include "spconf_p.h" 25#include "spconf_p.h"
22#include "interf.h" 26#include "interf.h"
@@ -26,11 +30,7 @@
26#include "snapshot.h" /* for SN_Z80 and SN_SNA */ 30#include "snapshot.h" /* for SN_Z80 and SN_SNA */
27#include "tapefile.h" /* for TAP_TAP and TAP_TZX */ 31#include "tapefile.h" /* for TAP_TAP and TAP_TZX */
28#include "zxconfig.h" 32#include "zxconfig.h"
29#include "stdio.h"
30#include "string.h"
31#include "sys/types.h"
32#include "helpers.h" 33#include "helpers.h"
33#include "ctype.h"
34 34
35 35
36extern const char *spcf_keynames_ascii[]; 36extern const char *spcf_keynames_ascii[];
diff --git a/apps/plugins/zxbox/sptape.c b/apps/plugins/zxbox/sptape.c
index 21f962ea28..80921a0afd 100644
--- a/apps/plugins/zxbox/sptape.c
+++ b/apps/plugins/zxbox/sptape.c
@@ -31,7 +31,6 @@
31#include <stdlib.h> 31#include <stdlib.h>
32#include <string.h> 32#include <string.h>
33#include <errno.h> 33#include <errno.h>
34#include <sys/types.h>
35 34
36#define MAXLINELEN 256 35#define MAXLINELEN 256
37 36
diff --git a/apps/plugins/zxbox/tapefile.c b/apps/plugins/zxbox/tapefile.c
index 0e262aa0f7..92f4ea69f6 100644
--- a/apps/plugins/zxbox/tapefile.c
+++ b/apps/plugins/zxbox/tapefile.c
@@ -29,7 +29,7 @@
29#include <stdlib.h> 29#include <stdlib.h>
30#include <string.h> 30#include <string.h>
31#include <errno.h> 31#include <errno.h>
32#include <sys/types.h> 32#include "inttypes.h"
33#include "zxconfig.h" 33#include "zxconfig.h"
34#include "helpers.h" 34#include "helpers.h"
35#define max(x, y) ((x) > (y) ? (x) : (y)) 35#define max(x, y) ((x) > (y) ? (x) : (y))
diff --git a/apps/plugins/zxbox/zxmisc.h b/apps/plugins/zxbox/zxmisc.h
index 4ad25a0604..904af24e3d 100644
--- a/apps/plugins/zxbox/zxmisc.h
+++ b/apps/plugins/zxbox/zxmisc.h
@@ -21,7 +21,7 @@
21#ifndef ZXMISC_H 21#ifndef ZXMISC_H
22#define ZXMISC_H 22#define ZXMISC_H
23 23
24#include <sys/types.h> 24#include <string.h> /* size_t */
25 25
26extern char *get_base_name(char *fname); 26extern char *get_base_name(char *fname);
27extern int check_ext(const char *filename, const char *ext); 27extern int check_ext(const char *filename, const char *ext);
diff --git a/apps/recorder/albumart.c b/apps/recorder/albumart.c
index be787538a3..5eca713542 100644
--- a/apps/recorder/albumart.c
+++ b/apps/recorder/albumart.c
@@ -19,8 +19,7 @@
19 * 19 *
20 ****************************************************************************/ 20 ****************************************************************************/
21 21
22#include <string.h> 22#include "string-extra.h"
23#include "sprintf.h"
24#include "system.h" 23#include "system.h"
25#include "albumart.h" 24#include "albumart.h"
26#include "metadata.h" 25#include "metadata.h"
diff --git a/apps/recorder/icons.c b/apps/recorder/icons.c
index 0b48c125d1..e6c3926759 100644
--- a/apps/recorder/icons.c
+++ b/apps/recorder/icons.c
@@ -22,7 +22,6 @@
22#include "lcd.h" 22#include "lcd.h"
23#include "font.h" 23#include "font.h"
24#include "kernel.h" 24#include "kernel.h"
25#include "sprintf.h"
26#include "rtc.h" 25#include "rtc.h"
27#include "powermgmt.h" 26#include "powermgmt.h"
28 27
diff --git a/apps/recorder/jpeg_load.c b/apps/recorder/jpeg_load.c
index f75176dae1..1af65fab6c 100644
--- a/apps/recorder/jpeg_load.c
+++ b/apps/recorder/jpeg_load.c
@@ -856,7 +856,7 @@ static const struct idct_entry idct_tbl[] = {
856/* JPEG decoder implementation */ 856/* JPEG decoder implementation */
857 857
858#ifdef JPEG_FROM_MEM 858#ifdef JPEG_FROM_MEM
859INLINE unsigned char *getc(struct jpeg* p_jpeg) 859INLINE unsigned char *jpeg_getc(struct jpeg* p_jpeg)
860{ 860{
861 if (LIKELY(p_jpeg->len)) 861 if (LIKELY(p_jpeg->len))
862 { 862 {
@@ -880,7 +880,7 @@ INLINE bool skip_bytes(struct jpeg* p_jpeg, int count)
880 } 880 }
881} 881}
882 882
883INLINE void putc(struct jpeg* p_jpeg) 883INLINE void jpeg_putc(struct jpeg* p_jpeg)
884{ 884{
885 p_jpeg->len++; 885 p_jpeg->len++;
886 p_jpeg->data--; 886 p_jpeg->data--;
@@ -892,7 +892,7 @@ INLINE void fill_buf(struct jpeg* p_jpeg)
892 p_jpeg->buf_index = 0; 892 p_jpeg->buf_index = 0;
893} 893}
894 894
895static unsigned char *getc(struct jpeg* p_jpeg) 895static unsigned char *jpeg_getc(struct jpeg* p_jpeg)
896{ 896{
897 if (UNLIKELY(p_jpeg->buf_left < 1)) 897 if (UNLIKELY(p_jpeg->buf_left < 1))
898 fill_buf(p_jpeg); 898 fill_buf(p_jpeg);
@@ -917,7 +917,7 @@ static bool skip_bytes(struct jpeg* p_jpeg, int count)
917 return p_jpeg->buf_left >= 0 || skip_bytes_seek(p_jpeg); 917 return p_jpeg->buf_left >= 0 || skip_bytes_seek(p_jpeg);
918} 918}
919 919
920static void putc(struct jpeg* p_jpeg) 920static void jpeg_putc(struct jpeg* p_jpeg)
921{ 921{
922 p_jpeg->buf_left++; 922 p_jpeg->buf_left++;
923 p_jpeg->buf_index--; 923 p_jpeg->buf_index--;
@@ -933,14 +933,14 @@ do {\
933#define e_getc(jpeg, code) \ 933#define e_getc(jpeg, code) \
934({ \ 934({ \
935 unsigned char *c; \ 935 unsigned char *c; \
936 if (UNLIKELY(!(c = getc(jpeg)))) \ 936 if (UNLIKELY(!(c = jpeg_getc(jpeg)))) \
937 return (code); \ 937 return (code); \
938 *c; \ 938 *c; \
939}) 939})
940 940
941#define d_getc(jpeg, def) \ 941#define d_getc(jpeg, def) \
942({ \ 942({ \
943 unsigned char *cp = getc(jpeg); \ 943 unsigned char *cp = jpeg_getc(jpeg); \
944 unsigned char c = LIKELY(cp) ? *cp : (def); \ 944 unsigned char c = LIKELY(cp) ? *cp : (def); \
945 c; \ 945 c; \
946}) 946})
@@ -958,7 +958,7 @@ static int process_markers(struct jpeg* p_jpeg)
958 if (c != 0xFF) /* no marker? */ 958 if (c != 0xFF) /* no marker? */
959 { 959 {
960 JDEBUGF("Non-marker data\n"); 960 JDEBUGF("Non-marker data\n");
961 putc(p_jpeg); 961 jpeg_putc(p_jpeg);
962 break; /* exit marker processing */ 962 break; /* exit marker processing */
963 } 963 }
964 964
@@ -969,7 +969,7 @@ static int process_markers(struct jpeg* p_jpeg)
969 case 0xFF: /* Fill byte */ 969 case 0xFF: /* Fill byte */
970 ret |= FILL_FF; 970 ret |= FILL_FF;
971 case 0x00: /* Zero stuffed byte - entropy data */ 971 case 0x00: /* Zero stuffed byte - entropy data */
972 putc(p_jpeg); 972 jpeg_putc(p_jpeg);
973 continue; 973 continue;
974 974
975 case 0xC0: /* SOF Huff - Baseline DCT */ 975 case 0xC0: /* SOF Huff - Baseline DCT */
@@ -1669,7 +1669,7 @@ static void search_restart(struct jpeg *p_jpeg)
1669 return; 1669 return;
1670 } 1670 }
1671 else 1671 else
1672 putc(p_jpeg); 1672 jpeg_putc(p_jpeg);
1673 } 1673 }
1674 } 1674 }
1675} 1675}
diff --git a/apps/recorder/keyboard.c b/apps/recorder/keyboard.c
index 3df3142897..f8b390d932 100644
--- a/apps/recorder/keyboard.c
+++ b/apps/recorder/keyboard.c
@@ -20,7 +20,7 @@
20 ****************************************************************************/ 20 ****************************************************************************/
21#include "kernel.h" 21#include "kernel.h"
22#include "system.h" 22#include "system.h"
23#include <string.h> 23#include "string-extra.h"
24#include "font.h" 24#include "font.h"
25#include "screens.h" 25#include "screens.h"
26#include "talk.h" 26#include "talk.h"
diff --git a/apps/recorder/peakmeter.c b/apps/recorder/peakmeter.c
index 8f32a837a7..154f605898 100644
--- a/apps/recorder/peakmeter.c
+++ b/apps/recorder/peakmeter.c
@@ -29,7 +29,6 @@
29#include "storage.h" 29#include "storage.h"
30#include "lcd.h" 30#include "lcd.h"
31#include "scrollbar.h" 31#include "scrollbar.h"
32#include "sprintf.h"
33#include "button.h" 32#include "button.h"
34#include "system.h" 33#include "system.h"
35#include "font.h" 34#include "font.h"
diff --git a/apps/recorder/radio.c b/apps/recorder/radio.c
index 7cf91d62f7..7761f248ca 100644
--- a/apps/recorder/radio.c
+++ b/apps/recorder/radio.c
@@ -23,7 +23,6 @@
23#include <stdio.h> 23#include <stdio.h>
24#include <stdbool.h> 24#include <stdbool.h>
25#include <stdlib.h> 25#include <stdlib.h>
26#include "sprintf.h"
27#include "mas.h" 26#include "mas.h"
28#include "settings.h" 27#include "settings.h"
29#include "button.h" 28#include "button.h"
@@ -35,7 +34,7 @@
35#include "file.h" 34#include "file.h"
36#include "general.h" 35#include "general.h"
37#include "errno.h" 36#include "errno.h"
38#include "string.h" 37#include "string-extra.h"
39#include "system.h" 38#include "system.h"
40#include "radio.h" 39#include "radio.h"
41#include "menu.h" 40#include "menu.h"
diff --git a/apps/recorder/recording.c b/apps/recorder/recording.c
index fc527923db..0f1ff30cf5 100644
--- a/apps/recorder/recording.c
+++ b/apps/recorder/recording.c
@@ -1762,7 +1762,7 @@ bool recording_screen(bool no_source)
1762 draw attention */ 1762 draw attention */
1763 /* Don't use language string unless agreed upon to make this 1763 /* Don't use language string unless agreed upon to make this
1764 method permanent - could do something in the statusbar */ 1764 method permanent - could do something in the statusbar */
1765 snprintf(buf, sizeof(buf), "Warning: %08X", 1765 snprintf(buf, sizeof(buf), "Warning: %08lX",
1766 pcm_rec_get_warnings()); 1766 pcm_rec_get_warnings());
1767 } 1767 }
1768 else 1768 else
@@ -1771,7 +1771,7 @@ bool recording_screen(bool no_source)
1771 (global_settings.rec_split_method)) 1771 (global_settings.rec_split_method))
1772 { 1772 {
1773 dmb = dsize/1024/1024; 1773 dmb = dsize/1024/1024;
1774 snprintf(buf, sizeof(buf), "%s %dMB", 1774 snprintf(buf, sizeof(buf), "%s %luMB",
1775 str(LANG_SPLIT_SIZE), dmb); 1775 str(LANG_SPLIT_SIZE), dmb);
1776 } 1776 }
1777 else 1777 else
diff --git a/apps/replaygain.c b/apps/replaygain.c
index 6ece1104b4..81f1a45ad7 100644
--- a/apps/replaygain.c
+++ b/apps/replaygain.c
@@ -20,13 +20,14 @@
20 ****************************************************************************/ 20 ****************************************************************************/
21 21
22#include <ctype.h> 22#include <ctype.h>
23#include <inttypes.h>
24#include <math.h> 23#include <math.h>
25#include <stdbool.h> 24#include <stdbool.h>
26#include <stdio.h> 25#include <stdio.h>
27#include <stdlib.h> 26#include <stdlib.h>
28#include <string.h> 27#include <inttypes.h>
29#include <system.h> 28#include "strlcpy.h"
29#include "strcasecmp.h"
30#include "system.h"
30#include "metadata.h" 31#include "metadata.h"
31#include "debug.h" 32#include "debug.h"
32#include "replaygain.h" 33#include "replaygain.h"
@@ -244,7 +245,7 @@ long parse_replaygain_int(bool album, long gain, long peak,
244 245
245 if (buffer != NULL) 246 if (buffer != NULL)
246 { 247 {
247 len = snprintf(buffer, length, "%d.%02d dB", gain / 512, 248 len = snprintf(buffer, length, "%ld.%02d dB", gain / 512,
248 ((abs(gain) & 0x01ff) * 100 + 256) / 512); 249 ((abs(gain) & 0x01ff) * 100 + 256) / 512);
249 len++; 250 len++;
250 } 251 }
diff --git a/apps/root_menu.c b/apps/root_menu.c
index 5124375490..e533c8ccc7 100644
--- a/apps/root_menu.c
+++ b/apps/root_menu.c
@@ -19,9 +19,9 @@
19 * 19 *
20 ****************************************************************************/ 20 ****************************************************************************/
21#include <stdio.h> 21#include <stdio.h>
22#include <string.h>
23#include <stdlib.h> 22#include <stdlib.h>
24#include <stdbool.h> 23#include <stdbool.h>
24#include "string-extra.h"
25#include "config.h" 25#include "config.h"
26#include "appevents.h" 26#include "appevents.h"
27#include "menu.h" 27#include "menu.h"
diff --git a/apps/screen_access.c b/apps/screen_access.c
index 871b1f8a60..df071020e5 100644
--- a/apps/screen_access.c
+++ b/apps/screen_access.c
@@ -19,17 +19,18 @@
19 * 19 *
20 ****************************************************************************/ 20 ****************************************************************************/
21 21
22#include <stdio.h>
23#include "config.h"
22#include <lcd.h> 24#include <lcd.h>
23#include <lcd-remote.h> 25#include <lcd-remote.h>
24#include <scroll_engine.h> 26#include <scroll_engine.h>
25#include "backlight.h"
26#include <font.h> 27#include <font.h>
27#include <button.h> 28#include <button.h>
28#include <sprintf.h>
29#include <settings.h> 29#include <settings.h>
30#include <kernel.h> 30#include <kernel.h>
31#include <icons.h> 31#include <icons.h>
32 32
33#include "backlight.h"
33#include "screen_access.h" 34#include "screen_access.h"
34#include "backdrop.h" 35#include "backdrop.h"
35 36
diff --git a/apps/screens.c b/apps/screens.c
index 1ac6633ccc..d988a521d0 100644
--- a/apps/screens.c
+++ b/apps/screens.c
@@ -34,7 +34,6 @@
34#include "settings.h" 34#include "settings.h"
35#include "status.h" 35#include "status.h"
36#include "playlist.h" 36#include "playlist.h"
37#include "sprintf.h"
38#include "kernel.h" 37#include "kernel.h"
39#include "power.h" 38#include "power.h"
40#include "system.h" 39#include "system.h"
diff --git a/apps/scrobbler.c b/apps/scrobbler.c
index 5ab13f3d15..401f5b93b6 100644
--- a/apps/scrobbler.c
+++ b/apps/scrobbler.c
@@ -23,8 +23,8 @@ Audioscrobbler spec at:
23http://www.audioscrobbler.net/wiki/Portable_Player_Logging 23http://www.audioscrobbler.net/wiki/Portable_Player_Logging
24*/ 24*/
25 25
26#include <stdio.h>
26#include "file.h" 27#include "file.h"
27#include "sprintf.h"
28#include "logf.h" 28#include "logf.h"
29#include "metadata.h" 29#include "metadata.h"
30#include "kernel.h" 30#include "kernel.h"
diff --git a/apps/settings.c b/apps/settings.c
index 690243b537..4901957263 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -33,7 +33,8 @@
33#include "backlight.h" 33#include "backlight.h"
34#include "audio.h" 34#include "audio.h"
35#include "talk.h" 35#include "talk.h"
36#include "string.h" 36#include "strlcpy.h"
37#include "strcasestr.h"
37#include "rtc.h" 38#include "rtc.h"
38#include "power.h" 39#include "power.h"
39#include "ata_idle_notify.h" 40#include "ata_idle_notify.h"
@@ -52,7 +53,6 @@
52#include "lang.h" 53#include "lang.h"
53#include "language.h" 54#include "language.h"
54#include "powermgmt.h" 55#include "powermgmt.h"
55#include "sprintf.h"
56#include "keyboard.h" 56#include "keyboard.h"
57#include "version.h" 57#include "version.h"
58#include "sound.h" 58#include "sound.h"
diff --git a/apps/settings_list.c b/apps/settings_list.c
index 044f9e8066..34d4fc52e0 100644
--- a/apps/settings_list.c
+++ b/apps/settings_list.c
@@ -21,7 +21,7 @@
21 21
22#include "config.h" 22#include "config.h"
23#include <stdbool.h> 23#include <stdbool.h>
24#include <string.h> 24#include "string-extra.h"
25#include "system.h" 25#include "system.h"
26#include "storage.h" 26#include "storage.h"
27#include "lang.h" 27#include "lang.h"
diff --git a/apps/tagcache.c b/apps/tagcache.c
index ab76fbadfe..29c00ae311 100644
--- a/apps/tagcache.c
+++ b/apps/tagcache.c
@@ -66,7 +66,7 @@
66#include "kernel.h" 66#include "kernel.h"
67#include "system.h" 67#include "system.h"
68#include "logf.h" 68#include "logf.h"
69#include "string.h" 69#include "string-extra.h"
70#include "usb.h" 70#include "usb.h"
71#include "metadata.h" 71#include "metadata.h"
72#include "tagcache.h" 72#include "tagcache.h"
@@ -1392,7 +1392,7 @@ static bool get_next(struct tagcache_search *tcs)
1392 1392
1393 if (TAGCACHE_IS_NUMERIC(tcs->type)) 1393 if (TAGCACHE_IS_NUMERIC(tcs->type))
1394 { 1394 {
1395 snprintf(buf, sizeof(buf), "%d", tcs->position); 1395 snprintf(buf, sizeof(buf), "%ld", tcs->position);
1396 tcs->result = buf; 1396 tcs->result = buf;
1397 tcs->result_len = strlen(buf) + 1; 1397 tcs->result_len = strlen(buf) + 1;
1398 return true; 1398 return true;
@@ -3490,7 +3490,7 @@ bool tagcache_create_changelog(struct tagcache_search *tcs)
3490 { 3490 {
3491 if (TAGCACHE_IS_NUMERIC(j)) 3491 if (TAGCACHE_IS_NUMERIC(j))
3492 { 3492 {
3493 snprintf(temp, sizeof temp, "%d", idx.tag_seek[j]); 3493 snprintf(temp, sizeof temp, "%d", (int)idx.tag_seek[j]);
3494 write_tag(clfd, tagcache_tag_to_str(j), temp); 3494 write_tag(clfd, tagcache_tag_to_str(j), temp);
3495 continue; 3495 continue;
3496 } 3496 }
diff --git a/apps/tagtree.c b/apps/tagtree.c
index ef9c9d2de7..3b13df06ab 100644
--- a/apps/tagtree.c
+++ b/apps/tagtree.c
@@ -27,8 +27,8 @@
27/*#define LOGF_ENABLE*/ 27/*#define LOGF_ENABLE*/
28 28
29#include <stdio.h> 29#include <stdio.h>
30#include <string.h>
31#include <stdlib.h> 30#include <stdlib.h>
31#include "string-extra.h"
32#include "config.h" 32#include "config.h"
33#include "system.h" 33#include "system.h"
34#include "kernel.h" 34#include "kernel.h"
diff --git a/apps/talk.c b/apps/talk.c
index 93e76fa69e..9f31645ca5 100644
--- a/apps/talk.c
+++ b/apps/talk.c
@@ -25,7 +25,7 @@
25 25
26#include <stdio.h> 26#include <stdio.h>
27#include <stddef.h> 27#include <stddef.h>
28#include <string.h> 28#include "string-extra.h"
29#include "file.h" 29#include "file.h"
30#include "buffer.h" 30#include "buffer.h"
31#include "system.h" 31#include "system.h"
diff --git a/apps/tree.c b/apps/tree.c
index db8f507146..8fbc793bda 100644
--- a/apps/tree.c
+++ b/apps/tree.c
@@ -19,9 +19,9 @@
19 * 19 *
20 ****************************************************************************/ 20 ****************************************************************************/
21#include <stdio.h> 21#include <stdio.h>
22#include <string.h>
23#include <stdlib.h> 22#include <stdlib.h>
24#include <stdbool.h> 23#include <stdbool.h>
24#include "string-extra.h"
25 25
26#include "applimits.h" 26#include "applimits.h"
27#include "dir.h" 27#include "dir.h"
@@ -32,7 +32,6 @@
32#include "kernel.h" 32#include "kernel.h"
33#include "usb.h" 33#include "usb.h"
34#include "tree.h" 34#include "tree.h"
35#include "sprintf.h"
36#include "audio.h" 35#include "audio.h"
37#include "playlist.h" 36#include "playlist.h"
38#include "menu.h" 37#include "menu.h"
diff --git a/apps/voice_thread.c b/apps/voice_thread.c
index 7b5bba20e7..076bd2ea1b 100644
--- a/apps/voice_thread.c
+++ b/apps/voice_thread.c
@@ -18,6 +18,7 @@
18 * KIND, either express or implied. 18 * KIND, either express or implied.
19 * 19 *
20 ****************************************************************************/ 20 ****************************************************************************/
21#include <sys/types.h>
21#include "system.h" 22#include "system.h"
22#include "thread.h" 23#include "thread.h"
23#include "voice_thread.h" 24#include "voice_thread.h"