Silence some warnings

This commit is contained in:
twinaphex 2015-07-17 07:29:26 +02:00
parent d3decf9a6e
commit aca4887a16
10 changed files with 120 additions and 139 deletions

View File

@ -16,7 +16,7 @@ MemoryStream::MemoryStream() : data_buffer(NULL), data_buffer_size(0), data_buff
{
data_buffer_size = 0;
data_buffer_alloced = 64;
if(!(data_buffer = (uint8*)realloc(data_buffer, data_buffer_alloced)))
if(!(data_buffer = (uint8*)realloc(data_buffer, (size_t)data_buffer_alloced)))
throw MDFN_Error(ErrnoHolder(errno));
}
@ -25,7 +25,7 @@ MemoryStream::MemoryStream(uint64 size_hint) : data_buffer(NULL), data_buffer_si
data_buffer_size = 0;
data_buffer_alloced = (size_hint > SIZE_MAX) ? SIZE_MAX : size_hint;
if(!(data_buffer = (uint8*)realloc(data_buffer, data_buffer_alloced)))
if(!(data_buffer = (uint8*)realloc(data_buffer, (size_t)data_buffer_alloced)))
throw MDFN_Error(ErrnoHolder(errno));
}
@ -36,7 +36,7 @@ MemoryStream::MemoryStream(Stream *stream) : data_buffer(NULL), data_buffer_size
data_buffer_size = stream->size();
data_buffer_alloced = data_buffer_size;
if(!(data_buffer = (uint8*)realloc(data_buffer, data_buffer_alloced)))
if(!(data_buffer = (uint8*)realloc(data_buffer, (size_t)data_buffer_alloced)))
throw MDFN_Error(ErrnoHolder(errno));
stream->read(data_buffer, data_buffer_size);
@ -49,10 +49,10 @@ MemoryStream::MemoryStream(const MemoryStream &zs)
{
data_buffer_size = zs.data_buffer_size;
data_buffer_alloced = zs.data_buffer_alloced;
if(!(data_buffer = (uint8*)malloc(data_buffer_alloced)))
if(!(data_buffer = (uint8*)malloc((size_t)data_buffer_alloced)))
throw MDFN_Error(ErrnoHolder(errno));
memcpy(data_buffer, zs.data_buffer, data_buffer_size);
memcpy(data_buffer, zs.data_buffer, (size_t)data_buffer_size);
position = zs.position;
}
@ -101,7 +101,7 @@ INLINE void MemoryStream::grow_if_necessary(uint64 new_required_size)
if(new_required_alloced < new_required_size)
throw MDFN_Error(ErrnoHolder(ENOMEM));
if(!(new_data_buffer = (uint8*)realloc(data_buffer, new_required_alloced)))
if(!(new_data_buffer = (uint8*)realloc(data_buffer, (size_t)new_required_alloced)))
throw MDFN_Error(ErrnoHolder(errno));
//
@ -128,7 +128,7 @@ uint64 MemoryStream::read(void *data, uint64 count, bool error_on_eos)
count = data_buffer_size - position;
}
memmove(data, &data_buffer[position], count);
memmove(data, &data_buffer[position], (size_t)count);
position += count;
return count;
@ -143,7 +143,7 @@ void MemoryStream::write(const void *data, uint64 count)
grow_if_necessary(nrs);
memmove(&data_buffer[position], data, count);
memmove(&data_buffer[position], data, (size_t)count);
position += count;
}
@ -153,21 +153,17 @@ void MemoryStream::seek(int64 offset, int whence)
switch(whence)
{
default:
throw MDFN_Error(ErrnoHolder(EINVAL));
break;
case SEEK_SET:
new_position = offset;
break;
case SEEK_SET:
new_position = offset;
break;
case SEEK_CUR:
new_position = position + offset;
break;
case SEEK_CUR:
new_position = position + offset;
break;
case SEEK_END:
new_position = data_buffer_size + offset;
break;
case SEEK_END:
new_position = data_buffer_size + offset;
break;
}
if(new_position < 0)

View File

