From 8d4ff638b9a79abcefe538eef8f1933c0c0decf9 Mon Sep 17 00:00:00 2001 From: Frank Gevaerts Date: Fri, 7 May 2010 19:27:42 +0000 Subject: Fix size_t handling in plugin_get_buffer() git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25884 a1c6a512-1295-4272-9138-f99709370657 --- apps/plugins/alpine_cdc.c | 4 +++- apps/plugins/chessbox/chessbox_pgn.c | 6 +++--- apps/plugins/dict.c | 6 +++--- apps/plugins/firmware_flash.c | 8 ++++---- apps/plugins/lib/overlay.c | 4 ++-- apps/plugins/random_folder_advance_config.c | 6 +++--- apps/plugins/rockbox_flash.c | 8 ++++---- apps/plugins/snake2.c | 4 ++-- apps/plugins/sort.c | 6 +++--- apps/plugins/vbrfix.c | 4 ++-- apps/plugins/viewer.c | 4 +++- apps/plugins/wavplay.c | 7 ++++--- apps/plugins/wavrecord.c | 7 ++++--- apps/plugins/wavview.c | 4 ++-- 14 files changed, 42 insertions(+), 36 deletions(-) (limited to 'apps') diff --git a/apps/plugins/alpine_cdc.c b/apps/plugins/alpine_cdc.c index 73bc49ff00..9357b2e5ab 100644 --- a/apps/plugins/alpine_cdc.c +++ b/apps/plugins/alpine_cdc.c @@ -1141,6 +1141,7 @@ int main(const void* parameter) #ifdef DEBUG int button; #endif + size_t buf_size; ssize_t stacksize; void* stack; @@ -1155,7 +1156,8 @@ int main(const void* parameter) #endif /* init the worker thread */ - stack = rb->plugin_get_buffer((size_t *)&stacksize); /* use the rest as stack */ + stack = rb->plugin_get_buffer(&buf_size); /* use the rest as stack */ + stacksize = buf_size; stack = (void*)(((unsigned int)stack + 100) & ~3); /* a bit away, 32 bit align */ stacksize = (stacksize - 100) & ~3; if (stacksize < DEFAULT_STACK_SIZE) diff --git a/apps/plugins/chessbox/chessbox_pgn.c b/apps/plugins/chessbox/chessbox_pgn.c index 3d699a7c9e..43da92e0a0 100644 --- a/apps/plugins/chessbox/chessbox_pgn.c +++ b/apps/plugins/chessbox/chessbox_pgn.c @@ -32,12 +32,12 @@ short bp_offs[4][2] = {{1,1},{-1,1},{1,-1},{-1,-1}}; /* global vars for pl_malloc() */ void *bufptr = NULL; -ssize_t bufleft; +size_t bufleft; /* simple function to "allocate" memory in pluginbuffer. * (borrowed from dict.c) */ -void *pl_malloc(ssize_t size) +void *pl_malloc(size_t size) { void *ptr; ptr = bufptr; @@ -57,7 +57,7 @@ void *pl_malloc(ssize_t size) /* init function for pl_malloc() */ void pl_malloc_init(void) { - bufptr = rb->plugin_get_buffer((size_t *)&bufleft); + bufptr = rb->plugin_get_buffer(&bufleft); } void process_tag(struct pgn_game_node* game, char* buffer){ diff --git a/apps/plugins/dict.c b/apps/plugins/dict.c index cdd4c651de..8c262923b7 100644 --- a/apps/plugins/dict.c +++ b/apps/plugins/dict.c @@ -62,10 +62,10 @@ void init_screen(void) /* global vars for pl_malloc() */ void *bufptr; -ssize_t bufleft; +size_t bufleft; /* simple function to "allocate" memory in pluginbuffer. */ -void *pl_malloc(ssize_t size) +void *pl_malloc(size_t size) { void *ptr; ptr = bufptr; @@ -85,7 +85,7 @@ void *pl_malloc(ssize_t size) /* init function for pl_malloc() */ void pl_malloc_init(void) { - bufptr = rb->plugin_get_buffer((size_t *)&bufleft); + bufptr = rb->plugin_get_buffer(&bufleft); } /* for endian problems */ diff --git a/apps/plugins/firmware_flash.c b/apps/plugins/firmware_flash.c index 6718d58e6a..43ed7a87d9 100644 --- a/apps/plugins/firmware_flash.c +++ b/apps/plugins/firmware_flash.c @@ -597,7 +597,7 @@ void DoUserDialog(char* filename) char default_filename[32]; int button; int rc; /* generic return code */ - ssize_t memleft; + size_t memleft; tCheckROM result; bool is_romless; @@ -644,7 +644,7 @@ void DoUserDialog(char* filename) } /* "allocate" memory */ - sector = rb->plugin_get_buffer((size_t *)&memleft); + sector = rb->plugin_get_buffer(&memleft); if (memleft < SEC_SIZE) /* need buffer for a flash sector */ { rb->splash(HZ*3, "Out of memory"); @@ -837,7 +837,7 @@ void DoUserDialog(char* filename) char default_filename[32]; int button; int rc; /* generic return code */ - ssize_t memleft; + size_t memleft; tCheckROM result; bool is_romless; @@ -884,7 +884,7 @@ void DoUserDialog(char* filename) } /* "allocate" memory */ - sector = rb->plugin_get_buffer((size_t *)&memleft); + sector = rb->plugin_get_buffer(&memleft); if (memleft < SEC_SIZE) /* need buffer for a flash sector */ { rb->splash(HZ*3, "Out of memory"); diff --git a/apps/plugins/lib/overlay.c b/apps/plugins/lib/overlay.c index fb779e4f82..97a6e1c718 100644 --- a/apps/plugins/lib/overlay.c +++ b/apps/plugins/lib/overlay.c @@ -49,7 +49,7 @@ enum plugin_status run_overlay(const void* parameter, unsigned char *filename, unsigned char *name) { int fd, readsize; - ssize_t audiobuf_size; + size_t audiobuf_size; unsigned char *audiobuf; static struct plugin_header header; @@ -80,7 +80,7 @@ enum plugin_status run_overlay(const void* parameter, return PLUGIN_ERROR; } - audiobuf = rb->plugin_get_audio_buffer((size_t *)&audiobuf_size); + audiobuf = rb->plugin_get_audio_buffer(&audiobuf_size); if (header.load_addr < audiobuf || header.end_addr > audiobuf + audiobuf_size) { diff --git a/apps/plugins/random_folder_advance_config.c b/apps/plugins/random_folder_advance_config.c index f7bb790dc1..9a589dfff6 100644 --- a/apps/plugins/random_folder_advance_config.c +++ b/apps/plugins/random_folder_advance_config.c @@ -33,7 +33,7 @@ static int lasttick; #define MAX_REMOVED_DIRS 10 char *buffer = NULL; -ssize_t buffer_size; +size_t buffer_size; int num_replaced_dirs = 0; char removed_dirs[MAX_REMOVED_DIRS][MAX_PATH]; struct file_format { @@ -248,7 +248,7 @@ int load_list(void) int myfd = rb->open(RFA_FILE,O_RDONLY); if (myfd < 0) return -1; - buffer = rb->plugin_get_audio_buffer((size_t *)&buffer_size); + buffer = rb->plugin_get_audio_buffer(&buffer_size); if (!buffer) { return -2; @@ -414,7 +414,7 @@ int import_list_from_file_text(void) { char line[MAX_PATH]; - buffer = rb->plugin_get_audio_buffer((size_t *)&buffer_size); + buffer = rb->plugin_get_audio_buffer(&buffer_size); if (buffer == NULL) { rb->splash(HZ*2, "failed to get audio buffer"); diff --git a/apps/plugins/rockbox_flash.c b/apps/plugins/rockbox_flash.c index 4bdb0d2c69..17c5e51ee2 100644 --- a/apps/plugins/rockbox_flash.c +++ b/apps/plugins/rockbox_flash.c @@ -568,7 +568,7 @@ static void DoUserDialog(char* filename) int rc; /* generic return code */ UINT32 space, aligned_size, true_size; UINT8* pos; - ssize_t memleft; + size_t memleft; unsigned bl_version; bool show_greet = false; @@ -587,7 +587,7 @@ static void DoUserDialog(char* filename) } /* "allocate" memory */ - sector = rb->plugin_get_buffer((size_t *)&memleft); + sector = rb->plugin_get_buffer(&memleft); if (memleft < SECTORSIZE) /* need buffer for a flash sector */ { rb->splash(HZ*3, "Out of memory"); @@ -772,7 +772,7 @@ static void DoUserDialog(char* filename) int rc; /* generic return code */ UINT32 space, aligned_size, true_size; UINT8* pos; - ssize_t memleft; + size_t memleft; unsigned bl_version; /* this can only work if Rockbox runs in DRAM, not flash ROM */ @@ -790,7 +790,7 @@ static void DoUserDialog(char* filename) } /* "allocate" memory */ - sector = rb->plugin_get_buffer((size_t *)&memleft); + sector = rb->plugin_get_buffer(&memleft); if (memleft < SECTORSIZE) /* need buffer for a flash sector */ { rb->splash(HZ*3, "Out of memory"); diff --git a/apps/plugins/snake2.c b/apps/plugins/snake2.c index d9b6542bf3..414d924c4a 100644 --- a/apps/plugins/snake2.c +++ b/apps/plugins/snake2.c @@ -409,13 +409,13 @@ int load_all_levels(void) { int linecnt = 0; int fd; - ssize_t size; + size_t size; char buf[64]; /* Larger than WIDTH, to allow for whitespace after the lines */ /* Init the level_cache pointer and calculate how many levels that will fit */ - level_cache = rb->plugin_get_buffer((size_t *)&size); + level_cache = rb->plugin_get_buffer(&size); max_levels = size / (HEIGHT*WIDTH); num_levels = 0; diff --git a/apps/plugins/sort.c b/apps/plugins/sort.c index 05c45cce1e..1e787b33dd 100644 --- a/apps/plugins/sort.c +++ b/apps/plugins/sort.c @@ -59,7 +59,7 @@ PLUGIN_HEADER -ssize_t buf_size; +size_t buf_size; static char *filename; static int num_entries; static char **pointers; @@ -104,7 +104,7 @@ int read_buffer(int offset) return readsize * 10 - 2; /* Temporary fix until we can do merged sorting */ - if(readsize == buf_size) + if(readsize == (int)buf_size) return buf_size; /* File too big */ buf_ptr = stringbuffer; @@ -192,7 +192,7 @@ enum plugin_status plugin_start(const void* parameter) filename = (char *)parameter; - buf = rb->plugin_get_audio_buffer((size_t *)&buf_size); /* start munching memory */ + buf = rb->plugin_get_audio_buffer(&buf_size); /* start munching memory */ stringbuffer = buf; pointers = (char **)(buf + buf_size - sizeof(int)); diff --git a/apps/plugins/vbrfix.c b/apps/plugins/vbrfix.c index 2ca0176084..ba13dc53f9 100644 --- a/apps/plugins/vbrfix.c +++ b/apps/plugins/vbrfix.c @@ -23,7 +23,7 @@ PLUGIN_HEADER static char *audiobuf; -static ssize_t audiobuflen; +static size_t audiobuflen; unsigned char xingbuf[1500]; char tmpname[MAX_PATH]; @@ -267,7 +267,7 @@ enum plugin_status plugin_start(const void *parameter) if (!parameter) return PLUGIN_ERROR; - audiobuf = rb->plugin_get_audio_buffer((size_t *)&audiobuflen); + audiobuf = rb->plugin_get_audio_buffer(&audiobuflen); #ifdef HAVE_ADJUSTABLE_CPU_FREQ rb->cpu_boost(true); diff --git a/apps/plugins/viewer.c b/apps/plugins/viewer.c index ffed414f68..f000628ca3 100644 --- a/apps/plugins/viewer.c +++ b/apps/plugins/viewer.c @@ -3059,11 +3059,13 @@ enum plugin_status plugin_start(const void* file) int lastbutton = BUTTON_NONE; bool autoscroll = false; long old_tick; + size_t buf_size; old_tick = *rb->current_tick; /* get the plugin buffer */ - buffer = rb->plugin_get_buffer((size_t *)&buffer_size); + buffer = rb->plugin_get_buffer(&buf_size); + buffer_size = buf_size; if (buffer_size == 0) { rb->splash(HZ, "buffer does not allocate !!"); diff --git a/apps/plugins/wavplay.c b/apps/plugins/wavplay.c index fdf9535bb2..94fef9faa0 100644 --- a/apps/plugins/wavplay.c +++ b/apps/plugins/wavplay.c @@ -3649,7 +3649,7 @@ int play_file(char* filename) /* plugin entry point */ enum plugin_status plugin_start(const void* parameter) { - ssize_t buf_size; + size_t buf_size; if (!parameter) { @@ -3657,14 +3657,15 @@ enum plugin_status plugin_start(const void* parameter) return PLUGIN_OK; } - plug_buf = rb->plugin_get_buffer((size_t *)&buf_size); + plug_buf = rb->plugin_get_buffer(&buf_size); if (buf_size < 6700) /* needed for i2c transfer */ { rb->splash(HZ, "Out of memory."); return PLUGIN_ERROR; } - aud_buf = rb->plugin_get_audio_buffer((size_t *)&aud_size); + aud_buf = rb->plugin_get_audio_buffer(&buf_size); + aud_size = buf_size; switch (play_file((char*)parameter)) { diff --git a/apps/plugins/wavrecord.c b/apps/plugins/wavrecord.c index f9d76d4366..83b63e9805 100644 --- a/apps/plugins/wavrecord.c +++ b/apps/plugins/wavrecord.c @@ -3750,14 +3750,14 @@ static int recording_menu(void) /* plugin entry point */ enum plugin_status plugin_start(const void* parameter) { - ssize_t buf_size; + size_t buf_size; int align; int rc; const char *recbasedir; (void)parameter; - plug_buf = rb->plugin_get_buffer((size_t *)&buf_size); + plug_buf = rb->plugin_get_buffer(&buf_size); if (buf_size < 6700) /* needed for i2c transfer */ { rb->splash(HZ, "Out of memory."); @@ -3776,7 +3776,8 @@ enum plugin_status plugin_start(const void* parameter) } } - aud_buf = rb->plugin_get_audio_buffer((size_t *)&aud_size); + aud_buf = rb->plugin_get_audio_buffer(&buf_size); + aud_size = buf_size; align = (-(long)aud_buf) & 3; aud_buf += align; aud_size -= align; diff --git a/apps/plugins/wavview.c b/apps/plugins/wavview.c index 0449fbec05..2b19d3d18a 100644 --- a/apps/plugins/wavview.c +++ b/apps/plugins/wavview.c @@ -60,7 +60,7 @@ struct peakstruct /* global vars */ static char *audiobuf; -static ssize_t audiobuflen; +static size_t audiobuflen; static uint32_t mempeakcount = 0; static uint32_t filepeakcount = 0; static uint32_t fppmp = 0; /* file peaks per mem peaks */ @@ -362,7 +362,7 @@ enum plugin_status plugin_start(const void *parameter) if (!parameter) return PLUGIN_ERROR; - audiobuf = rb->plugin_get_audio_buffer((size_t *)&audiobuflen); + audiobuf = rb->plugin_get_audio_buffer(&audiobuflen); if (!audiobuf) { -- cgit v1.2.3