1
0
Fork 0
forked from len0rd/rockbox

Const policed pointer arguments to functions, part 2

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4996 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Jens Arnold 2004-08-17 01:45:48 +00:00
parent c76c568b35
commit 0ceaa5e365
17 changed files with 55 additions and 51 deletions

View file

@ -116,7 +116,7 @@ struct plugin_api {
void (*lcd_stop_scroll)(void);
void (*lcd_set_contrast)(int x);
#ifdef HAVE_LCD_CHARCELLS
void (*lcd_define_pattern)(int which,char *pattern);
void (*lcd_define_pattern)(int which,const char *pattern);
unsigned char (*lcd_get_locked_pattern)(void);
void (*lcd_unlock_pattern)(unsigned char pat);
void (*lcd_putc)(int x, int y, unsigned short ch);
@ -145,7 +145,8 @@ struct plugin_api {
int min_shown, int max_shown, int orientation);
void (*checkbox)(int x, int y, int width, int height, bool checked);
unsigned char* lcd_framebuffer;
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);
#ifndef SIMULATOR
void (*lcd_roll)(int pixels);
#endif
@ -235,7 +236,7 @@ struct plugin_api {
/* MAS communication */
#ifndef SIMULATOR
int (*mas_readmem)(int bank, int addr, unsigned long* dest, int len);
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 (*mas_readreg)(int reg);
int (*mas_writereg)(int reg, unsigned int val);
#ifdef HAVE_MAS3587F
@ -251,7 +252,7 @@ struct plugin_api {
int(*compar)(const void *, const void *));
int (*kbd_input)(char* buffer, int buflen);
struct tm* (*get_time)(void);
int (*set_time)(struct tm *tm);
int (*set_time)(const struct tm *tm);
void* (*plugin_get_buffer)(int* buffer_size);
void* (*plugin_get_mp3_buffer)(int* buffer_size);
#ifndef SIMULATOR

View file

@ -27,7 +27,7 @@
static struct tm tm;
#endif
bool valid_time(struct tm *tm)
bool valid_time(const struct tm *tm)
{
if (tm->tm_hour < 0 || tm->tm_hour > 23 ||
tm->tm_sec < 0 || tm->tm_sec > 59 ||
@ -81,7 +81,7 @@ struct tm *get_time(void)
#endif
}
int set_time(struct tm *tm)
int set_time(const struct tm *tm)
{
#ifdef HAVE_RTC
int rc;

View file

@ -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;

View file

@ -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)
{
@ -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;

View file

@ -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;

View file

@ -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);

View file

@ -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--)

View file

@ -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();

View file

@ -42,8 +42,8 @@ extern int ata_hard_reset(void);
extern int ata_soft_reset(void);
extern int ata_init(void);
extern int ata_read_sectors(unsigned long start, int count, void* buf);
extern int ata_write_sectors(unsigned long start, int count, void* buf);
extern void ata_delayed_write(unsigned long sector, void* buf);
extern int ata_write_sectors(unsigned long start, int count, const void* buf);
extern void ata_delayed_write(unsigned long sector, const void* buf);
extern void ata_flush(void);
extern void ata_spin(void);
extern unsigned short* ata_get_identify(void);

View file

@ -72,14 +72,14 @@ struct fat_dir
extern int fat_mount(int startsector);
extern void fat_size(unsigned int* size, unsigned int* free);
extern void fat_recalc_free(void);
extern int fat_create_dir(char* name,
extern int fat_create_dir(const char* name,
struct fat_dir* newdir,
struct fat_dir* dir);
extern int fat_startsector(void);
extern int fat_open(unsigned int cluster,
struct fat_file* ent,
struct fat_dir* dir);
extern int fat_create_file(char* name,
const struct fat_dir* dir);
extern int fat_create_file(const char* name,
struct fat_file* ent,
struct fat_dir* dir);
extern int fat_readwrite(struct fat_file *ent, int sectorcount,
@ -87,13 +87,13 @@ extern int fat_readwrite(struct fat_file *ent, int sectorcount,
extern int fat_closewrite(struct fat_file *ent, int size, int attr);
extern int fat_seek(struct fat_file *ent, unsigned int sector );
extern int fat_remove(struct fat_file *ent);
extern int fat_truncate(struct fat_file *ent);
extern int fat_truncate(const struct fat_file *ent);
extern int fat_rename(struct fat_file* file,
unsigned char* newname,
const unsigned char* newname,
int size, int attr);
extern int fat_opendir(struct fat_dir *ent, unsigned int currdir,
struct fat_dir *parent_dir);
const struct fat_dir *parent_dir);
extern int fat_getnext(struct fat_dir *ent, struct fat_direntry *entry);
extern int fat_get_cluster_size(void);

View file

@ -44,13 +44,14 @@ extern void lcd_scroll_speed( int speed );
extern void lcd_scroll_delay( int ms );
extern void lcd_set_contrast(int val);
extern void lcd_write_command( int byte );
extern void lcd_write_data( unsigned char* p_bytes, int count );
extern void lcd_write_data( const unsigned char* p_bytes, int count );
extern int lcd_default_contrast(void);
#if defined(SIMULATOR) || defined(HAVE_LCD_BITMAP)
extern void lcd_update(void);
/* performance function */
extern void lcd_blit (unsigned char* p_data, int x, int y, int width, int height, int stride);
extern void lcd_blit (const unsigned char* p_data, int x, int y, int width,
int height, int stride);
/* update a fraction of the screen */
extern void lcd_update_rect(int x, int y, int width, int height);
@ -88,8 +89,8 @@ enum
ICON_PARAM
};
extern void lcd_define_hw_pattern (int which,char *pattern,int length);
extern void lcd_define_pattern (int which,char *pattern);
extern void lcd_define_hw_pattern (int which,const char *pattern,int length);
extern void lcd_define_pattern (int which,const char *pattern);
extern void lcd_double_height (bool on);
#define JUMP_SCROLL_ALWAYS 5
extern void lcd_jump_scroll (int mode); /* 0=off, 1=once, ..., ALWAYS */

View file

@ -101,7 +101,7 @@
int mas_default_read(unsigned short *buf);
int mas_run(unsigned short address);
int mas_readmem(int bank, int addr, unsigned long* dest, int len);
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 mas_readreg(int reg);
int mas_writereg(int reg, unsigned int val);
void mas_reset(void);

View file

@ -25,7 +25,7 @@
#include "time.h"
struct tm *get_time(void);
int set_time(struct tm *tm);
bool valid_time(struct tm *tm);
int set_time(const struct tm *tm);
bool valid_time(const struct tm *tm);
#endif /* _TIMEFUNCS_H_ */

View file

@ -30,7 +30,7 @@
#include "lcd-x11.h"
#endif
void lcd_blit(unsigned char* p_data, int x, int y, int width, int height,
void lcd_blit(const unsigned char* p_data, int x, int y, int width, int height,
int stride)
{
(void)p_data;

View file

@ -222,7 +222,7 @@ void lcd_double_height(bool on)
lcd_update();
}
void lcd_define_hw_pattern(int which, char *pattern, int length)
void lcd_define_hw_pattern(int which, const char *pattern, int length)
{
int i, j;
int pat = which / 8;

View file

@ -4,5 +4,5 @@
/* struct tm defined */
struct tm *get_time(void);
int set_time(struct tm *tm);
bool valid_time(struct tm *tm);
int set_time(const struct tm *tm);
bool valid_time(const struct tm *tm);

View file

@ -3,5 +3,5 @@
/* struct tm defined */
struct tm *get_time(void);
int set_time(struct tm *tm);
bool valid_time(struct tm *tm);
int set_time(const struct tm *tm);
bool valid_time(const struct tm *tm);