forked from len0rd/rockbox
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
This commit is contained in:
parent
3b1119bf27
commit
2cc80f502e
6 changed files with 29 additions and 28 deletions
|
@ -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
|
BOOT_H = ipod1g2g.h ipod3g.h ipod4g.h ipodcolor.h ipodmini.h ipodmini2g.h ipodnano.h ipodvideo.h
|
||||||
|
|
||||||
|
|
|
@ -333,8 +333,7 @@ static void create_boot_sector(unsigned char* buf,
|
||||||
buf[511] = 0xaa;
|
buf[511] = 0xaa;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void create_fsinfo(unsigned char* buf,
|
static void create_fsinfo(unsigned char* buf)
|
||||||
struct ipod_t* ipod, int partition)
|
|
||||||
{
|
{
|
||||||
struct FAT_FSINFO* pFAT32FsInfo = (struct FAT_FSINFO*)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);
|
pFAT32FsInfo->dNxt_Free = htole32(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void create_firstfatsector(unsigned char* buf,
|
static void create_firstfatsector(unsigned char* buf)
|
||||||
struct ipod_t* ipod, int partition)
|
|
||||||
{
|
{
|
||||||
uint32_t* p = (uint32_t*)buf; /* We know the buffer is aligned */
|
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 the boot sector structure */
|
||||||
create_boot_sector(sectorbuf, ipod, partition);
|
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 */
|
/* Write boot sector and fsinfo at start of partition */
|
||||||
if (ipod_seek(ipod, ipod->pinfo[partition].start * ipod->sector_size) < 0) {
|
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 the first FAT sector */
|
||||||
create_firstfatsector(sectorbuf, ipod, partition);
|
create_firstfatsector(sectorbuf);
|
||||||
|
|
||||||
/* Write the first fat sector in the right places */
|
/* Write the first fat sector in the right places */
|
||||||
for ( i=0; i<NumFATs; i++ ) {
|
for ( i=0; i<NumFATs; i++ ) {
|
||||||
|
|
|
@ -143,12 +143,12 @@ int ipod_seek(struct ipod_t* ipod, unsigned long pos)
|
||||||
return 0;
|
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);
|
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);
|
return write(ipod->dh, buf, nbytes);
|
||||||
}
|
}
|
||||||
|
|
|
@ -173,7 +173,7 @@ int ipod_seek(struct ipod_t* ipod, unsigned long pos)
|
||||||
return 0;
|
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;
|
unsigned long count;
|
||||||
|
|
||||||
|
@ -185,7 +185,7 @@ int ipod_read(struct ipod_t* ipod, unsigned char* buf, int nbytes)
|
||||||
return count;
|
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;
|
unsigned long count;
|
||||||
|
|
||||||
|
|
|
@ -52,6 +52,9 @@ struct ipod_directory_t {
|
||||||
uint32_t loadAddr;
|
uint32_t loadAddr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* A fake partition type - DOS partition tables can't include HFS partitions */
|
||||||
|
#define PARTTYPE_HFS 0xffff
|
||||||
|
|
||||||
struct partinfo_t {
|
struct partinfo_t {
|
||||||
uint32_t start; /* first sector (LBA) */
|
uint32_t start; /* first sector (LBA) */
|
||||||
uint32_t size; /* number of sectors */
|
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_reopen_rw(struct ipod_t* ipod);
|
||||||
int ipod_close(struct ipod_t* ipod);
|
int ipod_close(struct ipod_t* ipod);
|
||||||
int ipod_seek(struct ipod_t* ipod, unsigned long pos);
|
int ipod_seek(struct ipod_t* ipod, unsigned long pos);
|
||||||
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);
|
||||||
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);
|
||||||
int ipod_alloc_buffer(unsigned char** sectorbuf, int bufsize);
|
int ipod_alloc_buffer(unsigned char** sectorbuf, int bufsize);
|
||||||
|
|
||||||
/* In fat32format.c */
|
/* In fat32format.c */
|
||||||
|
|
|
@ -73,7 +73,7 @@ char* get_parttype(int pt)
|
||||||
int i;
|
int i;
|
||||||
static char unknown[]="Unknown";
|
static char unknown[]="Unknown";
|
||||||
|
|
||||||
if (pt == -1) {
|
if (pt == PARTTYPE_HFS) {
|
||||||
return "HFS/HFS+";
|
return "HFS/HFS+";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,41 +104,41 @@ off_t filesize(int fd) {
|
||||||
#define MAX_SECTOR_SIZE 2048
|
#define MAX_SECTOR_SIZE 2048
|
||||||
#define SECTOR_SIZE 512
|
#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];
|
unsigned short res = (buf[1] << 8) | buf[0];
|
||||||
|
|
||||||
return res;
|
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];
|
int32_t res = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0];
|
||||||
|
|
||||||
return res;
|
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];
|
int32_t res = (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3];
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
int static inline getint16le(char* buf)
|
static inline int getint16le(char* buf)
|
||||||
{
|
{
|
||||||
int16_t res = (buf[1] << 8) | buf[0];
|
int16_t res = (buf[1] << 8) | buf[0];
|
||||||
|
|
||||||
return res;
|
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[0] = val & 0xFF;
|
||||||
addr[1] = (val >> 8) & 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[0] = val & 0xFF;
|
||||||
addr[1] = (val >> 8) & 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;
|
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[0] = (val >> 24) & 0xff;
|
||||||
addr[1] = (val >> 16) & 0xff;
|
addr[1] = (val >> 16) & 0xff;
|
||||||
|
@ -245,7 +245,7 @@ int read_partinfo(struct ipod_t* ipod, int silent)
|
||||||
/* A HFS partition */
|
/* A HFS partition */
|
||||||
ipod->pinfo[i].start = pmPyPartStart;
|
ipod->pinfo[i].start = pmPyPartStart;
|
||||||
ipod->pinfo[i].size = pmPartBlkCnt;
|
ipod->pinfo[i].size = pmPartBlkCnt;
|
||||||
ipod->pinfo[i].type = -1;
|
ipod->pinfo[i].type = PARTTYPE_HFS;
|
||||||
i++;
|
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) ||
|
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 != 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");
|
if (!silent) fprintf(stderr,"[ERR] Partition layout is not an ipod\n");
|
||||||
return -1;
|
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 read_partition(struct ipod_t* ipod, int outfile)
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
unsigned long n;
|
ssize_t n;
|
||||||
int bytesleft;
|
int bytesleft;
|
||||||
int chunksize;
|
int chunksize;
|
||||||
int count = ipod->pinfo[0].size;
|
int count = ipod->pinfo[0].size;
|
||||||
|
@ -301,7 +301,7 @@ int read_partition(struct ipod_t* ipod, int outfile)
|
||||||
|
|
||||||
if (n < chunksize) {
|
if (n < chunksize) {
|
||||||
fprintf(stderr,
|
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);
|
chunksize,n);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -317,7 +317,7 @@ int read_partition(struct ipod_t* ipod, int outfile)
|
||||||
|
|
||||||
if (res != n) {
|
if (res != n) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Short write - requested %lu, received %d - aborting.\n",n,res);
|
"Short write - requested %d, received %d - aborting.\n",n,res);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -328,7 +328,7 @@ int read_partition(struct ipod_t* ipod, int outfile)
|
||||||
|
|
||||||
int write_partition(struct ipod_t* ipod, int infile)
|
int write_partition(struct ipod_t* ipod, int infile)
|
||||||
{
|
{
|
||||||
unsigned long res;
|
ssize_t res;
|
||||||
int n;
|
int n;
|
||||||
int bytesread;
|
int bytesread;
|
||||||
int byteswritten = 0;
|
int byteswritten = 0;
|
||||||
|
@ -370,7 +370,7 @@ int write_partition(struct ipod_t* ipod, int infile)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res != n) {
|
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;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue