Const policed pointer arguments to functions, part 1

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4995 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Jens Arnold 2004-08-16 23:37:23 +00:00
parent 8b131ac1fb
commit c76c568b35
20 changed files with 48 additions and 45 deletions

View file

@ -112,7 +112,7 @@ struct plugin_api {
/* lcd */ /* lcd */
void (*lcd_clear_display)(void); void (*lcd_clear_display)(void);
void (*lcd_puts)(int x, int y, const unsigned char *string); 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_stop_scroll)(void);
void (*lcd_set_contrast)(int x); void (*lcd_set_contrast)(int x);
#ifdef HAVE_LCD_CHARCELLS #ifdef HAVE_LCD_CHARCELLS
@ -211,7 +211,7 @@ struct plugin_api {
/* sound */ /* sound */
void (*mpeg_sound_set)(int setting, int value); void (*mpeg_sound_set)(int setting, int value);
#ifndef SIMULATOR #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_pause)(bool play);
void (*mp3_play_stop)(void); void (*mp3_play_stop)(void);
bool (*mp3_is_playing)(void); bool (*mp3_is_playing)(void);
@ -264,7 +264,7 @@ struct plugin_api {
#endif #endif
struct user_settings* global_settings; struct user_settings* global_settings;
void (*backlight_set_timeout)(int index); 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, int (*count_mp3_frames)(int fd, int startpos, int filesize,
void (*progressfunc)(int)); void (*progressfunc)(int));
int (*create_xing_header)(int fd, int startpos, int filesize, int (*create_xing_header)(int fd, int startpos, int filesize,
@ -285,7 +285,8 @@ struct plugin_api {
int (*peak_meter_get_use_dbfs)(void); int (*peak_meter_get_use_dbfs)(void);
#endif #endif
#ifdef HAVE_LCD_BITMAP #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 #endif
void (*mpeg_flush_and_reload_tracks)(void); void (*mpeg_flush_and_reload_tracks)(void);
int (*strncasecmp)(const char *s1, const char *s2, size_t n); int (*strncasecmp)(const char *s1, const char *s2, size_t n);

View file

@ -112,11 +112,11 @@ static char lowhex(int x)
return hexchars[x & 0xf]; return hexchars[x & 0xf];
} }
static void putpacket (char *buffer) static void putpacket (const char *buffer)
{ {
register int checksum; 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 /* Special debug hack. Shut off the Rx IRQ during I/O to prevent the debug
stub from interrupting the message */ 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 */ /* convert the memory, pointed to by mem into hex, placing result in buf */
/* return a pointer to the last char put in buf (null) */ /* 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 i;
int ch; int ch;
@ -186,7 +186,7 @@ static char *mem2hex (char *mem, char *buf, int count)
return (buf); return (buf);
} }
static void debug(char *msg) static void debug(const char *msg)
{ {
debugbuf[0] = 'O'; debugbuf[0] = 'O';
@ -196,7 +196,7 @@ static void debug(char *msg)
#endif /* end of DEBUG section */ #endif /* end of DEBUG section */
#ifdef __GNUC__ #ifdef __GNUC__
void debugf(char *fmt, ...) void debugf(const char *fmt, ...)
#endif #endif
{ {
#ifdef DEBUG #ifdef DEBUG
@ -218,7 +218,7 @@ void debug_init(void)
{ {
} }
void debugf(char *fmt, ...) void debugf(const char *fmt, ...)
{ {
va_list ap; va_list ap;
va_start( ap, fmt ); va_start( ap, fmt );
@ -226,7 +226,7 @@ void debugf(char *fmt, ...)
va_end( ap ); 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_list ap;
va_start( ap, fmt ); va_start( ap, fmt );

View file

@ -530,7 +530,7 @@ void lcd_bidir_scroll(int percent)
bidir_limit = 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; struct scrollinfo* s;
int i; int i;

View file

@ -784,12 +784,12 @@ void lcd_invertpixel(int x, int y)
INVERT_PIXEL(x,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); 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; struct scrollinfo* s;
int w, h; int w, h;

View file

@ -103,7 +103,7 @@ struct font {
/* font routines*/ /* font routines*/
void font_init(void); void font_init(void);
struct font* font_load(char *path); struct font* font_load(const char *path);
struct font* font_get(int font); struct font* font_get(int font);
void font_reset(void); void font_reset(void);

View file

@ -74,7 +74,7 @@ enum {
ID3_VER_2_4 ID3_VER_2_4
}; };
bool mp3info(struct mp3entry *entry, char *filename, bool v1first); bool mp3info(struct mp3entry *entry, const char *filename, bool v1first);
char* id3_get_genre(struct mp3entry* id3); char* id3_get_genre(const struct mp3entry* id3);
#endif #endif

View file

@ -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(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_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 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 int queue_broadcast(int id, void *data);
extern void mutex_init(struct mutex *m); extern void mutex_init(struct mutex *m);

View file

@ -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_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_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(int x, int y, const unsigned char* string );
extern void lcd_puts_scroll_style(int x, int y, unsigned char* string, extern void lcd_puts_scroll_style(int x, int y, const unsigned char* string,
int style); int style);
extern void lcd_icon(int icon, bool enable); extern void lcd_icon(int icon, bool enable);
extern void lcd_stop_scroll(void); extern void lcd_stop_scroll(void);

View file

@ -51,7 +51,7 @@ void demand_irq_enable(bool on);
/* new functions, exported to plugin API */ /* new functions, exported to plugin API */
void mp3_play_init(void); 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 (*get_more)(unsigned char** start, int* size) /* callback fn */
); );
void mp3_play_pause(bool play); void mp3_play_pause(bool play);

View file

@ -77,8 +77,8 @@ int mpeg_status(void);
#if defined(HAVE_MAS3587F) || defined(SIMULATOR) #if defined(HAVE_MAS3587F) || defined(SIMULATOR)
void mpeg_init_recording(void); void mpeg_init_recording(void);
void mpeg_init_playback(void); void mpeg_init_playback(void);
void mpeg_record(char *filename); void mpeg_record(const char *filename);
void mpeg_new_file(char *filename); void mpeg_new_file(const char *filename);
void mpeg_set_recording_options(int frequency, int quality, void mpeg_set_recording_options(int frequency, int quality,
int source, int channel_mode, int source, int channel_mode,
bool editable, int prerecord_time); bool editable, int prerecord_time);

View file

@ -20,6 +20,6 @@
#ifndef __PANIC_H__ #ifndef __PANIC_H__
#define __PANIC_H__ #define __PANIC_H__
void panicf( char *fmt, ... ); void panicf( const char *fmt, ... );
#endif /* __PANIC_H__ */ #endif /* __PANIC_H__ */

View file

@ -53,9 +53,9 @@ static unsigned char *freeptr = mbuf;
static unsigned char *fileptr; static unsigned char *fileptr;
static unsigned char *eofptr; 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, static void rotleft(unsigned char *dst,
bitmap_t *src, const bitmap_t *src,
unsigned int width, unsigned int width,
unsigned int height); unsigned int height);
@ -120,7 +120,7 @@ void font_reset(void)
} }
/* read and load font into incore font structure*/ /* read and load font into incore font structure*/
struct font* font_load(char *path) struct font* font_load(const char *path)
{ {
int fd, filesize; int fd, filesize;
unsigned short maxwidth, height, ascent, pad; unsigned short maxwidth, height, ascent, pad;
@ -263,7 +263,7 @@ struct font* font_get(int font)
} }
/* convert font bitmap data inplace to rockbox format*/ /* 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; int i;
unsigned long defaultchar = pf->defaultchar - pf->firstchar; 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, * Doing it this way keeps fonts in standard formats,
* as well as keeping Rockbox hw bitmap format. * as well as keeping Rockbox hw bitmap format.
*/ */
static void rotleft(unsigned char *dst, bitmap_t *src, unsigned int width, static void rotleft(unsigned char *dst, const bitmap_t *src,
unsigned int height) unsigned int width, unsigned int height)
{ {
unsigned int i,j; unsigned int i,j;
unsigned int src_words; /* # words of input image*/ unsigned int src_words; /* # words of input image*/

View file

@ -77,7 +77,7 @@ static const char* const genres[] = {
"Duet", "Punk Rock", "Drum Solo", "A capella", "Euro-House", "Dance Hall" "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 ) if( id3->genre_string )
return 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. * 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 fd;
int v1found = false; int v1found = false;

View file

@ -126,7 +126,7 @@ void queue_post(struct event_queue *q, int id, void *data)
set_irq_level(oldlevel); set_irq_level(oldlevel);
} }
bool queue_empty(struct event_queue* q) bool queue_empty(const struct event_queue* q)
{ {
return ( q->read == q->write ); return ( q->read == q->write );
} }

View file

@ -1059,7 +1059,7 @@ void mp3_play_init(void)
mp3_reset_playtime(); 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 */ void (*get_more)(unsigned char** start, int* size) /* callback fn */
) )
{ {

View file

@ -803,7 +803,7 @@ static void transfer_end(unsigned char** ppbuf, int* psize)
wake_up_thread(); 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; struct id3tag *t = NULL;
int i; int i;
@ -938,7 +938,7 @@ static void track_change(void)
} }
#ifdef DEBUG #ifdef DEBUG
void hexdump(unsigned char *buf, int len) void hexdump(const unsigned char *buf, int len)
{ {
int i; int i;
@ -2167,7 +2167,7 @@ static void init_recording(void)
call mpeg_set_recording_options(). */ call mpeg_set_recording_options(). */
} }
void mpeg_record(char *filename) void mpeg_record(const char *filename)
{ {
mpeg_errno = 0; mpeg_errno = 0;
@ -2396,7 +2396,7 @@ void mpeg_set_recording_gain(int left, int right, bool use_mic)
0x0007); 0x0007);
} }
void mpeg_new_file(char *filename) void mpeg_new_file(const char *filename)
{ {
mpeg_errno = 0; mpeg_errno = 0;

View file

@ -31,7 +31,7 @@ static char panic_buf[128];
/* /*
* "Dude. This is pretty fucked-up, right here." * "Dude. This is pretty fucked-up, right here."
*/ */
void panicf( char *fmt, ...) void panicf( const char *fmt, ...)
{ {
va_list ap; va_list ap;

View file

@ -30,7 +30,7 @@
#define IRQ0_EDGE_TRIGGER 0x80 #define IRQ0_EDGE_TRIGGER 0x80
static void rolo_error(char *text) static void rolo_error(const char *text)
{ {
lcd_clear_display(); lcd_clear_display();
lcd_puts(0, 0, "ROLO error:"); lcd_puts(0, 0, "ROLO error:");
@ -43,8 +43,10 @@ static void rolo_error(char *text)
} }
/* these are in assembler file "descramble.S" */ /* these are in assembler file "descramble.S" */
extern unsigned short descramble(unsigned char* source, unsigned char* dest, int length); extern unsigned short descramble(const unsigned char* source,
extern void rolo_restart(unsigned char* source, unsigned char* dest, int length); 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 * 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; int fd;
unsigned long length; unsigned long length;

View file

@ -71,7 +71,7 @@ static inline void store_context(void* addr)
* Load non-volatile context. * 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" asm volatile ("mov.l @%0+,r8\n\t"
"mov.l @%0+,r9\n\t" "mov.l @%0+,r9\n\t"

View file

@ -94,7 +94,7 @@ void queue_post(struct event_queue *q, int id, void *data)
set_irq_level(oldlevel); set_irq_level(oldlevel);
} }
bool queue_empty(struct event_queue* q) bool queue_empty(const struct event_queue* q)
{ {
return ( q->read == q->write ); return ( q->read == q->write );
} }