From c76c568b351d37c485f78cd185b2d52d54fe7a34 Mon Sep 17 00:00:00 2001 From: Jens Arnold Date: Mon, 16 Aug 2004 23:37:23 +0000 Subject: Const policed pointer arguments to functions, part 1 git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4995 a1c6a512-1295-4272-9138-f99709370657 --- apps/plugin.h | 9 +++++---- firmware/debug.c | 14 +++++++------- firmware/drivers/lcd-player.c | 2 +- firmware/drivers/lcd-recorder.c | 4 ++-- firmware/export/font.h | 2 +- firmware/export/id3.h | 4 ++-- firmware/export/kernel.h | 2 +- firmware/export/lcd.h | 4 ++-- firmware/export/mp3_playback.h | 2 +- firmware/export/mpeg.h | 4 ++-- firmware/export/panic.h | 2 +- firmware/font.c | 12 ++++++------ firmware/id3.c | 4 ++-- firmware/kernel.c | 2 +- firmware/mp3_playback.c | 2 +- firmware/mpeg.c | 8 ++++---- firmware/panic.c | 2 +- firmware/rolo.c | 10 ++++++---- firmware/thread.c | 2 +- uisimulator/win32/kernel.c | 2 +- 20 files changed, 48 insertions(+), 45 deletions(-) diff --git a/apps/plugin.h b/apps/plugin.h index 8ee2534372..d44aa7d60b 100644 --- a/apps/plugin.h +++ b/apps/plugin.h @@ -112,7 +112,7 @@ struct plugin_api { /* lcd */ void (*lcd_clear_display)(void); void (*lcd_puts)(int x, int y, const unsigned char *string); - void (*lcd_puts_scroll)(int x, int y, unsigned char* string); + void (*lcd_puts_scroll)(int x, int y, const unsigned char* string); void (*lcd_stop_scroll)(void); void (*lcd_set_contrast)(int x); #ifdef HAVE_LCD_CHARCELLS @@ -211,7 +211,7 @@ struct plugin_api { /* sound */ void (*mpeg_sound_set)(int setting, int value); #ifndef SIMULATOR - void (*mp3_play_data)(unsigned char* start, int size, void (*get_more)(unsigned char** start, int* size)); + void (*mp3_play_data)(const unsigned char* start, int size, void (*get_more)(unsigned char** start, int* size)); void (*mp3_play_pause)(bool play); void (*mp3_play_stop)(void); bool (*mp3_is_playing)(void); @@ -264,7 +264,7 @@ struct plugin_api { #endif struct user_settings* global_settings; void (*backlight_set_timeout)(int index); - bool (*mp3info)(struct mp3entry *entry, char *filename, bool v1first); + bool (*mp3info)(struct mp3entry *entry, const char *filename, bool v1first); int (*count_mp3_frames)(int fd, int startpos, int filesize, void (*progressfunc)(int)); int (*create_xing_header)(int fd, int startpos, int filesize, @@ -285,7 +285,8 @@ struct plugin_api { int (*peak_meter_get_use_dbfs)(void); #endif #ifdef HAVE_LCD_BITMAP - void (*lcd_puts_scroll_style)(int x, int y, unsigned char* string, int style); + void (*lcd_puts_scroll_style)(int x, int y, const unsigned char* string, + int style); #endif void (*mpeg_flush_and_reload_tracks)(void); int (*strncasecmp)(const char *s1, const char *s2, size_t n); diff --git a/firmware/debug.c b/firmware/debug.c index 977ece3f5d..6a30c6076a 100644 --- a/firmware/debug.c +++ b/firmware/debug.c @@ -112,11 +112,11 @@ static char lowhex(int x) return hexchars[x & 0xf]; } -static void putpacket (char *buffer) +static void putpacket (const char *buffer) { register int checksum; - char *src = buffer; + const char *src = buffer; /* Special debug hack. Shut off the Rx IRQ during I/O to prevent the debug stub from interrupting the message */ @@ -172,7 +172,7 @@ static void putpacket (char *buffer) /* convert the memory, pointed to by mem into hex, placing result in buf */ /* return a pointer to the last char put in buf (null) */ -static char *mem2hex (char *mem, char *buf, int count) +static char *mem2hex (const char *mem, char *buf, int count) { int i; int ch; @@ -186,7 +186,7 @@ static char *mem2hex (char *mem, char *buf, int count) return (buf); } -static void debug(char *msg) +static void debug(const char *msg) { debugbuf[0] = 'O'; @@ -196,7 +196,7 @@ static void debug(char *msg) #endif /* end of DEBUG section */ #ifdef __GNUC__ -void debugf(char *fmt, ...) +void debugf(const char *fmt, ...) #endif { #ifdef DEBUG @@ -218,7 +218,7 @@ void debug_init(void) { } -void debugf(char *fmt, ...) +void debugf(const char *fmt, ...) { va_list ap; va_start( ap, fmt ); @@ -226,7 +226,7 @@ void debugf(char *fmt, ...) va_end( ap ); } -void ldebugf(char* file, int line, char *fmt, ...) +void ldebugf(const char* file, int line, const char *fmt, ...) { va_list ap; va_start( ap, fmt ); diff --git a/firmware/drivers/lcd-player.c b/firmware/drivers/lcd-player.c index c948f49828..d4a523afe3 100644 --- a/firmware/drivers/lcd-player.c +++ b/firmware/drivers/lcd-player.c @@ -530,7 +530,7 @@ void lcd_bidir_scroll(int percent) bidir_limit = percent; } -void lcd_puts_scroll(int x, int y, unsigned char* string ) +void lcd_puts_scroll(int x, int y, const unsigned char* string ) { struct scrollinfo* s; int i; diff --git a/firmware/drivers/lcd-recorder.c b/firmware/drivers/lcd-recorder.c index 42cf016f97..a8dca92b4f 100644 --- a/firmware/drivers/lcd-recorder.c +++ b/firmware/drivers/lcd-recorder.c @@ -784,12 +784,12 @@ void lcd_invertpixel(int x, int y) INVERT_PIXEL(x,y); } -void lcd_puts_scroll(int x, int y, unsigned char *string) +void lcd_puts_scroll(int x, int y, const unsigned char *string) { lcd_puts_scroll_style(x, y, string, STYLE_DEFAULT); } -void lcd_puts_scroll_style(int x, int y, unsigned char *string, int style) +void lcd_puts_scroll_style(int x, int y, const unsigned char *string, int style) { struct scrollinfo* s; int w, h; diff --git a/firmware/export/font.h b/firmware/export/font.h index f2f83e54c8..14a683a5f2 100644 --- a/firmware/export/font.h +++ b/firmware/export/font.h @@ -103,7 +103,7 @@ struct font { /* font routines*/ void font_init(void); -struct font* font_load(char *path); +struct font* font_load(const char *path); struct font* font_get(int font); void font_reset(void); diff --git a/firmware/export/id3.h b/firmware/export/id3.h index 10f8002db6..8a79cb0ce1 100644 --- a/firmware/export/id3.h +++ b/firmware/export/id3.h @@ -74,7 +74,7 @@ enum { ID3_VER_2_4 }; -bool mp3info(struct mp3entry *entry, char *filename, bool v1first); -char* id3_get_genre(struct mp3entry* id3); +bool mp3info(struct mp3entry *entry, const char *filename, bool v1first); +char* id3_get_genre(const struct mp3entry* id3); #endif diff --git a/firmware/export/kernel.h b/firmware/export/kernel.h index 6e11baedf6..97994c41df 100644 --- a/firmware/export/kernel.h +++ b/firmware/export/kernel.h @@ -71,7 +71,7 @@ extern void queue_init(struct event_queue *q); extern void queue_wait(struct event_queue *q, struct event *ev); extern void queue_wait_w_tmo(struct event_queue *q, struct event *ev, int ticks); extern void queue_post(struct event_queue *q, int id, void *data); -extern bool queue_empty(struct event_queue* q); +extern bool queue_empty(const struct event_queue* q); extern int queue_broadcast(int id, void *data); extern void mutex_init(struct mutex *m); diff --git a/firmware/export/lcd.h b/firmware/export/lcd.h index 6a7f8cf155..2a8a7ff0b1 100644 --- a/firmware/export/lcd.h +++ b/firmware/export/lcd.h @@ -35,8 +35,8 @@ extern void lcd_puts(int x, int y, const unsigned char *string); extern void lcd_puts_style(int x, int y, const unsigned char *string, int style); extern void lcd_putc(int x, int y, unsigned short ch); -extern void lcd_puts_scroll(int x, int y, unsigned char* string ); -extern void lcd_puts_scroll_style(int x, int y, unsigned char* string, +extern void lcd_puts_scroll(int x, int y, const unsigned char* string ); +extern void lcd_puts_scroll_style(int x, int y, const unsigned char* string, int style); extern void lcd_icon(int icon, bool enable); extern void lcd_stop_scroll(void); diff --git a/firmware/export/mp3_playback.h b/firmware/export/mp3_playback.h index 9eb1d882ff..12ef734bfe 100644 --- a/firmware/export/mp3_playback.h +++ b/firmware/export/mp3_playback.h @@ -51,7 +51,7 @@ void demand_irq_enable(bool on); /* new functions, exported to plugin API */ void mp3_play_init(void); -void mp3_play_data(unsigned char* start, int size, +void mp3_play_data(const unsigned char* start, int size, void (*get_more)(unsigned char** start, int* size) /* callback fn */ ); void mp3_play_pause(bool play); diff --git a/firmware/export/mpeg.h b/firmware/export/mpeg.h index bf16a2ac73..3088dc5ffd 100644 --- a/firmware/export/mpeg.h +++ b/firmware/export/mpeg.h @@ -77,8 +77,8 @@ int mpeg_status(void); #if defined(HAVE_MAS3587F) || defined(SIMULATOR) void mpeg_init_recording(void); void mpeg_init_playback(void); -void mpeg_record(char *filename); -void mpeg_new_file(char *filename); +void mpeg_record(const char *filename); +void mpeg_new_file(const char *filename); void mpeg_set_recording_options(int frequency, int quality, int source, int channel_mode, bool editable, int prerecord_time); diff --git a/firmware/export/panic.h b/firmware/export/panic.h index 585f827927..fd63687606 100644 --- a/firmware/export/panic.h +++ b/firmware/export/panic.h @@ -20,6 +20,6 @@ #ifndef __PANIC_H__ #define __PANIC_H__ -void panicf( char *fmt, ... ); +void panicf( const char *fmt, ... ); #endif /* __PANIC_H__ */ diff --git a/firmware/font.c b/firmware/font.c index f33490869a..343dd0b278 100644 --- a/firmware/font.c +++ b/firmware/font.c @@ -53,9 +53,9 @@ static unsigned char *freeptr = mbuf; static unsigned char *fileptr; static unsigned char *eofptr; -static void rotate_font_bits(struct font* pf); +static void rotate_font_bits(const struct font* pf); static void rotleft(unsigned char *dst, - bitmap_t *src, + const bitmap_t *src, unsigned int width, unsigned int height); @@ -120,7 +120,7 @@ void font_reset(void) } /* read and load font into incore font structure*/ -struct font* font_load(char *path) +struct font* font_load(const char *path) { int fd, filesize; unsigned short maxwidth, height, ascent, pad; @@ -263,7 +263,7 @@ struct font* font_get(int font) } /* convert font bitmap data inplace to rockbox format*/ -static void rotate_font_bits(struct font* pf) +static void rotate_font_bits(const struct font* pf) { int i; unsigned long defaultchar = pf->defaultchar - pf->firstchar; @@ -305,8 +305,8 @@ static void rotate_font_bits(struct font* pf) * Doing it this way keeps fonts in standard formats, * as well as keeping Rockbox hw bitmap format. */ -static void rotleft(unsigned char *dst, bitmap_t *src, unsigned int width, - unsigned int height) +static void rotleft(unsigned char *dst, const bitmap_t *src, + unsigned int width, unsigned int height) { unsigned int i,j; unsigned int src_words; /* # words of input image*/ diff --git a/firmware/id3.c b/firmware/id3.c index 0a08fa0de8..4297c8ba70 100644 --- a/firmware/id3.c +++ b/firmware/id3.c @@ -77,7 +77,7 @@ static const char* const genres[] = { "Duet", "Punk Rock", "Drum Solo", "A capella", "Euro-House", "Dance Hall" }; -char* id3_get_genre(struct mp3entry* id3) +char* id3_get_genre(const struct mp3entry* id3) { if( id3->genre_string ) return id3->genre_string ; @@ -799,7 +799,7 @@ static int getsonglength(int fd, struct mp3entry *entry) * about an MP3 file and updates it's entry accordingly. * */ -bool mp3info(struct mp3entry *entry, char *filename, bool v1first) +bool mp3info(struct mp3entry *entry, const char *filename, bool v1first) { int fd; int v1found = false; diff --git a/firmware/kernel.c b/firmware/kernel.c index ec2c149cc5..2cb87ccbc9 100644 --- a/firmware/kernel.c +++ b/firmware/kernel.c @@ -126,7 +126,7 @@ void queue_post(struct event_queue *q, int id, void *data) set_irq_level(oldlevel); } -bool queue_empty(struct event_queue* q) +bool queue_empty(const struct event_queue* q) { return ( q->read == q->write ); } diff --git a/firmware/mp3_playback.c b/firmware/mp3_playback.c index 1d4f77bf41..8159c4504c 100644 --- a/firmware/mp3_playback.c +++ b/firmware/mp3_playback.c @@ -1059,7 +1059,7 @@ void mp3_play_init(void) mp3_reset_playtime(); } -void mp3_play_data(unsigned char* start, int size, +void mp3_play_data(const unsigned char* start, int size, void (*get_more)(unsigned char** start, int* size) /* callback fn */ ) { diff --git a/firmware/mpeg.c b/firmware/mpeg.c index c6afbd8e6c..bfcdfc1c0c 100644 --- a/firmware/mpeg.c +++ b/firmware/mpeg.c @@ -803,7 +803,7 @@ static void transfer_end(unsigned char** ppbuf, int* psize) wake_up_thread(); } -static int add_track_to_tag_list(char *filename) +static int add_track_to_tag_list(const char *filename) { struct id3tag *t = NULL; int i; @@ -938,7 +938,7 @@ static void track_change(void) } #ifdef DEBUG -void hexdump(unsigned char *buf, int len) +void hexdump(const unsigned char *buf, int len) { int i; @@ -2167,7 +2167,7 @@ static void init_recording(void) call mpeg_set_recording_options(). */ } -void mpeg_record(char *filename) +void mpeg_record(const char *filename) { mpeg_errno = 0; @@ -2396,7 +2396,7 @@ void mpeg_set_recording_gain(int left, int right, bool use_mic) 0x0007); } -void mpeg_new_file(char *filename) +void mpeg_new_file(const char *filename) { mpeg_errno = 0; diff --git a/firmware/panic.c b/firmware/panic.c index df8afdfda3..147ee6292e 100644 --- a/firmware/panic.c +++ b/firmware/panic.c @@ -31,7 +31,7 @@ static char panic_buf[128]; /* * "Dude. This is pretty fucked-up, right here." */ -void panicf( char *fmt, ...) +void panicf( const char *fmt, ...) { va_list ap; diff --git a/firmware/rolo.c b/firmware/rolo.c index c5cfc5d77b..d78078cdd7 100644 --- a/firmware/rolo.c +++ b/firmware/rolo.c @@ -30,7 +30,7 @@ #define IRQ0_EDGE_TRIGGER 0x80 -static void rolo_error(char *text) +static void rolo_error(const char *text) { lcd_clear_display(); lcd_puts(0, 0, "ROLO error:"); @@ -43,8 +43,10 @@ static void rolo_error(char *text) } /* these are in assembler file "descramble.S" */ -extern unsigned short descramble(unsigned char* source, unsigned char* dest, int length); -extern void rolo_restart(unsigned char* source, unsigned char* dest, int length); +extern unsigned short descramble(const unsigned char* source, + unsigned char* dest, int length); +extern void rolo_restart(const unsigned char* source, unsigned char* dest, + int length); /*************************************************************************** * @@ -52,7 +54,7 @@ extern void rolo_restart(unsigned char* source, unsigned char* dest, int length) * Filename must be a fully defined filename including the path and extension * ***************************************************************************/ -int rolo_load(char* filename) +int rolo_load(const char* filename) { int fd; unsigned long length; diff --git a/firmware/thread.c b/firmware/thread.c index 7490833863..df90c7ac2f 100644 --- a/firmware/thread.c +++ b/firmware/thread.c @@ -71,7 +71,7 @@ static inline void store_context(void* addr) * Load non-volatile context. *--------------------------------------------------------------------------- */ -static inline void load_context(void* addr) +static inline void load_context(const void* addr) { asm volatile ("mov.l @%0+,r8\n\t" "mov.l @%0+,r9\n\t" diff --git a/uisimulator/win32/kernel.c b/uisimulator/win32/kernel.c index 77ae6bffb2..b7c4af1eb1 100644 --- a/uisimulator/win32/kernel.c +++ b/uisimulator/win32/kernel.c @@ -94,7 +94,7 @@ void queue_post(struct event_queue *q, int id, void *data) set_irq_level(oldlevel); } -bool queue_empty(struct event_queue* q) +bool queue_empty(const struct event_queue* q) { return ( q->read == q->write ); } -- cgit v1.2.3