summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Chapman <dave@dchapman.com>2007-07-29 21:19:14 +0000
committerDave Chapman <dave@dchapman.com>2007-07-29 21:19:14 +0000
commit2cc80f502e93b4f041fbc80f00cb76e7de47730d (patch)
tree7443c95c128e1cb4f58b741e6f8753f9562ca8da
parent3b1119bf27ec945a54e1d60279fc542629885c64 (diff)
downloadrockbox-2cc80f502e93b4f041fbc80f00cb76e7de47730d.tar.gz
rockbox-2cc80f502e93b4f041fbc80f00cb76e7de47730d.zip
Add -W to CFLAGS in Makefile and fix the generated warnings.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14066 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--rbutil/ipodpatcher/Makefile2
-rw-r--r--rbutil/ipodpatcher/fat32format.c10
-rw-r--r--rbutil/ipodpatcher/ipodio-posix.c4
-rw-r--r--rbutil/ipodpatcher/ipodio-win32.c4
-rw-r--r--rbutil/ipodpatcher/ipodio.h7
-rw-r--r--rbutil/ipodpatcher/ipodpatcher.c30
6 files changed, 29 insertions, 28 deletions
diff --git a/rbutil/ipodpatcher/Makefile b/rbutil/ipodpatcher/Makefile
index a67316187e..f65234a505 100644
--- a/rbutil/ipodpatcher/Makefile
+++ b/rbutil/ipodpatcher/Makefile
@@ -1,4 +1,4 @@
1CFLAGS=-Wall 1CFLAGS=-Wall -W
2 2
3BOOT_H = ipod1g2g.h ipod3g.h ipod4g.h ipodcolor.h ipodmini.h ipodmini2g.h ipodnano.h ipodvideo.h 3BOOT_H = ipod1g2g.h ipod3g.h ipod4g.h ipodcolor.h ipodmini.h ipodmini2g.h ipodnano.h ipodvideo.h
4 4
diff --git a/rbutil/ipodpatcher/fat32format.c b/rbutil/ipodpatcher/fat32format.c
index 6d42379124..e0e30db602 100644
--- a/rbutil/ipodpatcher/fat32format.c
+++ b/rbutil/ipodpatcher/fat32format.c
@@ -333,8 +333,7 @@ static void create_boot_sector(unsigned char* buf,
333 buf[511] = 0xaa; 333 buf[511] = 0xaa;
334} 334}
335 335
336static void create_fsinfo(unsigned char* buf, 336static void create_fsinfo(unsigned char* buf)
337 struct ipod_t* ipod, int partition)
338{ 337{
339 struct FAT_FSINFO* pFAT32FsInfo = (struct FAT_FSINFO*)buf; 338 struct FAT_FSINFO* pFAT32FsInfo = (struct FAT_FSINFO*)buf;
340 339
@@ -350,8 +349,7 @@ static void create_fsinfo(unsigned char* buf,
350 pFAT32FsInfo->dNxt_Free = htole32(3); 349 pFAT32FsInfo->dNxt_Free = htole32(3);
351} 350}
352 351
353static void create_firstfatsector(unsigned char* buf, 352static void create_firstfatsector(unsigned char* buf)
354 struct ipod_t* ipod, int partition)
355{ 353{
356 uint32_t* p = (uint32_t*)buf; /* We know the buffer is aligned */ 354 uint32_t* p = (uint32_t*)buf; /* We know the buffer is aligned */
357 355
@@ -481,7 +479,7 @@ int format_partition(struct ipod_t* ipod, int partition)
481 479
482 /* Create the boot sector structure */ 480 /* Create the boot sector structure */
483 create_boot_sector(sectorbuf, ipod, partition); 481 create_boot_sector(sectorbuf, ipod, partition);
484 create_fsinfo(sectorbuf + 512, ipod, partition); 482 create_fsinfo(sectorbuf + 512);
485 483
486 /* Write boot sector and fsinfo at start of partition */ 484 /* Write boot sector and fsinfo at start of partition */
487 if (ipod_seek(ipod, ipod->pinfo[partition].start * ipod->sector_size) < 0) { 485 if (ipod_seek(ipod, ipod->pinfo[partition].start * ipod->sector_size) < 0) {
@@ -504,7 +502,7 @@ int format_partition(struct ipod_t* ipod, int partition)
504 } 502 }
505 503
506 /* Create the first FAT sector */ 504 /* Create the first FAT sector */
507 create_firstfatsector(sectorbuf, ipod, partition); 505 create_firstfatsector(sectorbuf);
508 506
509 /* Write the first fat sector in the right places */ 507 /* Write the first fat sector in the right places */
510 for ( i=0; i<NumFATs; i++ ) { 508 for ( i=0; i<NumFATs; i++ ) {
diff --git a/rbutil/ipodpatcher/ipodio-posix.c b/rbutil/ipodpatcher/ipodio-posix.c
index 78c2dbf852..631a3b1b01 100644
--- a/rbutil/ipodpatcher/ipodio-posix.c
+++ b/rbutil/ipodpatcher/ipodio-posix.c
@@ -143,12 +143,12 @@ int ipod_seek(struct ipod_t* ipod, unsigned long pos)
143 return 0; 143 return 0;
144} 144}
145 145
146int ipod_read(struct ipod_t* ipod, unsigned char* buf, int nbytes) 146ssize_t ipod_read(struct ipod_t* ipod, unsigned char* buf, int nbytes)
147{ 147{
148 return read(ipod->dh, buf, nbytes); 148 return read(ipod->dh, buf, nbytes);
149} 149}
150 150
151int ipod_write(struct ipod_t* ipod, unsigned char* buf, int nbytes) 151ssize_t ipod_write(struct ipod_t* ipod, unsigned char* buf, int nbytes)
152{ 152{
153 return write(ipod->dh, buf, nbytes); 153 return write(ipod->dh, buf, nbytes);
154} 154}
diff --git a/rbutil/ipodpatcher/ipodio-win32.c b/rbutil/ipodpatcher/ipodio-win32.c
index 342a06a358..1bf1ac7613 100644
--- a/rbutil/ipodpatcher/ipodio-win32.c
+++ b/rbutil/ipodpatcher/ipodio-win32.c
@@ -173,7 +173,7 @@ int ipod_seek(struct ipod_t* ipod, unsigned long pos)
173 return 0; 173 return 0;
174} 174}
175 175
176int ipod_read(struct ipod_t* ipod, unsigned char* buf, int nbytes) 176ssize_t ipod_read(struct ipod_t* ipod, unsigned char* buf, int nbytes)
177{ 177{
178 unsigned long count; 178 unsigned long count;
179 179
@@ -185,7 +185,7 @@ int ipod_read(struct ipod_t* ipod, unsigned char* buf, int nbytes)
185 return count; 185 return count;
186} 186}
187 187
188int ipod_write(struct ipod_t* ipod, unsigned char* buf, int nbytes) 188ssize_t ipod_write(struct ipod_t* ipod, unsigned char* buf, int nbytes)
189{ 189{
190 unsigned long count; 190 unsigned long count;
191 191
diff --git a/rbutil/ipodpatcher/ipodio.h b/rbutil/ipodpatcher/ipodio.h
index a4625f7bc7..2f106df521 100644
--- a/rbutil/ipodpatcher/ipodio.h
+++ b/rbutil/ipodpatcher/ipodio.h
@@ -52,6 +52,9 @@ struct ipod_directory_t {
52 uint32_t loadAddr; 52 uint32_t loadAddr;
53}; 53};
54 54
55/* A fake partition type - DOS partition tables can't include HFS partitions */
56#define PARTTYPE_HFS 0xffff
57
55struct partinfo_t { 58struct partinfo_t {
56 uint32_t start; /* first sector (LBA) */ 59 uint32_t start; /* first sector (LBA) */
57 uint32_t size; /* number of sectors */ 60 uint32_t size; /* number of sectors */
@@ -86,8 +89,8 @@ int ipod_open(struct ipod_t* ipod, int silent);
86int ipod_reopen_rw(struct ipod_t* ipod); 89int ipod_reopen_rw(struct ipod_t* ipod);
87int ipod_close(struct ipod_t* ipod); 90int ipod_close(struct ipod_t* ipod);
88int ipod_seek(struct ipod_t* ipod, unsigned long pos); 91int ipod_seek(struct ipod_t* ipod, unsigned long pos);
89int ipod_read(struct ipod_t* ipod, unsigned char* buf, int nbytes); 92ssize_t ipod_read(struct ipod_t* ipod, unsigned char* buf, int nbytes);
90int ipod_write(struct ipod_t* ipod, unsigned char* buf, int nbytes); 93ssize_t ipod_write(struct ipod_t* ipod, unsigned char* buf, int nbytes);
91int ipod_alloc_buffer(unsigned char** sectorbuf, int bufsize); 94int ipod_alloc_buffer(unsigned char** sectorbuf, int bufsize);
92 95
93/* In fat32format.c */ 96/* In fat32format.c */
diff --git a/rbutil/ipodpatcher/ipodpatcher.c b/rbutil/ipodpatcher/ipodpatcher.c
index e43fc8d156..45fb24d4fc 100644
--- a/rbutil/ipodpatcher/ipodpatcher.c
+++ b/rbutil/ipodpatcher/ipodpatcher.c
@@ -73,7 +73,7 @@ char* get_parttype(int pt)
73 int i; 73 int i;
74 static char unknown[]="Unknown"; 74 static char unknown[]="Unknown";
75 75
76 if (pt == -1) { 76 if (pt == PARTTYPE_HFS) {
77 return "HFS/HFS+"; 77 return "HFS/HFS+";
78 } 78 }
79 79
@@ -104,41 +104,41 @@ off_t filesize(int fd) {
104#define MAX_SECTOR_SIZE 2048 104#define MAX_SECTOR_SIZE 2048
105#define SECTOR_SIZE 512 105#define SECTOR_SIZE 512
106 106
107unsigned short static inline le2ushort(unsigned char* buf) 107static inline unsigned short le2ushort(unsigned char* buf)
108{ 108{
109 unsigned short res = (buf[1] << 8) | buf[0]; 109 unsigned short res = (buf[1] << 8) | buf[0];
110 110
111 return res; 111 return res;
112} 112}
113 113
114int static inline le2int(unsigned char* buf) 114static inline int le2int(unsigned char* buf)
115{ 115{
116 int32_t res = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0]; 116 int32_t res = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0];
117 117
118 return res; 118 return res;
119} 119}
120 120
121int static inline be2int(unsigned char* buf) 121static inline int be2int(unsigned char* buf)
122{ 122{
123 int32_t res = (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3]; 123 int32_t res = (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3];
124 124
125 return res; 125 return res;
126} 126}
127 127
128int static inline getint16le(char* buf) 128static inline int getint16le(char* buf)
129{ 129{
130 int16_t res = (buf[1] << 8) | buf[0]; 130 int16_t res = (buf[1] << 8) | buf[0];
131 131
132 return res; 132 return res;
133} 133}
134 134
135void static inline short2le(unsigned short val, unsigned char* addr) 135static inline void short2le(unsigned short val, unsigned char* addr)
136{ 136{
137 addr[0] = val & 0xFF; 137 addr[0] = val & 0xFF;
138 addr[1] = (val >> 8) & 0xff; 138 addr[1] = (val >> 8) & 0xff;
139} 139}
140 140
141void static inline int2le(unsigned int val, unsigned char* addr) 141static inline void int2le(unsigned int val, unsigned char* addr)
142{ 142{
143 addr[0] = val & 0xFF; 143 addr[0] = val & 0xFF;
144 addr[1] = (val >> 8) & 0xff; 144 addr[1] = (val >> 8) & 0xff;
@@ -146,7 +146,7 @@ void static inline int2le(unsigned int val, unsigned char* addr)
146 addr[3] = (val >> 24) & 0xff; 146 addr[3] = (val >> 24) & 0xff;
147} 147}
148 148
149void int2be(unsigned int val, unsigned char* addr) 149static inline void int2be(unsigned int val, unsigned char* addr)
150{ 150{
151 addr[0] = (val >> 24) & 0xff; 151 addr[0] = (val >> 24) & 0xff;
152 addr[1] = (val >> 16) & 0xff; 152 addr[1] = (val >> 16) & 0xff;
@@ -245,7 +245,7 @@ int read_partinfo(struct ipod_t* ipod, int silent)
245 /* A HFS partition */ 245 /* A HFS partition */
246 ipod->pinfo[i].start = pmPyPartStart; 246 ipod->pinfo[i].start = pmPyPartStart;
247 ipod->pinfo[i].size = pmPartBlkCnt; 247 ipod->pinfo[i].size = pmPartBlkCnt;
248 ipod->pinfo[i].type = -1; 248 ipod->pinfo[i].type = PARTTYPE_HFS;
249 i++; 249 i++;
250 } 250 }
251 251
@@ -262,7 +262,7 @@ int read_partinfo(struct ipod_t* ipod, int silent)
262 */ 262 */
263 if ((ipod->pinfo[0].type != 0) || (ipod->pinfo[0].size == 0) || 263 if ((ipod->pinfo[0].type != 0) || (ipod->pinfo[0].size == 0) ||
264 ((ipod->pinfo[1].type != 0xb) && (ipod->pinfo[1].type != 0xc) && 264 ((ipod->pinfo[1].type != 0xb) && (ipod->pinfo[1].type != 0xc) &&
265 (ipod->pinfo[1].type != -1))) { 265 (ipod->pinfo[1].type != PARTTYPE_HFS))) {
266 if (!silent) fprintf(stderr,"[ERR] Partition layout is not an ipod\n"); 266 if (!silent) fprintf(stderr,"[ERR] Partition layout is not an ipod\n");
267 return -1; 267 return -1;
268 } 268 }
@@ -274,7 +274,7 @@ int read_partinfo(struct ipod_t* ipod, int silent)
274int read_partition(struct ipod_t* ipod, int outfile) 274int read_partition(struct ipod_t* ipod, int outfile)
275{ 275{
276 int res; 276 int res;
277 unsigned long n; 277 ssize_t n;
278 int bytesleft; 278 int bytesleft;
279 int chunksize; 279 int chunksize;
280 int count = ipod->pinfo[0].size; 280 int count = ipod->pinfo[0].size;
@@ -301,7 +301,7 @@ int read_partition(struct ipod_t* ipod, int outfile)
301 301
302 if (n < chunksize) { 302 if (n < chunksize) {
303 fprintf(stderr, 303 fprintf(stderr,
304 "[ERR] Short read in disk_read() - requested %d, got %lu\n", 304 "[ERR] Short read in disk_read() - requested %d, got %d\n",
305 chunksize,n); 305 chunksize,n);
306 return -1; 306 return -1;
307 } 307 }
@@ -317,7 +317,7 @@ int read_partition(struct ipod_t* ipod, int outfile)
317 317
318 if (res != n) { 318 if (res != n) {
319 fprintf(stderr, 319 fprintf(stderr,
320 "Short write - requested %lu, received %d - aborting.\n",n,res); 320 "Short write - requested %d, received %d - aborting.\n",n,res);
321 return -1; 321 return -1;
322 } 322 }
323 } 323 }
@@ -328,7 +328,7 @@ int read_partition(struct ipod_t* ipod, int outfile)
328 328
329int write_partition(struct ipod_t* ipod, int infile) 329int write_partition(struct ipod_t* ipod, int infile)
330{ 330{
331 unsigned long res; 331 ssize_t res;
332 int n; 332 int n;
333 int bytesread; 333 int bytesread;
334 int byteswritten = 0; 334 int byteswritten = 0;
@@ -370,7 +370,7 @@ int write_partition(struct ipod_t* ipod, int infile)
370 } 370 }
371 371
372 if (res != n) { 372 if (res != n) {
373 fprintf(stderr,"[ERR] Short write - requested %d, received %lu - aborting.\n",n,res); 373 fprintf(stderr,"[ERR] Short write - requested %d, received %d - aborting.\n",n,res);
374 return -1; 374 return -1;
375 } 375 }
376 376