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
diff --git a/rbutil/ipodpatcher/Makefile b/rbutil/ipodpatcher/Makefile
index a673161..f65234a 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 6d42379..e0e30db 100644
--- a/rbutil/ipodpatcher/fat32format.c
+++ b/rbutil/ipodpatcher/fat32format.c
@@ -333,8 +333,7 @@
     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 @@
     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 @@
 
     /* 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 @@
     }
 
     /* 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 78c2dbf..631a3b1 100644
--- a/rbutil/ipodpatcher/ipodio-posix.c
+++ b/rbutil/ipodpatcher/ipodio-posix.c
@@ -143,12 +143,12 @@
     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 342a06a..1bf1ac7 100644
--- a/rbutil/ipodpatcher/ipodio-win32.c
+++ b/rbutil/ipodpatcher/ipodio-win32.c
@@ -173,7 +173,7 @@
     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 @@
     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 a4625f7..2f106df 100644
--- a/rbutil/ipodpatcher/ipodio.h
+++ b/rbutil/ipodpatcher/ipodio.h
@@ -52,6 +52,9 @@
   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_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 e43fc8d..45fb24d 100644
--- a/rbutil/ipodpatcher/ipodpatcher.c
+++ b/rbutil/ipodpatcher/ipodpatcher.c
@@ -73,7 +73,7 @@
     int i;
     static char unknown[]="Unknown";
 
-    if (pt == -1) {
+    if (pt == PARTTYPE_HFS) {
         return "HFS/HFS+";
     }
 
@@ -104,41 +104,41 @@
 #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 @@
     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 @@
                  /* 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 @@
     */
     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_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 @@
 
         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 @@
 
         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 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 @@
         }
 
         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;
         }