@ -213,7 +213,6 @@ void CDAccess_CCD::Load(const char *path, bool image_memcache)
{
default:
throw MDFN_Error(0, "Unsupported TOC entry Point value: %u", point);
break;
case 0xA0:
tocd.first_track = pmin;

View File

@ -174,29 +174,24 @@ static size_t UnQuotify(const std::string &src, size_t source_offset, std::strin
uint32 CDAccess_Image::GetSectorCount(CDRFILE_TRACK_INFO *track)
{
if(track->DIFormat == DI_FORMAT_AUDIO)
{
if(track->AReader)
return(((track->AReader->FrameCount() * 4) - track->FileOffset) / 2352);
else
{
const int64 size = track->fp->size();
int64 size;
//printf("%d %d %d\n", (int)stat_buf.st_size, (int)track->FileOffset, (int)stat_buf.st_size - (int)track->FileOffset);
if(track->SubchannelMode)
return((size - track->FileOffset) / (2352 + 96));
else
return((size - track->FileOffset) / 2352);
}
}
else
{
const int64 size = track->fp->size();
return((size - track->FileOffset) / DI_Size_Table[track->DIFormat]);
}
if(track->DIFormat == DI_FORMAT_AUDIO)
{
if(track->AReader)
return(((track->AReader->FrameCount() * 4) - track->FileOffset) / 2352);
return(0);
size = track->fp->size();
//printf("%d %d %d\n", (int)stat_buf.st_size, (int)track->FileOffset, (int)stat_buf.st_size - (int)track->FileOffset);
if(track->SubchannelMode)
return((size - track->FileOffset) / (2352 + 96));
return((size - track->FileOffset) / 2352);
}
size = track->fp->size();
return((size - track->FileOffset) / DI_Size_Table[track->DIFormat]);
}
void CDAccess_Image::ParseTOCFileLineInfo(CDRFILE_TRACK_INFO *track, const int tracknum, const std::string &filename, const char *binoffset, const char *msfoffset, const char *length, bool image_memcache, std::map<std::string, Stream*> &toc_streamcache)

View File

@ -828,31 +828,27 @@ void CDIF_Stream_Thing::write(const void *data, uint64 count)
void CDIF_Stream_Thing::seek(int64 offset, int whence)
{
int64 new_position;
int64 new_position;
switch(whence)
{
default:
throw MDFN_Error(ErrnoHolder(EINVAL));
break;
switch(whence)
{
case SEEK_SET:
new_position = offset;
break;
case SEEK_SET:
new_position = offset;
break;
case SEEK_CUR:
new_position = position + offset;
break;
case SEEK_CUR:
new_position = position + offset;
break;
case SEEK_END:
new_position = ((int64)sector_count * 2048) + offset;
break;
}
case SEEK_END:
new_position = ((int64)sector_count * 2048) + offset;
break;
}
if(new_position < 0 || new_position > ((int64)sector_count * 2048))
throw MDFN_Error(ErrnoHolder(EINVAL));
if(new_position < 0 || new_position > ((int64)sector_count * 2048))
throw MDFN_Error(ErrnoHolder(EINVAL));
position = new_position;
position = new_position;
}
int64 CDIF_Stream_Thing::tell(void)

View File

@ -35,9 +35,9 @@ bool MDFNFILE::MakeMemWrapAndClose(void *fp)
f_size = ::ftell((FILE *)fp);
::fseek((FILE *)fp, 0, SEEK_SET);
if (!(f_data = (uint8*)MDFN_malloc(f_size, _("file read buffer"))))
if (!(f_data = (uint8*)MDFN_malloc((size_t)f_size, _("file read buffer"))))
goto fail;
::fread(f_data, 1, f_size, (FILE *)fp);
::fread(f_data, 1, (size_t)f_size, (FILE *)fp);
ret = TRUE;
fail:
@ -109,7 +109,7 @@ uint64 MDFNFILE::fread(void *ptr, size_t element_size, size_t nmemb)
if ((location + total) > f_size)
{
int64 ak = f_size - location;
size_t ak = f_size - location;
memcpy((uint8*)ptr, f_data + location, ak);
@ -117,14 +117,12 @@ uint64 MDFNFILE::fread(void *ptr, size_t element_size, size_t nmemb)
return(ak / element_size);
}
else
{
memcpy((uint8*)ptr, f_data + location, total);
location += total;
memcpy((uint8*)ptr, f_data + location, total);
return nmemb;
}
location += total;
return nmemb;
}
int MDFNFILE::fseek(int64 offset, int whence)

View File

@ -779,70 +779,69 @@ static int GGtobin(char c)
/* Returns 1 on success, 0 on failure. Sets *a,*v,*c. */
int MDFNI_DecodeGG(const char *str, uint32 *a, uint8 *v, uint8 *c, char *type)
{
uint16 A;
uint8 V,C;
uint8 t;
int s;
uint16 A;
uint8 V,C;
uint8 t;
int s;
A=0x8000;
V=0;
C=0;
A=0x8000;
V=0;
C=0;
s=strlen(str);
if(s!=6 && s!=8) return(0);
s=strlen(str);
if(s!=6 && s!=8) return(0);
t=GGtobin(*str++);
V|=(t&0x07);
V|=(t&0x08)<<4;
t=GGtobin(*str++);
V|=(t&0x07);
V|=(t&0x08)<<4;
t=GGtobin(*str++);
V|=(t&0x07)<<4;
A|=(t&0x08)<<4;
t=GGtobin(*str++);
V|=(t&0x07)<<4;
A|=(t&0x08)<<4;
t=GGtobin(*str++);
A|=(t&0x07)<<4;
//if(t&0x08) return(0); /* 8-character code?! */
t=GGtobin(*str++);
A|=(t&0x07)<<4;
//if(t&0x08) return(0); /* 8-character code?! */
t=GGtobin(*str++);
A|=(t&0x07)<<12;
A|=(t&0x08);
t=GGtobin(*str++);
A|=(t&0x07)<<12;
A|=(t&0x08);
t=GGtobin(*str++);
A|=(t&0x07);
A|=(t&0x08)<<8;
t=GGtobin(*str++);
A|=(t&0x07);
A|=(t&0x08)<<8;
if(s==6)
{
t=GGtobin(*str++);
A|=(t&0x07)<<8;
V|=(t&0x08);
if(s==6)
{
t=GGtobin(*str++);
A|=(t&0x07)<<8;
V|=(t&0x08);
*a=A;
*v=V;
*type = 'S';
*c = 0;
return(1);
}
else
{
t=GGtobin(*str++);
A|=(t&0x07)<<8;
C|=(t&0x08);
*a=A;
*v=V;
*type = 'S';
*c = 0;
}
else
{
t=GGtobin(*str++);
A|=(t&0x07)<<8;
C|=(t&0x08);
t=GGtobin(*str++);
C|=(t&0x07);
C|=(t&0x08)<<4;
t=GGtobin(*str++);
C|=(t&0x07)<<4;
V|=(t&0x08);
*a=A;
*v=V;
*c=C;
*type = 'C';
return(1);
}
return(0);
t=GGtobin(*str++);
C|=(t&0x07);
C|=(t&0x08)<<4;
t=GGtobin(*str++);
C|=(t&0x07)<<4;
V|=(t&0x08);
*a=A;
*v=V;
*c=C;
*type = 'C';
}
return(1);
}
int MDFNI_DecodePAR(const char *str, uint32 *a, uint8 *v, uint8 *c, char *type)

View File

@ -118,16 +118,16 @@ class PS_CPU
enum
{
CP0REG_BPC = 3, // PC breakpoint address.
CP0REG_BDA = 5, // Data load/store breakpoint address.
CP0REG_TAR = 6, // Target address(???)
CP0REG_DCIC = 7, // Cache control
CP0REG_BDAM = 9, // Data load/store address mask.
CP0REG_BPCM = 11, // PC breakpoint address mask.
CP0REG_SR = 12,
CP0REG_BPC = 3, // PC breakpoint address.
CP0REG_BDA = 5, // Data load/store breakpoint address.
CP0REG_TAR = 6, // Target address
CP0REG_DCIC = 7, // Cache control
CP0REG_BDAM = 9, // Data load/store address mask.
CP0REG_BPCM = 11, // PC breakpoint address mask.
CP0REG_SR = 12,
CP0REG_CAUSE = 13,
CP0REG_EPC = 14,
CP0REG_PRID = 15, // Product ID
CP0REG_EPC = 14,
CP0REG_PRID = 15, // Product ID
CP0REG_ERREG = 16
};

View File

@ -238,7 +238,7 @@ static INLINE void ChRW(const unsigned ch, const uint32_t CRModeCache, uint32_t
#if 0
if(CRModeCache & 0x100) // For CDC DMA(at least): When this bit is set, DMA controller doesn't appear to hog the (RAM?) bus.
{
if(CRModeCache & 0x00400000) // For CDC DMA(at least): When this bit is set, DMA controller appears to get even less bus time(or has a lower priority??)
if(CRModeCache & 0x00400000) // For CDC DMA(at least): When this bit is set, DMA controller appears to get even less bus time(or has a lower priority?)
{
DMACH[ch].ClockCounter -= 44 * 20 / 12;
}

View File

@ -368,8 +368,6 @@ void FrontIO::SetAMCT(bool enabled)
void FrontIO::SetCrosshairsColor(unsigned port, uint32_t color)
{
assert(port >= 0 && port < 8);
chair_colors[port] = color;
Devices[port]->SetCrosshairsColor(color);
}

View File

@ -1547,7 +1547,7 @@ int32_t GTE_Instruction(uint32_t instr)
break;
/*
case 0x17: // PARTIALLY UNSTABLE(depending on sf or v or cv or mx or lm???), similar behavior under some conditions to 0x16?
case 0x17: // PARTIALLY UNSTABLE(depending on sf or v or cv or mx or lm), similar behavior under some conditions to 0x16?
break;
case 0x18: