Sio: use & 0xFF instead of u8 mask

Tentative to avoid various bad coverity reports
This commit is contained in:
Gregory Hainaut 2016-11-12 19:28:07 +01:00
parent 2da6cb263d
commit 356429d0e7
2 changed files with 7 additions and 5 deletions

View File

@ -433,7 +433,9 @@ SIO_WRITE memcardWrite(u8 data)
case 2:
transfer_size = data;
sio.buf[data + 5] = mcd->term;
// Note: coverity wrongly detects a buffer overflow. Because data + 5 could be > 512...
// So let's add a mask-nop to avoid various useless reports.
sio.buf[(data & 0xFF) + 5] = mcd->term;
sio.bufSize = data + 5;
checksum_pos = data + 4;
break;

View File

@ -270,13 +270,13 @@ static __fi void _HwWrite_16or32_Page1( u32 addr, T val )
{
// ------------------------------------------------------------------------
mcase(HW_SIO_DATA):
sioWrite8( (u8)val );
sioWrite8( (u8)(val >> 8) );
sioWrite8( val & 0xFF );
sioWrite8( (val >> 8) & 0xFF );
if( sizeof(T) == 4 )
{
// u32 gets rid of compiler warnings when using the u16 version of this template
sioWrite8( (u8)((u32)val >> 16) );
sioWrite8( (u8)((u32)val >> 24) );
sioWrite8( ((u32)val >> 16) & 0xFF );
sioWrite8( ((u32)val >> 24) & 0xFF );
}
break;