summaryrefslogtreecommitdiffstats
path: root/rbutil/ipodpatcher
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 /rbutil/ipodpatcher
parent3b1119bf27ec945a54e1d60279fc542629885c64 (diff)
downloadrockbox-2cc80f502e93b4f041fbc80f00cb76e7de47730d.tar.gz
rockbox-2cc80f502e93b4f041fbc80f00cb76e7de47730d.tar.bz2
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
Diffstat (limited to 'rbutil/ipodpatcher')
-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 @@
-CFLAGS=-Wall
+CFLAGS=-Wall -W
BOOT_H = ipod1g2g.h ipod3g.h ipod4g.h ipodcolor.h ipodmini.h ipodmini2g.h ipodnano.h ipodvideo.h
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,
buf[511] = 0xaa;
}
-static void create_fsinfo(unsigned char* buf,
- struct ipod_t* ipod, int partition)
+static void create_fsinfo(unsigned char* buf)
{
struct FAT_FSINFO* pFAT32FsInfo = (struct FAT_FSINFO*)buf;
@@ -350,8 +349,7 @@ static void create_fsinfo(unsigned char* buf,
pFAT32FsInfo->dNxt_Free = htole32(3);
}
-static void create_firstfatsector(unsigned char* buf,
- struct ipod_t* ipod, int partition)
+static void create_firstfatsector(unsigned char* buf)
{
uint32_t* p = (uint32_t*)buf; /* We know the buffer is aligned */
@@ -481,7 +479,7 @@ int format_partition(struct ipod_t* ipod, int partition)
/* Create the boot sector structure */
create_boot_sector(sectorbuf, ipod, partition);
- create_fsinfo(sectorbuf + 512, ipod, partition);
+ create_fsinfo(sectorbuf + 512);
/* Write boot sector and fsinfo at start of partition */
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)
}
/* Create the first FAT sector */
- create_firstfatsector(sectorbuf, ipod, partition);
+ create_firstfatsector(sectorbuf);
/* Write the first fat sector in the right places */
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)
return 0;
}
-int ipod_read(struct ipod_t* ipod, unsigned char* buf, int nbytes)
+ssize_t ipod_read(struct ipod_t* ipod, unsigned char* buf, int nbytes)
{
return read(ipod->dh, buf, nbytes);
}
-int ipod_write(struct ipod_t* ipod, unsigned char* buf, int nbytes)
+ssize_t ipod_write(struct ipod_t* ipod, unsigned char* buf, int nbytes)
{
return write(ipod->dh, buf, nbytes);
}
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)
return 0;
}
-int ipod_read(struct ipod_t* ipod, unsigned char* buf, int nbytes)
+ssize_t ipod_read(struct ipod_t* ipod, unsigned char* buf, int nbytes)
{
unsigned long count;
@@ -185,7 +185,7 @@ int ipod_read(struct ipod_t* ipod, unsigned char* buf, int nbytes)
return count;
}
-int ipod_write(struct ipod_t* ipod, unsigned char* buf, int nbytes)
+ssize_t ipod_write(struct ipod_t* ipod, unsigned char* buf, int nbytes)
{
unsigned long count;
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 {
uint32_t loadAddr;
};
+/* A fake partition type - DOS partition tables can't include HFS partitions */
+#define PARTTYPE_HFS 0xffff
+
struct partinfo_t {
uint32_t start; /* first sector (LBA) */
uint32_t size; /* number of sectors */
@@ -86,8 +89,8 @@ int ipod_open(struct ipod_t* ipod, int silent);
int ipod_reopen_rw(struct ipod_t* ipod);
int ipod_close(struct ipod_t* ipod);
int ipod_seek(struct ipod_t* ipod, unsigned long pos);
-int ipod_read(struct ipod_t* ipod, unsigned char* buf, int nbytes);
-int ipod_write(struct ipod_t* ipod, unsigned char* buf, int nbytes);
+ssize_t ipod_read(struct ipod_t* ipod, unsigned char* buf, int nbytes);
+ssize_t ipod_write(struct ipod_t* ipod, unsigned char* buf, int nbytes);
int ipod_alloc_buffer(unsigned char** sectorbuf, int bufsize);
/* 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)
int i;
static char unknown[]="Unknown";
- if (pt == -1) {
+ if (pt == PARTTYPE_HFS) {
return "HFS/HFS+";
}
@@ -104,41 +104,41 @@ off_t filesize(int fd) {
#define MAX_SECTOR_SIZE 2048
#define SECTOR_SIZE 512
-unsigned short static inline le2ushort(unsigned char* buf)
+static inline unsigned short le2ushort(unsigned char* buf)
{
unsigned short res = (buf[1] << 8) | buf[0];
return res;
}
-int static inline le2int(unsigned char* buf)
+static inline int le2int(unsigned char* buf)
{
int32_t res = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0];
return res;
}
-int static inline be2int(unsigned char* buf)
+static inline int be2int(unsigned char* buf)
{
int32_t res = (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3];
return res;
}
-int static inline getint16le(char* buf)
+static inline int getint16le(char* buf)
{
int16_t res = (buf[1] << 8) | buf[0];
return res;
}
-void static inline short2le(unsigned short val, unsigned char* addr)
+static inline void short2le(unsigned short val, unsigned char* addr)
{
addr[0] = val & 0xFF;
addr[1] = (val >> 8) & 0xff;
}
-void static inline int2le(unsigned int val, unsigned char* addr)
+static inline void int2le(unsigned int val, unsigned char* addr)
{
addr[0] = val & 0xFF;
addr[1] = (val >> 8) & 0xff;
@@ -146,7 +146,7 @@ void static inline int2le(unsigned int val, unsigned char* addr)
addr[3] = (val >> 24) & 0xff;
}
-void int2be(unsigned int val, unsigned char* addr)
+static inline void int2be(unsigned int val, unsigned char* addr)
{
addr[0] = (val >> 24) & 0xff;
addr[1] = (val >> 16) & 0xff;
@@ -245,7 +245,7 @@ int read_partinfo(struct ipod_t* ipod, int silent)
/* A HFS partition */
ipod->pinfo[i].start = pmPyPartStart;
ipod->pinfo[i].size = pmPartBlkCnt;
- ipod->pinfo[i].type = -1;
+ ipod->pinfo[i].type = PARTTYPE_HFS;
i++;
}
@@ -262,7 +262,7 @@ int read_partinfo(struct ipod_t* ipod, int silent)
*/
if ((ipod->pinfo[0].type != 0) || (ipod->pinfo[0].size == 0) ||
((ipod->pinfo[1].type != 0xb) && (ipod->pinfo[1].type != 0xc) &&
- (ipod->pinfo[1].type != -1))) {
+ (ipod->pinfo[1].type != PARTTYPE_HFS))) {
if (!silent) fprintf(stderr,"[ERR] Partition layout is not an ipod\n");
return -1;
}
@@ -274,7 +274,7 @@ int read_partinfo(struct ipod_t* ipod, int silent)
int read_partition(struct ipod_t* ipod, int outfile)
{
int res;
- unsigned long n;
+ ssize_t n;
int bytesleft;
int chunksize;
int count = ipod->pinfo[0].size;
@@ -301,7 +301,7 @@ int read_partition(struct ipod_t* ipod, int outfile)
if (n < chunksize) {
fprintf(stderr,
- "[ERR] Short read in disk_read() - requested %d, got %lu\n",
+ "[ERR] Short read in disk_read() - requested %d, got %d\n",
chunksize,n);
return -1;
}
@@ -317,7 +317,7 @@ int read_partition(struct ipod_t* ipod, int outfile)
if (res != n) {
fprintf(stderr,
- "Short write - requested %lu, received %d - aborting.\n",n,res);
+ "Short write - requested %d, received %d - aborting.\n",n,res);
return -1;
}
}
@@ -328,7 +328,7 @@ int read_partition(struct ipod_t* ipod, int outfile)
int write_partition(struct ipod_t* ipod, int infile)
{
- unsigned long res;
+ ssize_t res;
int n;
int bytesread;
int byteswritten = 0;
@@ -370,7 +370,7 @@ int write_partition(struct ipod_t* ipod, int infile)
}
if (res != n) {
- fprintf(stderr,"[ERR] Short write - requested %d, received %lu - aborting.\n",n,res);
+ fprintf(stderr,"[ERR] Short write - requested %d, received %d - aborting.\n",n,res);
return -1;
}