From 50a6ca39ad4ed01922aa4f755f0ca579788226cf Mon Sep 17 00:00:00 2001 From: Thomas Martitz Date: Thu, 6 May 2010 21:04:40 +0000 Subject: Move c/h files implementing/defining standard library stuff into a new libc directory, also standard'ify some parts of the code base (almost entirely #include fixes). This is to a) to cleanup firmware/common and firmware/include a bit, but also b) for Rockbox as an application which should use the host system's c library and headers, separating makes it easy to exclude our files from the build. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25850 a1c6a512-1295-4272-9138-f99709370657 --- apps/alarm_menu.c | 1 - apps/apps.make | 5 +++-- apps/bookmark.c | 6 +++--- apps/buffering.c | 1 - apps/codecs.c | 3 ++- apps/codecs.h | 2 ++ apps/codecs/adx.c | 2 ++ apps/codecs/demac/demac.c | 1 - apps/codecs/demac/libdemac/parser.c | 2 +- apps/codecs/demac/wavwrite.c | 2 +- apps/codecs/lib/codeclib.h | 10 ++++++++-- apps/codecs/lib/tlsf/src/tlsf.c | 2 +- apps/codecs/lib/tlsf/src/tlsf.h | 2 +- apps/codecs/libatrac/main.c | 2 +- apps/codecs/libcook/main.c | 2 +- apps/codecs/libfaad/common.h | 2 +- apps/codecs/libmad/libmad.make | 2 +- apps/codecs/libpcm/adpcm_seek.h | 2 +- apps/codecs/libpcm/ima_adpcm_common.c | 16 +++++++-------- apps/codecs/libpcm/ima_adpcm_common.h | 1 - apps/codecs/libpcm/pcm_common.h | 2 +- apps/codecs/librm/rm.c | 2 +- apps/codecs/libtremor/config-tremor.h | 2 ++ apps/codecs/libtremor/ctype.c | 4 +++- apps/codecs/libwavpack/words.c | 6 +++--- apps/cuesheet.c | 1 - apps/debug_menu.c | 1 - apps/enc_config.c | 1 - apps/filetree.c | 1 - apps/filetypes.c | 1 - apps/gui/bitmap/list.c | 1 - apps/gui/charcell/list.c | 1 - apps/gui/list.c | 2 +- apps/gui/option_select.c | 3 +-- apps/gui/pitchscreen.c | 15 +++++++-------- apps/gui/skin_engine/skin_backdrops.c | 3 +-- apps/gui/skin_engine/skin_display.c | 2 +- apps/gui/skin_engine/skin_tokens.c | 14 +++++++------- apps/gui/statusbar.c | 2 +- apps/gui/usb_screen.c | 1 - apps/gui/viewport.c | 1 - apps/gui/wps.c | 1 - apps/main.c | 1 - apps/menus/eq_menu.c | 1 - apps/menus/recording_menu.c | 1 - apps/menus/settings_menu.c | 1 - apps/menus/time_menu.c | 30 ++++++++++++++--------------- apps/metadata.c | 3 +-- apps/metadata/metadata_common.c | 2 +- apps/metadata/metadata_common.h | 1 + apps/metadata/mp3.c | 4 ++-- apps/metadata/smaf.c | 2 +- apps/misc.c | 10 ++++------ apps/onplay.c | 1 - apps/player/keyboard.c | 1 - apps/playlist.c | 7 +++---- apps/playlist_catalog.c | 3 +-- apps/playlist_viewer.c | 1 - apps/plugin.c | 1 - apps/plugin.h | 9 ++++++++- apps/plugins/calculator.c | 3 +++ apps/plugins/doom/d_deh.c | 2 +- apps/plugins/doom/doom.make | 2 +- apps/plugins/doom/rockmacros.h | 20 ++++++++++++++++++- apps/plugins/frotz/frotz.c | 6 +++--- apps/plugins/frotz/frotzplugin.h | 9 ++++++--- apps/plugins/imageviewer/png/png.c | 2 +- apps/plugins/invadrox.c | 4 ++++ apps/plugins/lib/buflib.c | 4 ++-- apps/plugins/lib/jhash.h | 4 ++-- apps/plugins/lib/strncpy.c | 1 + apps/plugins/lua/gmtime.c | 6 +++--- apps/plugins/midi/midiplay.c | 2 ++ apps/plugins/midi/midiutil.c | 5 ----- apps/plugins/midi/midiutil.h | 3 ++- apps/plugins/mpegplayer/disk_buf.c | 2 +- apps/plugins/random_folder_advance_config.c | 10 +++++----- apps/plugins/rockboy/menu.c | 8 ++++---- apps/plugins/rockboy/rockboy.make | 2 +- apps/plugins/rockboy/rtc.c | 1 - apps/plugins/search.c | 2 +- apps/plugins/shortcuts/shortcuts.h | 2 +- apps/plugins/shortcuts/shortcuts_common.c | 2 +- apps/plugins/stats.c | 10 +++++----- apps/plugins/wav2wv.c | 8 ++++---- apps/plugins/zxbox/helpers.h | 7 +++++-- apps/plugins/zxbox/snapshot.c | 8 ++++---- apps/plugins/zxbox/spconf.c | 8 ++++---- apps/plugins/zxbox/sptape.c | 1 - apps/plugins/zxbox/tapefile.c | 2 +- apps/plugins/zxbox/zxmisc.h | 2 +- apps/recorder/albumart.c | 3 +-- apps/recorder/icons.c | 1 - apps/recorder/jpeg_load.c | 18 ++++++++--------- apps/recorder/keyboard.c | 2 +- apps/recorder/peakmeter.c | 1 - apps/recorder/radio.c | 3 +-- apps/recorder/recording.c | 4 ++-- apps/replaygain.c | 9 +++++---- apps/root_menu.c | 2 +- apps/screen_access.c | 5 +++-- apps/screens.c | 1 - apps/scrobbler.c | 2 +- apps/settings.c | 4 ++-- apps/settings_list.c | 2 +- apps/tagcache.c | 6 +++--- apps/tagtree.c | 2 +- apps/talk.c | 2 +- apps/tree.c | 3 +-- apps/voice_thread.c | 1 + 110 files changed, 225 insertions(+), 206 deletions(-) (limited to 'apps') 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 @@ #include "lcd.h" #include "action.h" #include "kernel.h" -#include "sprintf.h" #include #include "settings.h" #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) # to genlang and thus (translated) phrases can be used based on those names. # button.h is included for the HAS_BUTTON_HOLD define. # -# Kludge: depends on ctype.o only to depend on config-*.h ... +# Kludge: depends on config.o which only depends on config-*.h to have config.h +# changes trigger a genlang re-run # -features $(BUILDDIR)/apps/features $(BUILDDIR)/apps/genlang-features: $(APPSDIR)/features.txt $(BUILDDIR)/firmware/common/ctype.o +features $(BUILDDIR)/apps/features $(BUILDDIR)/apps/genlang-features: $(APPSDIR)/features.txt $(BUILDDIR)/firmware/common/config.o $(SILENT)mkdir -p $(BUILDDIR)/apps $(SILENT)mkdir -p $(BUILDDIR)/lang $(call PRINTS,PP $(%d;%d;%ld;%d;%ld;%d;%d;%d;%d;%s;%s", + ">%d;%d;%ld;%d;%ld;%d;%d;%ld;%ld;%s;%s", #else ">%d;%d;%ld;%d;%ld;%d;%d;%s;%s", #endif @@ -360,8 +360,8 @@ static char* create_bookmark() global_settings.playlist_shuffle, /* ...and their values should go here */ #if CONFIG_CODEC == SWCODEC - sound_get_pitch(), - dsp_get_timestretch(), + (long)sound_get_pitch(), + (long)dsp_get_timestretch(), #endif /* more mandatory tokens */ 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 @@ #include "kernel.h" #include "tree.h" #include "debug.h" -#include "sprintf.h" #include "settings.h" #include "codecs.h" #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 @@ #include #include #include +#include +#include "string-extra.h" #include "debug.h" #include "button.h" #include "dir.h" #include "file.h" #include "kernel.h" -#include "sprintf.h" #include "screens.h" #include "misc.h" #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 @@ #define MEM 2 #endif +#include <_ansi.h> #include #include +#include "strlcpy.h" #include "config.h" #include "system.h" #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 @@ * KIND, either express or implied. * ****************************************************************************/ + +#include #include "codeclib.h" #include "inttypes.h" #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. #include #include #include -#include #include #include #include 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 #ifndef ROCKBOX #include #include -#include +#include "inttypes.h" #include #include #include 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 #include #include #include -#include +#include "inttypes.h" #include #include #include 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 @@ #ifndef __CODECLIB_H__ #define __CODECLIB_H__ +#include +#include #include "config.h" #include "codecs.h" -#include #include "mdct.h" #include "fft.h" @@ -44,6 +45,7 @@ extern unsigned char* filebuf; /* The rest of the MP3 buffer #define calloc(x,y) codec_calloc(x,y) #define realloc(x,y) codec_realloc(x,y) #define free(x) codec_free(x) +#undef alloca #define alloca(x) __builtin_alloca(x) void* codec_malloc(size_t size); @@ -59,7 +61,11 @@ void *memmove(void *s1, const void *s2, size_t n); size_t strlen(const char *s); char *strcpy(char *dest, const char *src); char *strcat(char *dest, const char *src); -int strcmp(const char *, const char *); + +/* on some platforms strcmp() seems to be a tricky define which + * breaks if we write down strcmp's prototype */ +#undef strcmp +int strcmp(const char *s1, const char *s2); void qsort(void *base, size_t nmemb, size_t size, int(*compar)(const void *, const void *)); 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 @@ #endif #if defined(ROCKBOX) && defined(SIMULATOR) || !defined(ROCKBOX) -int printf(char*, ...); +int printf(const char* fmt, ...); #define PRINT_MSG(fmt, args...) printf(fmt, ## args) #define ERROR_MSG(fmt, args...) printf(fmt, ## args) #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 @@ #ifndef _TLSF_H_ #define _TLSF_H_ -#include +#include /* defines size_t */ extern size_t init_memory_pool(size_t, void *); extern 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 @@ #include #include -#include +#include #include #include #include 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 @@ * ****************************************************************************/ #include -#include +#include #include #include #include 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; #include #ifdef HAVE_SYS_TYPES_H -# include +# include "inttypes.h" #endif #ifdef HAVE_SYS_STAT_H # include 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 @@ # (one for codec, one for mpegplayer) # so a little trickery is necessary -MADFLAGS = $(CODECFLAGS) -UDEBUG -DNDEBUG -O2 -I$(APPSDIR)/codecs/libmad +MADFLAGS = $(CODECFLAGS) -UDEBUG -DNDEBUG -O2 -I$(APPSDIR)/codecs/libmad -DHAVE_LIMITS_H MPEGMADFLAGS = $(MADFLAGS) -DMPEGPLAYER # 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 @@ #ifndef CODEC_LIBPCM_ADPCM_SEEK_H #define CODEC_LIBPCM_ADPCM_SEEK_H -#include #include #include +#include struct adpcm_data { 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 = { }; static int32_t pcmdata[2]; -static int8_t index[2]; +static int8_t indices[2]; static int adpcm_data_size; static uint8_t step_mask; @@ -107,7 +107,7 @@ void set_decode_parameters(int channels, int32_t *init_pcmdata, int8_t *init_ind for (ch = 0; ch < channels; ch++) { pcmdata[ch] = init_pcmdata[ch]; - index[ch] = init_index[ch]; + indices[ch] = init_index[ch]; } } @@ -121,7 +121,7 @@ int16_t create_pcmdata(int ch, uint8_t nibble) { int check_bit = 1 << step_shift; int32_t delta = 0; - int16_t step = step_table[index[ch]]; + int16_t step = step_table[indices[ch]]; do { if (nibble & check_bit) @@ -136,8 +136,8 @@ int16_t create_pcmdata(int ch, uint8_t nibble) else pcmdata[ch] += delta; - index[ch] += use_index_table[nibble & step_mask]; - CLIP(index[ch], 0, 88); + indices[ch] += use_index_table[nibble & step_mask]; + CLIP(indices[ch], 0, 88); CLIP(pcmdata[ch], -32768, 32767); @@ -150,7 +150,7 @@ int16_t create_pcmdata(int ch, uint8_t nibble) int16_t create_pcmdata_size4(int ch, uint8_t nibble) { int32_t delta; - int16_t step = step_table[index[ch]]; + int16_t step = step_table[indices[ch]]; delta = (step >> 3); if (nibble & 4) delta += step; @@ -162,8 +162,8 @@ int16_t create_pcmdata_size4(int ch, uint8_t nibble) else pcmdata[ch] += delta; - index[ch] += use_index_table[nibble & 0x07]; - CLIP(index[ch], 0, 88); + indices[ch] += use_index_table[nibble & 0x07]; + CLIP(indices[ch], 0, 88); CLIP(pcmdata[ch], -32768, 32767); 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 @@ #ifndef CODEC_LIBPCM_IMA_ADPCM_COMMON_H #define CODEC_LIBPCM_IMA_ADPCM_COMMON_H -#include #include #include 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 @@ #ifndef CODEC_LIBPCM_PCM_COMMON_H #define CODEC_LIBPCM_PCM_COMMON_H -#include #include #include +#include /* decoded pcm sample depth (sample 28bit + sign 1bit) */ #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 @@ #ifdef TEST #include #include -#include +#include "inttypes.h" #include int 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 @@ #define _ARM_ASSEM_ #endif +#ifndef BYTE_ORDER #ifdef ROCKBOX_BIG_ENDIAN #define BIG_ENDIAN 1 #define LITTLE_ENDIAN 0 @@ -16,6 +17,7 @@ #define LITTLE_ENDIAN 1 #define BIG_ENDIAN 0 #endif +#endif #ifndef ICODE_ATTR_TREMOR_MDCT #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 @@ -#include "common/ctype.c" +#ifndef SIMULATOR +#include "libc/ctype.c" +#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) CLEAR (wps->w); } -static int mylog2 (unsigned int32_t avalue); +static int mylog2 (uint32_t avalue); // Read the median log2 values from the specifed metadata structure, convert // 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, if (sign) value = ~value; - if ((unsigned int32_t) value < GET_MED (0)) { + if ((uint32_t) value < GET_MED (0)) { ones_count = low = 0; high = GET_MED (0) - 1; DEC_MED0 (); @@ -709,7 +709,7 @@ void flush_word (struct words_data *w, Bitstream *bs) // This function returns the log2 for the specified 32-bit unsigned value. // The maximum value allowed is about 0xff800000 and returns 8447. -static int mylog2 (unsigned int32_t avalue) +static int mylog2 (uint32_t avalue) { int dbits; 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 @@ #include "audio.h" #include "kernel.h" #include "logf.h" -#include "sprintf.h" #include "misc.h" #include "screens.h" #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 @@ #include "menu.h" #include "debug_menu.h" #include "kernel.h" -#include "sprintf.h" #include "structec.h" #include "action.h" #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 @@ * ****************************************************************************/ #include -#include #include #include #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 @@ #include "screens.h" #include "plugin.h" #include "rolo.h" -#include "sprintf.h" #include "splash.h" #include "cuesheet.h" #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 @@ #include "string.h" #include -#include "sprintf.h" #include "settings.h" #include "debug.h" #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 @@ #include "lcd.h" #include "font.h" #include "button.h" -#include "sprintf.h" #include "string.h" #include "settings.h" #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 @@ #include "lcd.h" #include "font.h" #include "button.h" -#include "sprintf.h" #include "string.h" #include "settings.h" #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 @@ * ****************************************************************************/ +#include #include "config.h" #include "lcd.h" #include "font.h" #include "button.h" -#include "sprintf.h" #include "string.h" #include "settings.h" #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 @@ * ****************************************************************************/ #include -#include +#include "string-extra.h" #include "config.h" #include "option_select.h" -#include "sprintf.h" #include "kernel.h" #include "lang.h" #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 @@ #include #include #include -#include /* for ABS() */ +#include /* for abs() */ #include "config.h" -#include "sprintf.h" #include "action.h" #include "dsp.h" #include "sound.h" @@ -248,10 +247,10 @@ static void pitchscreen_draw(struct screen *display, int max_lines, /* Pitch:XXX.X% */ if(global_settings.pitch_mode_semitone) { - snprintf(buf, sizeof(buf), "%s: %s%ld.%02ld", str(LANG_PITCH), + snprintf(buf, sizeof(buf), "%s: %s%d.%02d", str(LANG_PITCH), semitone >= 0 ? "+" : "-", - ABS(semitone / PITCH_SPEED_PRECISION), - ABS((semitone % PITCH_SPEED_PRECISION) / + abs(semitone / PITCH_SPEED_PRECISION), + abs((semitone % PITCH_SPEED_PRECISION) / (PITCH_SPEED_PRECISION / 100)) ); } @@ -290,10 +289,10 @@ static void pitchscreen_draw(struct screen *display, int max_lines, { if(global_settings.pitch_mode_semitone) { - snprintf(buf, sizeof(buf), "%s%ld.%02ld", + snprintf(buf, sizeof(buf), "%s%d.%02d", semitone >= 0 ? "+" : "-", - ABS(semitone / PITCH_SPEED_PRECISION), - ABS((semitone % PITCH_SPEED_PRECISION) / + abs(semitone / PITCH_SPEED_PRECISION), + abs((semitone % PITCH_SPEED_PRECISION) / (PITCH_SPEED_PRECISION / 100)) ); } 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 @@ #include "config.h" #include -#include #include - +#include "string-extra.h" #include "settings.h" #include "skin_buffer.h" #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 @@ ****************************************************************************/ #include "config.h" #include -#include +#include "string-extra.h" #include "misc.h" #include "font.h" #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 @@ ****************************************************************************/ #include "font.h" #include -#include +#include "string-extra.h" #include #include "action.h" #include "system.h" @@ -247,7 +247,7 @@ const char *get_id3_token(struct wps_token *token, struct mp3entry *id3, { *intval = limit * elapsed / length + 1; } - snprintf(buf, buf_size, "%d", 100 * elapsed / length); + snprintf(buf, buf_size, "%lu", 100 * elapsed / length); return buf; @@ -269,7 +269,7 @@ const char *get_id3_token(struct wps_token *token, struct mp3entry *id3, if ((id3->frequency % 1000) < 100) snprintf(buf, buf_size, "%ld", id3->frequency / 1000); else - snprintf(buf, buf_size, "%ld.%d", + snprintf(buf, buf_size, "%ld.%lu", id3->frequency / 1000, (id3->frequency % 1000) / 100); return buf; @@ -302,12 +302,12 @@ const char *get_id3_token(struct wps_token *token, struct mp3entry *id3, case WPS_TOKEN_DATABASE_RATING: if (intval) *intval = id3->rating + 1; - snprintf(buf, buf_size, "%ld", id3->rating); + snprintf(buf, buf_size, "%d", id3->rating); return buf; case WPS_TOKEN_DATABASE_AUTOSCORE: if (intval) *intval = id3->score + 1; - snprintf(buf, buf_size, "%ld", id3->score); + snprintf(buf, buf_size, "%d", id3->score); return buf; #endif @@ -1064,7 +1064,7 @@ const char *get_token_value(struct gui_wps *gwps, break;) } } - snprintf(buf, buf_size, "%d.%1d", samprk/1000,samprk%1000); + snprintf(buf, buf_size, "%lu.%1lu", samprk/1000,samprk%1000); #else /* HWCODEC */ static const char * const freq_strings[] = @@ -1164,7 +1164,7 @@ const char *get_token_value(struct gui_wps *gwps, #endif *intval = global_settings.mp3_enc_config.bitrate+1; } - snprintf(buf, buf_size, "%d", global_settings.mp3_enc_config.bitrate+1); + snprintf(buf, buf_size, "%lu", global_settings.mp3_enc_config.bitrate+1); return buf; } 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 @@ * ****************************************************************************/ +#include #include "config.h" #include "font.h" #include "kernel.h" #include "string.h" /* for memcmp oO*/ -#include "sprintf.h" #include "sound.h" #include "settings.h" #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 @@ #include "usb_core.h" #ifdef USB_ENABLE_HID #include "usb_keymaps.h" -#include "sprintf.h" #endif #endif #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 @@ /* all below isn't needed for pc tools (i.e. checkwps/wps editor) * only viewport_parse_viewport() is */ #ifndef __PCTOOL__ -#include "sprintf.h" #include "string.h" #include "kernel.h" #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 @@ #include "action.h" #include "kernel.h" #include "filetypes.h" -#include "sprintf.h" #include "settings.h" #include "skin_engine/skin_engine.h" #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 @@ #include "status.h" #include "debug_menu.h" #include "version.h" -#include "sprintf.h" #include "font.h" #include "language.h" #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 @@ #include "icons.h" #include "font.h" #include "lang.h" -#include "sprintf.h" #include "talk.h" #include "misc.h" #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 @@ #include "scrollbar.h" #endif #include "lang.h" -#include "sprintf.h" #include "talk.h" #include "misc.h" #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 @@ #include "usb.h" #include "splash.h" #include "talk.h" -#include "sprintf.h" #include "powermgmt.h" #if CONFIG_CODEC == SWCODEC #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 @@ #include #include #include +#include #include "config.h" #include "string.h" -#include "sprintf.h" #include "lang.h" #include "action.h" #include "settings.h" @@ -201,7 +201,7 @@ static void draw_timedate(struct viewport *vp, struct screen *display) } -static struct viewport clock[NB_SCREENS], menu[NB_SCREENS]; +static struct viewport clock_vps[NB_SCREENS], menu[NB_SCREENS]; static bool menu_was_pressed; static int time_menu_callback(int action, const struct menu_item_ex *this_item) @@ -233,7 +233,7 @@ static int time_menu_callback(int action, { last_redraw = current_tick; FOR_NB_SCREENS(i) - draw_timedate(&clock[i], &screens[i]); + draw_timedate(&clock_vps[i], &screens[i]); } return action; } @@ -257,30 +257,30 @@ int time_screen(void* ignored) FOR_NB_SCREENS(i) { - viewport_set_defaults(&clock[i], i); + viewport_set_defaults(&clock_vps[i], i); #ifdef HAVE_BUTTONBAR if (global_settings.buttonbar) { - clock[i].height -= BUTTONBAR_HEIGHT; + clock_vps[i].height -= BUTTONBAR_HEIGHT; } #endif - nb_lines = viewport_get_nb_lines(&clock[i]); + nb_lines = viewport_get_nb_lines(&clock_vps[i]); - menu[i] = clock[i]; + menu[i] = clock_vps[i]; /* force time to be drawn centered */ - clock[i].flags |= VP_FLAG_ALIGN_CENTER; + clock_vps[i].flags |= VP_FLAG_ALIGN_CENTER; - font_h = font_get(clock[i].font)->height; + font_h = font_get(clock_vps[i].font)->height; nb_lines -= 2; /* at least 2 lines for menu */ if (nb_lines > 4) nb_lines = 4; if (nb_lines >= 2) - clock[i].height = nb_lines*font_h; - else /* disable the clock drawing */ - clock[i].height = 0; - menu[i].y += clock[i].height; - menu[i].height -= clock[i].height; - draw_timedate(&clock[i], &screens[i]); + clock_vps[i].height = nb_lines*font_h; + else /* disable the clock_vps drawing */ + clock_vps[i].height = 0; + menu[i].y += clock_vps[i].height; + menu[i].height -= clock_vps[i].height; + draw_timedate(&clock_vps[i], &screens[i]); } 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 @@ * ****************************************************************************/ #include -#include #include #include -#include +#include "string-extra.h" #include "debug.h" #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 @@ * ****************************************************************************/ #include -#include +#include "string-extra.h" #include #include #include 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 @@ * KIND, either express or implied. * ****************************************************************************/ +#include #include "metadata.h" #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 @@ #include #include -#include #include #include #include -#include +#include +#include "string-extra.h" #include "config.h" #include "file.h" #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 @@ * KIND, either express or implied. * ****************************************************************************/ -#include #include +#include "string-extra.h" #include "system.h" #include "metadata.h" #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 @@ ****************************************************************************/ #include #include -#include +#include +#include #include +#include "string-extra.h" #include "config.h" #include "misc.h" #include "lcd.h" #include "file.h" -#ifdef __PCTOOL__ -#include -#include -#else -#include "sprintf.h" +#ifndef __PCTOOL__ #include "lang.h" #include "dir.h" #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 @@ #include #include "debug.h" -#include "sprintf.h" #include "lcd.h" #include "dir.h" #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 @@ #include "kernel.h" #include "system.h" #include "version.h" -#include "sprintf.h" #include #include "settings.h" #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 @@ */ #include -#include -#include -#include +#include +#include +#include "string-extra.h" #include "playlist.h" #include "ata_idle_notify.h" #include "file.h" #include "action.h" #include "dir.h" -#include "sprintf.h" #include "debug.h" #include "audio.h" #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 @@ #include #include #include -#include +#include "string-extra.h" #include "action.h" #include "dir.h" #include "file.h" @@ -36,7 +36,6 @@ #include "playlist.h" #include "settings.h" #include "splash.h" -#include "sprintf.h" #include "tree.h" #include "yesno.h" #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 @@ * multi-screen support, rewrote a lot of code */ #include -#include #include "playlist.h" #include "audio.h" #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 @@ #include "plugin.h" #include #include -#include #include #include "debug.h" #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 @@ #endif #include +#include #include #include #include #include #include +#include "string-extra.h" char* strncpy(char *, const char *, size_t); void* plugin_get_buffer(size_t *buffer_size); @@ -111,6 +113,11 @@ void* plugin_get_buffer(size_t *buffer_size); #include "usbstack/usb_hid_usage_tables.h" #endif + +/* on some platforms strcmp() seems to be a tricky define which + * breaks if we write down strcmp's prototype */ +#undef strcmp + #ifdef PLUGIN #if defined(DEBUG) || defined(SIMULATOR) @@ -529,7 +536,7 @@ struct plugin_api { /* strings and memory */ int (*snprintf)(char *buf, size_t size, const char *fmt, ...) ATTRIBUTE_PRINTF(3, 4); - int (*vsnprintf)(char *buf, int size, const char *fmt, va_list ap); + int (*vsnprintf)(char *buf, size_t size, const char *fmt, va_list ap); char* (*strcpy)(char *dst, const char *src); size_t (*strlcpy)(char *dst, const char *src, size_t length); 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 #define X_5_POS (X_4_POS + REC_WIDTH) /* x5 = 110, column 111 left blank */ #define SIGN(x) ((x)<0?-1:1) +#ifndef ABS +#define ABS(a) (((a) < 0) ? -(a) : (a)) +#endif /* variable button definitions */ #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 @@ #include "d_think.h" #include "w_wad.h" -#include "sscanf.h" +#include /* sscanf */ #include "rockmacros.h" #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 ROCKS += $(DOOMBUILDDIR)/doom.rock DOOM_SRC := $(call preprocess, $(DOOMSRCDIR)/SOURCES) -DOOM_SRC += $(ROOTDIR)/firmware/common/sscanf.c +DOOM_SRC += $(ROOTDIR)/firmware/libc/sscanf.c DOOM_OBJ := $(call c2obj, $(DOOM_SRC)) # 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; int printf(const char *fmt, ...); int fileexists(const char * fname); char *my_strtok( char * s, const char * delim ); +#undef alloca #define alloca __builtin_alloca -#define fdprintf(...) rb->fdprintf(__VA_ARGS__) +#undef fdprintf +#define fdprintf(...) rb->fdprintf(__VA_ARGS__) +#undef vsnprintf #define vsnprintf(...) rb->vsnprintf(__VA_ARGS__) +#undef read_line #define read_line(a,b,c) rb->read_line((a),(b),(c)) #ifdef SIMULATOR @@ -52,19 +56,33 @@ int my_close(int id); #define filesize(a) rb->filesize((a)) #define read(a,b,c) rb->read((a),(b),(c)) #define write(a,b,c) rb->write((a),(b),(c)) +#undef strtok #define strtok(a,b) my_strtok((a),(b)) +#undef strcat #define strcat(a,b) rb->strcat((a),(b)) +#undef memset #define memset(a,b,c) rb->memset((a),(b),(c)) +#undef memmove #define memmove(a,b,c) rb->memmove((a),(b),(c)) +#undef memcmp #define memcmp(a,b,c) rb->memcmp((a),(b),(c)) +#undef memchr #define memchr(a,b,c) rb->memchr((a),(b),(c)) +#undef strcpy #define strcpy(a,b) rb->strcpy((a),(b)) +#undef strlen #define strlen(a) rb->strlen((a)) +#undef strcmp #define strcmp(a,b) rb->strcmp((a),(b)) +#undef strncmp #define strncmp(a,b,c) rb->strncmp((a),(b),(c)) +#undef strchr #define strchr(a,b) rb->strchr((a),(b)) +#undef strrchr #define strrchr(a,b) rb->strrchr((a),(b)) +#undef strcasecmp #define strcasecmp(a,b) rb->strcasecmp((a),(b)) +#undef strncasecmp #define strncasecmp(a,b,c) rb->strncasecmp((a),(b),(c)) #define srand(a) rb->srand((a)) #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) static unsigned char unget_buf; static int unget_file; -int ungetc(int c, int f) +int frotz_ungetc(int c, int f) { unget_file = f; unget_buf = c; return c; } -int fgetc(int f) +int frotz_fgetc(int f) { unsigned char cb; if (unget_file == f) @@ -305,7 +305,7 @@ int fgetc(int f) return cb; } -int fputc(int c, int f) +int frotz_fputc(int c, int f) { unsigned char cb = c; 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 @@ /* * we need functions for character io */ -extern int ungetc(int c, int f); -extern int fgetc(int f); -extern int fputc(int c, int f); +extern int frotz_ungetc(int c, int f); +#define ungetc frotz_ungetc +extern int frotz_fgetc(int f); +#define fgetc frotz_fgetc +extern int frotz_fputc(int c, int f); +#define fputc frotz_fputc /* * 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, } else { if (!running_slideshow) { - rb->snprintf(print, sizeof(print), "loading %lu bytes", image_size); + rb->snprintf(print, sizeof(print), "loading %zu bytes", image_size); rb->lcd_puts(0, 1, print); rb->lcd_update(); } 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 #define DBG(format, arg...) {} #endif +#ifndef ABS +#define ABS(a) (((a) < 0) ? -(a) : (a)) +#endif + #if CONFIG_KEYPAD == IRIVER_H100_PAD #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 @@ * ****************************************************************************/ +#include /* for abs() */ #include "buflib.h" - /* The main goal of this design is fast fetching of the pointer for a handle. * For that reason, the handles are stored in a table at the end of the buffer * 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) while (next_block < freed_block) { block = next_block; - next_block += ABS(block->val); + next_block += abs(block->val); } /* If next_block == block, the above loop didn't go anywhere. If it did, * 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 @@ #ifndef _LIB_JHASH_H_ #define _LIB_JHASH_H_ #include /* defines uint32_t etc */ -#include -#include +#include /* size_t */ +#include "plugin.h" /* hashw() -- 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 #include #include +#include "plugin.h" /*SUPPRESS 560*/ /*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] = (31+28+31+30+31+30+31+31+30+31+30+31), }; -int __isleap(int year) { +static inline int isleap(int year) { /* every fourth year is a leap year except for century years that are * not divisible by 400. */ /* return (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)); */ @@ -36,7 +36,7 @@ struct tm *gmtime(const time_t *timep) { work=*timep/(SPD); r.tm_wday=(4+work)%7; for (i=1970; ; ++i) { - register time_t k=__isleap(i)?366:365; + register time_t k=isleap(i)?366:365; if (work>=k) work-=k; else @@ -46,7 +46,7 @@ struct tm *gmtime(const time_t *timep) { r.tm_yday=work; r.tm_mday=1; - if (__isleap(i) && (work>58)) { + if (isleap(i) && (work>58)) { if (work==59) r.tm_mday=2; /* 29.2. */ work-=1; } 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) enum plugin_status plugin_start(const void* parameter) { int retval; + PLUGINLIB_EXIT_INIT; + PLUGIN_IRAM_INIT(rb) 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, ...) return 1; } -void exit(int code) -{ - code = code; /* Stub function, kill warning for now */ -} - 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 @@ #define FRACTSIZE 12 +#include "lib/pluginlib_exit.h" + #define BUF_SIZE 16384 /* 64 kB output buffers */ #define NBUF 2 @@ -145,7 +147,6 @@ int readFourBytes(int file); int readVarData(int file); int eof(int fd); unsigned char * readData(int file, int len); -void exit(int code); #define malloc(n) my_malloc(n) void * 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) disk_buf.pos_last = 0; disk_buf.low_wm = DISK_BUF_LOW_WATERMARK; - disk_buf.start = mpeg_malloc_all(&disk_buf.size, MPEG_ALLOC_DISKBUF); + disk_buf.start = mpeg_malloc_all((size_t*)&disk_buf.size, MPEG_ALLOC_DISKBUF); if (disk_buf.start == NULL) return false; 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 @@ PLUGIN_HEADER -static bool abort; +static bool cancel; static int fd; static int dirs_count; static int lasttick; @@ -70,7 +70,7 @@ void traversedir(char* location, char* name) if (dir) { entry = rb->readdir(dir); while (entry) { - if (abort) + if (cancel) break; /* Skip .. and . */ if (entry->d_name[0] == '.') @@ -113,7 +113,7 @@ void traversedir(char* location, char* name) lasttick = *rb->current_tick; if (rb->action_userabort(TIMEOUT_NOBLOCK)) { - abort = true; + cancel = true; break; } } @@ -213,7 +213,7 @@ bool custom_dir(void) void generate(void) { dirs_count = 0; - abort = false; + cancel = false; fd = rb->open(RFA_FILE,O_CREAT|O_WRONLY, 0666); rb->write(fd,&dirs_count,sizeof(int)); if (fd < 0) @@ -621,7 +621,7 @@ enum plugin_status plugin_start(const void* parameter) { (void)parameter; - abort = false; + cancel = false; return main_menu(); } 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) { munge_name(name_buf, strlen(name_buf)); /* glom the whole mess together */ - snprintf(buf, bufsiz, "%s/%s-%ld.rbs", STATE_DIR, name_buf, slot_id + 1); + snprintf(buf, bufsiz, "%s/%s-%zud.rbs", STATE_DIR, name_buf, slot_id + 1); } /* @@ -253,17 +253,17 @@ static void slot_info(char *info_buf, size_t info_bufsiz, size_t slot_id) { if (read(fd, buf, 20) > 0) { buf[20] = '\0'; - snprintf(info_buf, info_bufsiz, "%ld. %s", slot_id + 1, buf); + snprintf(info_buf, info_bufsiz, "%zud. %s", slot_id + 1, buf); } else - snprintf(info_buf, info_bufsiz, "%ld. ERROR", slot_id + 1); + snprintf(info_buf, info_bufsiz, "%zud. ERROR", slot_id + 1); close(fd); } else { /* if we couldn't open the file, then the slot is empty */ - snprintf(info_buf, info_bufsiz, "%ld. %s", slot_id + 1, ""); + snprintf(info_buf, info_bufsiz, "%zu. %s", slot_id + 1, ""); } } 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 ROCKBOY_OBJDIR = $(BUILDDIR)/apps/plugins/rockboy ROCKBOY_SRC := $(call preprocess, $(ROCKBOY_SRCDIR)/SOURCES) -ROCKBOY_SRC += $(ROOTDIR)/firmware/common/sscanf.c +ROCKBOY_SRC += $(ROOTDIR)/firmware/libc/sscanf.c ROCKBOY_OBJ := $(call c2obj, $(ROCKBOY_SRC)) OTHER_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 @@ #include "defs.h" #include "mem.h" #include "rtc-gb.h" -#include "sscanf.h" struct rtc rtc; 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 @@ * ****************************************************************************/ #include "plugin.h" -#include "ctype.h" +#include PLUGIN_HEADER 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 extern void *memory_buf; -extern long memory_bufsize; +extern size_t memory_bufsize; extern 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 @@ /* Memory (will be used for entries) */ void *memory_buf; -long memory_bufsize; /* Size of memory_buf in bytes */ +size_t memory_bufsize; /* Size of memory_buf in bytes */ /* 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 static int files, dirs, musicfiles, largestdir; static int lasttick; -static bool abort; +static bool cancel; #if CONFIG_KEYPAD == PLAYER_PAD #define STATS_STOP BUTTON_STOP @@ -173,7 +173,7 @@ void traversedir(char* location, char* name) if (dir) { entry = rb->readdir(dir); while (entry) { - if (abort) + if (cancel) break; /* Skip .. and . */ if (rb->strcmp(entry->d_name, ".") && rb->strcmp(entry->d_name, "..")) @@ -206,7 +206,7 @@ void traversedir(char* location, char* name) || button == STATS_STOP_REMOTE #endif ) { - abort = true; + cancel = true; break; } } @@ -229,14 +229,14 @@ enum plugin_status plugin_start(const void* parameter) dirs = 0; musicfiles = 0; largestdir = 0; - abort = false; + cancel = false; rb->splash(HZ, "Counting..."); update_screen(); lasttick = *rb->current_tick; traversedir("", ""); - if (abort) { + if (cancel) { rb->splash(HZ, "Aborted"); return PLUGIN_OK; } 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; static int wav2wv(const char *infile) { int in_fd, out_fd, num_chans, error = false, last_buttons; - unsigned int32_t total_bytes_read = 0, total_bytes_written = 0; - unsigned int32_t total_samples, samples_remaining; + uint32_t total_bytes_read = 0, total_bytes_written = 0; + uint32_t total_samples, samples_remaining; int32_t *input_buffer = (int32_t *) audiobuf; unsigned char *output_buffer = (unsigned char *)(audiobuf + 0x100000); char outfile[MAX_PATH]; @@ -180,7 +180,7 @@ static int wav2wv(const char *infile) wvupdate (start_tick, native_header.SampleRate, total_samples, 0, 0, 0); for (samples_remaining = total_samples; samples_remaining;) { - unsigned int32_t samples_count, samples_to_pack, bytes_count; + uint32_t samples_count, samples_to_pack, bytes_count; int cnt, buttons; int32_t value, *lp; signed char *cp; @@ -204,7 +204,7 @@ static int wav2wv(const char *infile) cp = (signed char *) input_buffer; while (samples_to_pack) { - unsigned int32_t samples_this_pass = TEMP_SAMPLES / num_chans; + uint32_t samples_this_pass = TEMP_SAMPLES / num_chans; if (samples_this_pass > samples_to_pack) 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); extern void *my_malloc(size_t size); +#undef getc #define getc my_getc -#define malloc my_malloc -#define ftell my_ftell +#undef putc #define putc my_putc +#undef ftell +#define ftell my_ftell +#define malloc my_malloc #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 @@ * */ +#include +#include /* size_t */ #include "zxmisc.h" -#include "helpers.h" #include "spperif.h" #include "z80.h" @@ -29,9 +30,8 @@ #include "spconf.h" -#include -#include -#include +/* include this at last to avoid clashes with stdio functions */ +#include "helpers.h" #define COMPRESS_SAVE 1 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 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ + +#include +#include +#include #include "zxmisc.h" #include "spconf_p.h" #include "interf.h" @@ -26,11 +30,7 @@ #include "snapshot.h" /* for SN_Z80 and SN_SNA */ #include "tapefile.h" /* for TAP_TAP and TAP_TZX */ #include "zxconfig.h" -#include "stdio.h" -#include "string.h" -#include "sys/types.h" #include "helpers.h" -#include "ctype.h" extern 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 @@ #include #include #include -#include #define MAXLINELEN 256 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 @@ #include #include #include -#include +#include "inttypes.h" #include "zxconfig.h" #include "helpers.h" #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 @@ #ifndef ZXMISC_H #define ZXMISC_H -#include +#include /* size_t */ extern char *get_base_name(char *fname); extern 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 @@ * ****************************************************************************/ -#include -#include "sprintf.h" +#include "string-extra.h" #include "system.h" #include "albumart.h" #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 @@ #include "lcd.h" #include "font.h" #include "kernel.h" -#include "sprintf.h" #include "rtc.h" #include "powermgmt.h" 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[] = { /* JPEG decoder implementation */ #ifdef JPEG_FROM_MEM -INLINE unsigned char *getc(struct jpeg* p_jpeg) +INLINE unsigned char *jpeg_getc(struct jpeg* p_jpeg) { if (LIKELY(p_jpeg->len)) { @@ -880,7 +880,7 @@ INLINE bool skip_bytes(struct jpeg* p_jpeg, int count) } } -INLINE void putc(struct jpeg* p_jpeg) +INLINE void jpeg_putc(struct jpeg* p_jpeg) { p_jpeg->len++; p_jpeg->data--; @@ -892,7 +892,7 @@ INLINE void fill_buf(struct jpeg* p_jpeg) p_jpeg->buf_index = 0; } -static unsigned char *getc(struct jpeg* p_jpeg) +static unsigned char *jpeg_getc(struct jpeg* p_jpeg) { if (UNLIKELY(p_jpeg->buf_left < 1)) fill_buf(p_jpeg); @@ -917,7 +917,7 @@ static bool skip_bytes(struct jpeg* p_jpeg, int count) return p_jpeg->buf_left >= 0 || skip_bytes_seek(p_jpeg); } -static void putc(struct jpeg* p_jpeg) +static void jpeg_putc(struct jpeg* p_jpeg) { p_jpeg->buf_left++; p_jpeg->buf_index--; @@ -933,14 +933,14 @@ do {\ #define e_getc(jpeg, code) \ ({ \ unsigned char *c; \ - if (UNLIKELY(!(c = getc(jpeg)))) \ + if (UNLIKELY(!(c = jpeg_getc(jpeg)))) \ return (code); \ *c; \ }) #define d_getc(jpeg, def) \ ({ \ - unsigned char *cp = getc(jpeg); \ + unsigned char *cp = jpeg_getc(jpeg); \ unsigned char c = LIKELY(cp) ? *cp : (def); \ c; \ }) @@ -958,7 +958,7 @@ static int process_markers(struct jpeg* p_jpeg) if (c != 0xFF) /* no marker? */ { JDEBUGF("Non-marker data\n"); - putc(p_jpeg); + jpeg_putc(p_jpeg); break; /* exit marker processing */ } @@ -969,7 +969,7 @@ static int process_markers(struct jpeg* p_jpeg) case 0xFF: /* Fill byte */ ret |= FILL_FF; case 0x00: /* Zero stuffed byte - entropy data */ - putc(p_jpeg); + jpeg_putc(p_jpeg); continue; case 0xC0: /* SOF Huff - Baseline DCT */ @@ -1669,7 +1669,7 @@ static void search_restart(struct jpeg *p_jpeg) return; } else - putc(p_jpeg); + jpeg_putc(p_jpeg); } } } 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 @@ ****************************************************************************/ #include "kernel.h" #include "system.h" -#include +#include "string-extra.h" #include "font.h" #include "screens.h" #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 @@ #include "storage.h" #include "lcd.h" #include "scrollbar.h" -#include "sprintf.h" #include "button.h" #include "system.h" #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 @@ #include #include #include -#include "sprintf.h" #include "mas.h" #include "settings.h" #include "button.h" @@ -35,7 +34,7 @@ #include "file.h" #include "general.h" #include "errno.h" -#include "string.h" +#include "string-extra.h" #include "system.h" #include "radio.h" #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) draw attention */ /* Don't use language string unless agreed upon to make this method permanent - could do something in the statusbar */ - snprintf(buf, sizeof(buf), "Warning: %08X", + snprintf(buf, sizeof(buf), "Warning: %08lX", pcm_rec_get_warnings()); } else @@ -1771,7 +1771,7 @@ bool recording_screen(bool no_source) (global_settings.rec_split_method)) { dmb = dsize/1024/1024; - snprintf(buf, sizeof(buf), "%s %dMB", + snprintf(buf, sizeof(buf), "%s %luMB", str(LANG_SPLIT_SIZE), dmb); } 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 @@ ****************************************************************************/ #include -#include #include #include #include #include -#include -#include +#include +#include "strlcpy.h" +#include "strcasecmp.h" +#include "system.h" #include "metadata.h" #include "debug.h" #include "replaygain.h" @@ -244,7 +245,7 @@ long parse_replaygain_int(bool album, long gain, long peak, if (buffer != NULL) { - len = snprintf(buffer, length, "%d.%02d dB", gain / 512, + len = snprintf(buffer, length, "%ld.%02d dB", gain / 512, ((abs(gain) & 0x01ff) * 100 + 256) / 512); len++; } 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 @@ * ****************************************************************************/ #include -#include #include #include +#include "string-extra.h" #include "config.h" #include "appevents.h" #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 @@ * ****************************************************************************/ +#include +#include "config.h" #include #include #include -#include "backlight.h" #include #include -#include #include #include #include +#include "backlight.h" #include "screen_access.h" #include "backdrop.h" 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 @@ #include "settings.h" #include "status.h" #include "playlist.h" -#include "sprintf.h" #include "kernel.h" #include "power.h" #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: http://www.audioscrobbler.net/wiki/Portable_Player_Logging */ +#include #include "file.h" -#include "sprintf.h" #include "logf.h" #include "metadata.h" #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 @@ #include "backlight.h" #include "audio.h" #include "talk.h" -#include "string.h" +#include "strlcpy.h" +#include "strcasestr.h" #include "rtc.h" #include "power.h" #include "ata_idle_notify.h" @@ -52,7 +53,6 @@ #include "lang.h" #include "language.h" #include "powermgmt.h" -#include "sprintf.h" #include "keyboard.h" #include "version.h" #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 @@ #include "config.h" #include -#include +#include "string-extra.h" #include "system.h" #include "storage.h" #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 @@ #include "kernel.h" #include "system.h" #include "logf.h" -#include "string.h" +#include "string-extra.h" #include "usb.h" #include "metadata.h" #include "tagcache.h" @@ -1392,7 +1392,7 @@ static bool get_next(struct tagcache_search *tcs) if (TAGCACHE_IS_NUMERIC(tcs->type)) { - snprintf(buf, sizeof(buf), "%d", tcs->position); + snprintf(buf, sizeof(buf), "%ld", tcs->position); tcs->result = buf; tcs->result_len = strlen(buf) + 1; return true; @@ -3490,7 +3490,7 @@ bool tagcache_create_changelog(struct tagcache_search *tcs) { if (TAGCACHE_IS_NUMERIC(j)) { - snprintf(temp, sizeof temp, "%d", idx.tag_seek[j]); + snprintf(temp, sizeof temp, "%d", (int)idx.tag_seek[j]); write_tag(clfd, tagcache_tag_to_str(j), temp); continue; } 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 @@ /*#define LOGF_ENABLE*/ #include -#include #include +#include "string-extra.h" #include "config.h" #include "system.h" #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 @@ #include #include -#include +#include "string-extra.h" #include "file.h" #include "buffer.h" #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 @@ * ****************************************************************************/ #include -#include #include #include +#include "string-extra.h" #include "applimits.h" #include "dir.h" @@ -32,7 +32,6 @@ #include "kernel.h" #include "usb.h" #include "tree.h" -#include "sprintf.h" #include "audio.h" #include "playlist.h" #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 @@ * KIND, either express or implied. * ****************************************************************************/ +#include #include "system.h" #include "thread.h" #include "voice_thread.h" -- cgit