summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBertrik Sikken <bertrik@sikken.nl>2008-07-14 16:43:47 +0000
committerBertrik Sikken <bertrik@sikken.nl>2008-07-14 16:43:47 +0000
commitd4e3839f0562bdd61d26c705fb3c0dbba2bc03d3 (patch)
tree0ce8a4a05199afcfc4cbd7d79434f3d754149b86
parent3f830cb96b3b6adeea5bad5a7bd5f1f54a625ee7 (diff)
downloadrockbox-d4e3839f0562bdd61d26c705fb3c0dbba2bc03d3.tar.gz
rockbox-d4e3839f0562bdd61d26c705fb3c0dbba2bc03d3.zip
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
-rw-r--r--rbutil/sansapatcher/bin2c.c4
-rw-r--r--rbutil/sansapatcher/main.c8
-rw-r--r--rbutil/sansapatcher/sansapatcher.c23
-rw-r--r--rbutil/sansapatcher/sansapatcher.h8
4 files changed, 21 insertions, 22 deletions
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)
39 return buf.st_size; 39 return buf.st_size;
40} 40}
41 41
42static int write_cfile(unsigned char* buf, off_t len, char* cname) 42static int write_cfile(const unsigned char* buf, off_t len, const char* cname)
43{ 43{
44 char filename[256]; 44 char filename[256];
45 FILE* fp; 45 FILE* fp;
@@ -72,7 +72,7 @@ static int write_cfile(unsigned char* buf, off_t len, char* cname)
72 return 0; 72 return 0;
73} 73}
74 74
75static int write_hfile(off_t len, char* cname) 75static int write_hfile(off_t len, const char* cname)
76{ 76{
77 char filename[256]; 77 char filename[256];
78 FILE* fp; 78 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 {
50 UPDATE_PPBL 50 UPDATE_PPBL
51}; 51};
52 52
53void print_usage(void) 53static void print_usage(void)
54{ 54{
55 fprintf(stderr,"Usage: sansapatcher --scan\n"); 55 fprintf(stderr,"Usage: sansapatcher --scan\n");
56#ifdef __WIN32__ 56#ifdef __WIN32__
@@ -88,10 +88,10 @@ void print_usage(void)
88#endif 88#endif
89} 89}
90 90
91char* get_parttype(int pt) 91static const char* get_parttype(int pt)
92{ 92{
93 int i; 93 int i;
94 static char unknown[]="Unknown"; 94 static const char unknown[]="Unknown";
95 95
96 if (pt == -1) { 96 if (pt == -1) {
97 return "HFS/HFS+"; 97 return "HFS/HFS+";
@@ -108,7 +108,7 @@ char* get_parttype(int pt)
108 return unknown; 108 return unknown;
109} 109}
110 110
111void display_partinfo(struct sansa_t* sansa) 111static void display_partinfo(struct sansa_t* sansa)
112{ 112{
113 int i; 113 int i;
114 double sectors_per_MB = (1024.0*1024.0)/sansa->sector_size; 114 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) {
65#define MAX_SECTOR_SIZE 2048 65#define MAX_SECTOR_SIZE 2048
66#define SECTOR_SIZE 512 66#define SECTOR_SIZE 512
67 67
68static inline int32_t le2int(unsigned char* buf) 68static inline int32_t le2int(const unsigned char* buf)
69{ 69{
70 int32_t res = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0]; 70 int32_t res = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0];
71 71
72 return res; 72 return res;
73} 73}
74 74
75static inline uint32_t le2uint(unsigned char* buf) 75static inline uint32_t le2uint(const unsigned char* buf)
76{ 76{
77 uint32_t res = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0]; 77 uint32_t res = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0];
78 78
@@ -207,7 +207,7 @@ static unsigned int crc_tab[256];
207 * reached. the crc32-checksum will be 207 * reached. the crc32-checksum will be
208 * the result. 208 * the result.
209 */ 209 */
210static unsigned int chksum_crc32 (unsigned char *block, unsigned int length) 210static unsigned int chksum_crc32 (const unsigned char *block, unsigned int length)
211{ 211{
212 register unsigned long crc; 212 register unsigned long crc;
213 unsigned long i; 213 unsigned long i;
@@ -276,7 +276,7 @@ Roger Needham:"
276 32. 276 32.
277*/ 277*/
278 278
279void tea_decrypt(uint32_t* v0, uint32_t* v1, uint32_t* k) { 279static void tea_decrypt(uint32_t* v0, uint32_t* v1, const uint32_t* k) {
280 uint32_t sum=0xF1BBCDC8, i; /* set up */ 280 uint32_t sum=0xF1BBCDC8, i; /* set up */
281 uint32_t delta=0x9E3779B9; /* a key schedule constant */ 281 uint32_t delta=0x9E3779B9; /* a key schedule constant */
282 uint32_t k0=k[0], k1=k[1], k2=k[2], k3=k[3]; /* cache key */ 282 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) {
291 integers) and the key is incremented after each block 291 integers) and the key is incremented after each block
292 */ 292 */
293 293
294void tea_decrypt_buf(unsigned char* src, unsigned char* dest, size_t n, uint32_t * key) 294static void tea_decrypt_buf(const unsigned char* src, unsigned char* dest, size_t n, uint32_t * key)
295{ 295{
296 uint32_t v0, v1; 296 uint32_t v0, v1;
297 unsigned int i; 297 unsigned int i;
@@ -322,7 +322,7 @@ void tea_decrypt_buf(unsigned char* src, unsigned char* dest, size_t n, uint32_t
322 } 322 }
323} 323}
324 324
325static int get_mi4header(unsigned char* buf,struct mi4header_t* mi4header) 325static int get_mi4header(const unsigned char* buf,struct mi4header_t* mi4header)
326{ 326{
327 if (memcmp(buf,"PPOS",4)!=0) 327 if (memcmp(buf,"PPOS",4)!=0)
328 return -1; 328 return -1;
@@ -337,7 +337,7 @@ static int get_mi4header(unsigned char* buf,struct mi4header_t* mi4header)
337 return 0; 337 return 0;
338} 338}
339 339
340static int set_mi4header(unsigned char* buf,struct mi4header_t* mi4header) 340static int set_mi4header(unsigned char* buf,const struct mi4header_t* mi4header)
341{ 341{
342 if (memcmp(buf,"PPOS",4)!=0) 342 if (memcmp(buf,"PPOS",4)!=0)
343 return -1; 343 return -1;
@@ -394,7 +394,6 @@ int is_sansa(struct sansa_t* sansa)
394 int ppbl_length; 394 int ppbl_length;
395 395
396 /* Check partition layout */ 396 /* Check partition layout */
397
398 if (((sansa->pinfo[0].type != 0x06) && 397 if (((sansa->pinfo[0].type != 0x06) &&
399 (sansa->pinfo[0].type != 0x0b) && 398 (sansa->pinfo[0].type != 0x0b) &&
400 (sansa->pinfo[0].type != 0x0c) && 399 (sansa->pinfo[0].type != 0x0c) &&
@@ -654,7 +653,7 @@ static int load_original_firmware(struct sansa_t* sansa, unsigned char* buf, str
654 return prepare_original_firmware(sansa, buf, mi4header); 653 return prepare_original_firmware(sansa, buf, mi4header);
655} 654}
656 655
657int sansa_read_firmware(struct sansa_t* sansa, char* filename) 656int sansa_read_firmware(struct sansa_t* sansa, const char* filename)
658{ 657{
659 int res; 658 int res;
660 int outfile; 659 int outfile;
@@ -681,7 +680,7 @@ int sansa_read_firmware(struct sansa_t* sansa, char* filename)
681} 680}
682 681
683 682
684int sansa_add_bootloader(struct sansa_t* sansa, char* filename, int type) 683int sansa_add_bootloader(struct sansa_t* sansa, const char* filename, int type)
685{ 684{
686 int res; 685 int res;
687 int infile = -1; /* Prevent an erroneous "may be used uninitialised" gcc warning */ 686 int infile = -1; /* Prevent an erroneous "may be used uninitialised" gcc warning */
@@ -825,7 +824,7 @@ void sansa_list_images(struct sansa_t* sansa)
825 } 824 }
826} 825}
827 826
828int sansa_update_of(struct sansa_t* sansa, char* filename) 827int sansa_update_of(struct sansa_t* sansa, const char* filename)
829{ 828{
830 int n; 829 int n;
831 int infile = -1; /* Prevent an erroneous "may be used uninitialised" gcc warning */ 830 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)
928} 927}
929 928
930/* Update the PPBL (bootloader) image in the hidden firmware partition */ 929/* Update the PPBL (bootloader) image in the hidden firmware partition */
931int sansa_update_ppbl(struct sansa_t* sansa, char* filename) 930int sansa_update_ppbl(struct sansa_t* sansa, const char* filename)
932{ 931{
933 int n; 932 int n;
934 int infile = -1; /* Prevent an erroneous "may be used uninitialised" gcc warning */ 933 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;
40int sansa_read_partinfo(struct sansa_t* sansa, int silent); 40int sansa_read_partinfo(struct sansa_t* sansa, int silent);
41int is_sansa(struct sansa_t* sansa); 41int is_sansa(struct sansa_t* sansa);
42int sansa_scan(struct sansa_t* sansa); 42int sansa_scan(struct sansa_t* sansa);
43int sansa_read_firmware(struct sansa_t* sansa, char* filename); 43int sansa_read_firmware(struct sansa_t* sansa, const char* filename);
44int sansa_add_bootloader(struct sansa_t* sansa, char* filename, int type); 44int sansa_add_bootloader(struct sansa_t* sansa, const char* filename, int type);
45int sansa_delete_bootloader(struct sansa_t* sansa); 45int sansa_delete_bootloader(struct sansa_t* sansa);
46int sansa_update_of(struct sansa_t* sansa,char* filename); 46int sansa_update_of(struct sansa_t* sansa,const char* filename);
47int sansa_update_ppbl(struct sansa_t* sansa,char* filename); 47int sansa_update_ppbl(struct sansa_t* sansa,const char* filename);
48void sansa_list_images(struct sansa_t* sansa); 48void sansa_list_images(struct sansa_t* sansa);
49 49
50#ifdef __cplusplus 50#ifdef __cplusplus