From 0ceaa5e365b3f6dc78269ed5c4cd43df5c0144eb Mon Sep 17 00:00:00 2001 From: Jens Arnold Date: Tue, 17 Aug 2004 01:45:48 +0000 Subject: Const policed pointer arguments to functions, part 2 git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4996 a1c6a512-1295-4272-9138-f99709370657 --- firmware/drivers/ata.c | 8 ++++---- firmware/drivers/fat.c | 29 +++++++++++++++-------------- firmware/drivers/i2c.c | 2 +- firmware/drivers/lcd-player.c | 4 ++-- firmware/drivers/lcd-recorder.c | 3 ++- firmware/drivers/mas.c | 4 ++-- 6 files changed, 26 insertions(+), 24 deletions(-) (limited to 'firmware/drivers') diff --git a/firmware/drivers/ata.c b/firmware/drivers/ata.c index 663df600ca..05000b02a8 100644 --- a/firmware/drivers/ata.c +++ b/firmware/drivers/ata.c @@ -447,11 +447,11 @@ int ata_read_sectors(unsigned long start, } /* the tight loop of ata_write_sectors(), to avoid the whole in IRAM */ -static void copy_write_sectors(unsigned char* buf, +static void copy_write_sectors(const unsigned char* buf, int wordcount) __attribute__ ((section (".icode"))); -static void copy_write_sectors(unsigned char* buf, int wordcount) +static void copy_write_sectors(const unsigned char* buf, int wordcount) { #ifdef PREFER_C_WRITING @@ -566,7 +566,7 @@ static void copy_write_sectors(unsigned char* buf, int wordcount) int ata_write_sectors(unsigned long start, int count, - void* buf) + const void* buf) { int i; int ret = 0; @@ -657,7 +657,7 @@ int ata_write_sectors(unsigned long start, return ret; } -extern void ata_delayed_write(unsigned long sector, void* buf) +extern void ata_delayed_write(unsigned long sector, const void* buf) { memcpy(delayed_sector, buf, SECTOR_SIZE); delayed_sector_num = sector; diff --git a/firmware/drivers/fat.c b/firmware/drivers/fat.c index 85a9deaa8c..1b530153a5 100644 --- a/firmware/drivers/fat.c +++ b/firmware/drivers/fat.c @@ -236,7 +236,7 @@ static int update_fsinfo(void); static int first_sector_of_cluster(int cluster); static int bpb_is_sane(void); static void *cache_fat_sector(int secnum); -static int create_dos_name(unsigned char *name, unsigned char *newname); +static int create_dos_name(const unsigned char *name, unsigned char *newname); static unsigned int find_free_cluster(unsigned int start); static int transfer( unsigned int start, int count, char* buf, bool write ); @@ -811,8 +811,8 @@ static void fat_time(unsigned short* date, static int write_long_name(struct fat_file* file, unsigned int firstentry, unsigned int numentries, - unsigned char* name, - unsigned char* shortname, + const unsigned char* name, + const unsigned char* shortname, bool is_directory) { unsigned char buf[SECTOR_SIZE]; @@ -949,7 +949,7 @@ static int write_long_name(struct fat_file* file, static int add_dir_entry(struct fat_dir* dir, struct fat_file* file, - char* name, + const char* name, bool is_directory, bool dotdir) { @@ -1178,7 +1178,7 @@ unsigned char char2dos(unsigned char c) return c; } -static int create_dos_name(unsigned char *name, unsigned char *newname) +static int create_dos_name(const unsigned char *name, unsigned char *newname) { int i,j; @@ -1265,7 +1265,7 @@ static int update_short_entry( struct fat_file* file, int size, int attr ) return 0; } -static int parse_direntry(struct fat_direntry *de, unsigned char *buf) +static int parse_direntry(struct fat_direntry *de, const unsigned char *buf) { int i=0,j=0; memset(de, 0, sizeof(struct fat_direntry)); @@ -1292,7 +1292,7 @@ static int parse_direntry(struct fat_direntry *de, unsigned char *buf) int fat_open(unsigned int startcluster, struct fat_file *file, - struct fat_dir* dir) + const struct fat_dir* dir) { file->firstcluster = startcluster; file->lastcluster = startcluster; @@ -1311,7 +1311,7 @@ int fat_open(unsigned int startcluster, return 0; } -int fat_create_file(char* name, +int fat_create_file(const char* name, struct fat_file* file, struct fat_dir* dir) { @@ -1331,7 +1331,7 @@ int fat_create_file(char* name, return rc; } -int fat_create_dir(char* name, +int fat_create_dir(const char* name, struct fat_dir* newdir, struct fat_dir* dir) { @@ -1396,7 +1396,7 @@ int fat_create_dir(char* name, return rc; } -int fat_truncate(struct fat_file *file) +int fat_truncate(const struct fat_file *file) { /* truncate trailing clusters */ int next; @@ -1551,7 +1551,7 @@ int fat_remove(struct fat_file* file) } int fat_rename(struct fat_file* file, - unsigned char* newname, + const unsigned char* newname, int size, int attr) { @@ -1656,7 +1656,7 @@ static int transfer( unsigned int start, int count, char* buf, bool write ) } -int fat_readwrite( struct fat_file *file, int sectorcount, +int fat_readwrite( struct fat_file *file, int sectorcount, void* buf, bool write ) { int cluster = file->lastcluster; @@ -1801,7 +1801,7 @@ int fat_seek(struct fat_file *file, unsigned int seeksector ) } int fat_opendir(struct fat_dir *dir, unsigned int startcluster, - struct fat_dir *parent_dir) + const struct fat_dir *parent_dir) { int rc; @@ -1823,7 +1823,8 @@ int fat_opendir(struct fat_dir *dir, unsigned int startcluster, } /* convert from unicode to a single-byte charset */ -static void unicode2iso(unsigned char* unicode, unsigned char* iso, int count ) +static void unicode2iso(const unsigned char* unicode, unsigned char* iso, + int count) { int i; diff --git a/firmware/drivers/i2c.c b/firmware/drivers/i2c.c index 24ad77495d..2fc53d579f 100644 --- a/firmware/drivers/i2c.c +++ b/firmware/drivers/i2c.c @@ -198,7 +198,7 @@ unsigned char i2c_inb(int ack) return byte; } -int i2c_write(int address, unsigned char* buf, int count ) +int i2c_write(int address, const unsigned char* buf, int count ) { int i,x=0; diff --git a/firmware/drivers/lcd-player.c b/firmware/drivers/lcd-player.c index d4a523afe3..fb870f232a 100644 --- a/firmware/drivers/lcd-player.c +++ b/firmware/drivers/lcd-player.c @@ -398,7 +398,7 @@ void lcd_unlock_pattern(unsigned char pat) lcd_free_pat(pat); } -void lcd_define_pattern(int pat, char *pattern) +void lcd_define_pattern(int pat, const char *pattern) { int i; for (i=0; i<7; i++) { @@ -410,7 +410,7 @@ void lcd_define_pattern(int pat, char *pattern) } #ifndef SIMULATOR -void lcd_define_hw_pattern (int which,char *pattern,int length) +void lcd_define_hw_pattern (int which,const char *pattern,int length) { lcd_write_command(lcd_pram | which); lcd_write_data(pattern, length); diff --git a/firmware/drivers/lcd-recorder.c b/firmware/drivers/lcd-recorder.c index a8dca92b4f..c9781e77ef 100644 --- a/firmware/drivers/lcd-recorder.c +++ b/firmware/drivers/lcd-recorder.c @@ -165,7 +165,8 @@ void lcd_init (void) /* Performance function that works with an external buffer note that y and height are in 8-pixel units! */ -void lcd_blit (unsigned char* p_data, int x, int y, int width, int height, int stride) +void lcd_blit (const unsigned char* p_data, int x, int y, int width, + int height, int stride) { /* Copy display bitmap to hardware */ while (height--) diff --git a/firmware/drivers/mas.c b/firmware/drivers/mas.c index c39a46c9f2..a6fd1d1a21 100644 --- a/firmware/drivers/mas.c +++ b/firmware/drivers/mas.c @@ -112,12 +112,12 @@ int mas_readmem(int bank, int addr, unsigned long* dest, int len) } /* note: 'len' is number of 32-bit words, not number of bytes! */ -int mas_writemem(int bank, int addr, unsigned long* src, int len) +int mas_writemem(int bank, int addr, const unsigned long* src, int len) { int ret = 0; int i, j; unsigned char buf[60]; - unsigned char* ptr = (unsigned char*)src; + const unsigned char* ptr = (const unsigned char*)src; i2c_begin(); -- cgit v1.2.3