summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2004-08-16 23:37:23 +0000
committerJens Arnold <amiconn@rockbox.org>2004-08-16 23:37:23 +0000
commitc76c568b351d37c485f78cd185b2d52d54fe7a34 (patch)
treeca65a23113fb82941855e44b5dcc3a0896885882
parent8b131ac1fb04cb96094044dca7423a8d1da7f690 (diff)
downloadrockbox-c76c568b351d37c485f78cd185b2d52d54fe7a34.zip
rockbox-c76c568b351d37c485f78cd185b2d52d54fe7a34.tar.gz
rockbox-c76c568b351d37c485f78cd185b2d52d54fe7a34.tar.bz2
rockbox-c76c568b351d37c485f78cd185b2d52d54fe7a34.tar.xz
Const policed pointer arguments to functions, part 1
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4995 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/plugin.h9
-rw-r--r--firmware/debug.c14
-rw-r--r--firmware/drivers/lcd-player.c2
-rw-r--r--firmware/drivers/lcd-recorder.c4
-rw-r--r--firmware/export/font.h2
-rw-r--r--firmware/export/id3.h4
-rw-r--r--firmware/export/kernel.h2
-rw-r--r--firmware/export/lcd.h4
-rw-r--r--firmware/export/mp3_playback.h2
-rw-r--r--firmware/export/mpeg.h4
-rw-r--r--firmware/export/panic.h2
-rw-r--r--firmware/font.c12
-rw-r--r--firmware/id3.c4
-rw-r--r--firmware/kernel.c2
-rw-r--r--firmware/mp3_playback.c2
-rw-r--r--firmware/mpeg.c8
-rw-r--r--firmware/panic.c2
-rw-r--r--firmware/rolo.c10
-rw-r--r--firmware/thread.c2
-rw-r--r--uisimulator/win32/kernel.c2
20 files changed, 48 insertions, 45 deletions
diff --git a/apps/plugin.h b/apps/plugin.h
index 8ee2534..d44aa7d 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 977ece3..6a30c60 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 c948f49..d4a523a 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 42cf016..a8dca92 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 f2f83e5..14a683a 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 10f8002..8a79cb0 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 6e11bae..97994c4 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 6a7f8cf..2a8a7ff 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 9eb1d88..12ef734 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 bf16a2a..3088dc5 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 585f827..fd63687 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 f334908..343dd0b 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 0a08fa0..4297c8b 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 ec2c149..2cb87cc 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 1d4f77b..8159c45 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 c6afbd8..bfcdfc1 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 df8afdf..147ee62 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 c5cfc5d..d78078c 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 7490833..df90c7a 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 77ae6bf..b7c4af1 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 );
}