From d4e3839f0562bdd61d26c705fb3c0dbba2bc03d3 Mon Sep 17 00:00:00 2001 From: Bertrik Sikken Date: Mon, 14 Jul 2008 16:43:47 +0000 Subject: Make functions in sansapatcher static and their arguments const if possible. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18037 a1c6a512-1295-4272-9138-f99709370657 --- rbutil/sansapatcher/bin2c.c | 4 ++-- rbutil/sansapatcher/main.c | 8 ++++---- rbutil/sansapatcher/sansapatcher.c | 23 +++++++++++------------ rbutil/sansapatcher/sansapatcher.h | 8 ++++---- 4 files changed, 21 insertions(+), 22 deletions(-) (limited to 'rbutil/sansapatcher') diff --git a/rbutil/sansapatcher/bin2c.c b/rbutil/sansapatcher/bin2c.c index 85941a1de0..7b0606912b 100644 --- a/rbutil/sansapatcher/bin2c.c +++ b/rbutil/sansapatcher/bin2c.c @@ -39,7 +39,7 @@ static off_t filesize(int fd) return buf.st_size; } -static int write_cfile(unsigned char* buf, off_t len, char* cname) +static int write_cfile(const unsigned char* buf, off_t len, const char* cname) { char filename[256]; FILE* fp; @@ -72,7 +72,7 @@ static int write_cfile(unsigned char* buf, off_t len, char* cname) return 0; } -static int write_hfile(off_t len, char* cname) +static int write_hfile(off_t len, const char* cname) { char filename[256]; FILE* fp; diff --git a/rbutil/sansapatcher/main.c b/rbutil/sansapatcher/main.c index 4e95ae82b2..bfe948f922 100644 --- a/rbutil/sansapatcher/main.c +++ b/rbutil/sansapatcher/main.c @@ -50,7 +50,7 @@ enum { UPDATE_PPBL }; -void print_usage(void) +static void print_usage(void) { fprintf(stderr,"Usage: sansapatcher --scan\n"); #ifdef __WIN32__ @@ -88,10 +88,10 @@ void print_usage(void) #endif } -char* get_parttype(int pt) +static const char* get_parttype(int pt) { int i; - static char unknown[]="Unknown"; + static const char unknown[]="Unknown"; if (pt == -1) { return "HFS/HFS+"; @@ -108,7 +108,7 @@ char* get_parttype(int pt) return unknown; } -void display_partinfo(struct sansa_t* sansa) +static void display_partinfo(struct sansa_t* sansa) { int i; double sectors_per_MB = (1024.0*1024.0)/sansa->sector_size; diff --git a/rbutil/sansapatcher/sansapatcher.c b/rbutil/sansapatcher/sansapatcher.c index 504220a0d9..966cfb7033 100644 --- a/rbutil/sansapatcher/sansapatcher.c +++ b/rbutil/sansapatcher/sansapatcher.c @@ -65,14 +65,14 @@ static off_t filesize(int fd) { #define MAX_SECTOR_SIZE 2048 #define SECTOR_SIZE 512 -static inline int32_t le2int(unsigned char* buf) +static inline int32_t le2int(const unsigned char* buf) { int32_t res = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0]; return res; } -static inline uint32_t le2uint(unsigned char* buf) +static inline uint32_t le2uint(const unsigned char* buf) { uint32_t res = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0]; @@ -207,7 +207,7 @@ static unsigned int crc_tab[256]; * reached. the crc32-checksum will be * the result. */ -static unsigned int chksum_crc32 (unsigned char *block, unsigned int length) +static unsigned int chksum_crc32 (const unsigned char *block, unsigned int length) { register unsigned long crc; unsigned long i; @@ -276,7 +276,7 @@ Roger Needham:" 32. */ -void tea_decrypt(uint32_t* v0, uint32_t* v1, uint32_t* k) { +static void tea_decrypt(uint32_t* v0, uint32_t* v1, const uint32_t* k) { uint32_t sum=0xF1BBCDC8, i; /* set up */ uint32_t delta=0x9E3779B9; /* a key schedule constant */ uint32_t k0=k[0], k1=k[1], k2=k[2], k3=k[3]; /* cache key */ @@ -291,7 +291,7 @@ void tea_decrypt(uint32_t* v0, uint32_t* v1, uint32_t* k) { integers) and the key is incremented after each block */ -void tea_decrypt_buf(unsigned char* src, unsigned char* dest, size_t n, uint32_t * key) +static void tea_decrypt_buf(const unsigned char* src, unsigned char* dest, size_t n, uint32_t * key) { uint32_t v0, v1; unsigned int i; @@ -322,7 +322,7 @@ void tea_decrypt_buf(unsigned char* src, unsigned char* dest, size_t n, uint32_t } } -static int get_mi4header(unsigned char* buf,struct mi4header_t* mi4header) +static int get_mi4header(const unsigned char* buf,struct mi4header_t* mi4header) { if (memcmp(buf,"PPOS",4)!=0) return -1; @@ -337,7 +337,7 @@ static int get_mi4header(unsigned char* buf,struct mi4header_t* mi4header) return 0; } -static int set_mi4header(unsigned char* buf,struct mi4header_t* mi4header) +static int set_mi4header(unsigned char* buf,const struct mi4header_t* mi4header) { if (memcmp(buf,"PPOS",4)!=0) return -1; @@ -394,7 +394,6 @@ int is_sansa(struct sansa_t* sansa) int ppbl_length; /* Check partition layout */ - if (((sansa->pinfo[0].type != 0x06) && (sansa->pinfo[0].type != 0x0b) && (sansa->pinfo[0].type != 0x0c) && @@ -654,7 +653,7 @@ static int load_original_firmware(struct sansa_t* sansa, unsigned char* buf, str return prepare_original_firmware(sansa, buf, mi4header); } -int sansa_read_firmware(struct sansa_t* sansa, char* filename) +int sansa_read_firmware(struct sansa_t* sansa, const char* filename) { int res; int outfile; @@ -681,7 +680,7 @@ int sansa_read_firmware(struct sansa_t* sansa, char* filename) } -int sansa_add_bootloader(struct sansa_t* sansa, char* filename, int type) +int sansa_add_bootloader(struct sansa_t* sansa, const char* filename, int type) { int res; int infile = -1; /* Prevent an erroneous "may be used uninitialised" gcc warning */ @@ -825,7 +824,7 @@ void sansa_list_images(struct sansa_t* sansa) } } -int sansa_update_of(struct sansa_t* sansa, char* filename) +int sansa_update_of(struct sansa_t* sansa, const char* filename) { int n; int infile = -1; /* Prevent an erroneous "may be used uninitialised" gcc warning */ @@ -928,7 +927,7 @@ int sansa_update_of(struct sansa_t* sansa, char* filename) } /* Update the PPBL (bootloader) image in the hidden firmware partition */ -int sansa_update_ppbl(struct sansa_t* sansa, char* filename) +int sansa_update_ppbl(struct sansa_t* sansa, const char* filename) { int n; int infile = -1; /* Prevent an erroneous "may be used uninitialised" gcc warning */ diff --git a/rbutil/sansapatcher/sansapatcher.h b/rbutil/sansapatcher/sansapatcher.h index ae0ac4faa2..170646b1d8 100644 --- a/rbutil/sansapatcher/sansapatcher.h +++ b/rbutil/sansapatcher/sansapatcher.h @@ -40,11 +40,11 @@ extern unsigned char* sansa_sectorbuf; int sansa_read_partinfo(struct sansa_t* sansa, int silent); int is_sansa(struct sansa_t* sansa); int sansa_scan(struct sansa_t* sansa); -int sansa_read_firmware(struct sansa_t* sansa, char* filename); -int sansa_add_bootloader(struct sansa_t* sansa, char* filename, int type); +int sansa_read_firmware(struct sansa_t* sansa, const char* filename); +int sansa_add_bootloader(struct sansa_t* sansa, const char* filename, int type); int sansa_delete_bootloader(struct sansa_t* sansa); -int sansa_update_of(struct sansa_t* sansa,char* filename); -int sansa_update_ppbl(struct sansa_t* sansa,char* filename); +int sansa_update_of(struct sansa_t* sansa,const char* filename); +int sansa_update_ppbl(struct sansa_t* sansa,const char* filename); void sansa_list_images(struct sansa_t* sansa); #ifdef __cplusplus -- cgit