PSP: Fix wrong/dangerous C-style casts

This commit is contained in:
Colin Snover 2017-10-28 15:26:54 -05:00 committed by Eugene Sandulenko
parent 334e0e7463
commit e49e34eede
4 changed files with 10 additions and 10 deletions

View file

@ -125,13 +125,13 @@ void Overlay::setSize(uint32 width, uint32 height) {
void Overlay::copyToArray(void *buf, int pitch) {
DEBUG_ENTER_FUNC();
_buffer.copyToArray((byte *)buf, pitch); // Change to bytes
_buffer.copyToArray((byte *)buf, pitch);
}
void Overlay::copyFromRect(const void *buf, int pitch, int x, int y, int w, int h) {
DEBUG_ENTER_FUNC();
_buffer.copyFromRect((byte *)buf, pitch, x, y, w, h); // Change to bytes
_buffer.copyFromRect((const byte *)buf, pitch, x, y, w, h);
// debug
//_buffer.print(0xFF);
setDirty();

View file

@ -72,7 +72,7 @@ void PspMemory::copy(byte *dst, const byte *src, uint32 bytes) {
if (alignSrc) { // we'll need to realign our reads
copy32Misaligned((uint32 *)dst, src, bytes, alignSrc);
} else {
copy32Aligned((uint32 *)dst, (uint32 *)src, bytes);
copy32Aligned((uint32 *)dst, (const uint32 *)src, bytes);
}
#ifdef TEST_MEMORY_COPY
@ -141,7 +141,7 @@ void PspMemory::copy32Aligned(uint32 *dst32, const uint32 *src32, uint32 bytes)
PSP_DEBUG_PRINT("bytesLeft[%d]\n", bytesLeft);
byte *dst = (byte *)dst32;
byte *src = (byte *)src32;
const byte *src = (const byte *)src32;
while (bytesLeft--) {
*dst++ = *src++;
@ -343,7 +343,7 @@ void PspMemorySwap::swap32Aligned(uint32 *dst32, const uint32 *src32, uint32 byt
bytesLeft = bytes & 0x3;
if (bytesLeft) { // for swap, can only be 1 short left
*((uint16 *)dst32) = format.swapRedBlue16(*((uint16 *)src32));
*((uint16 *)dst32) = format.swapRedBlue16(*((const uint16 *)src32));
}
}

View file

@ -72,7 +72,7 @@ public:
// This is the interface to the outside world
static void *fastCopy(void *dstv, const void *srcv, int32 bytes) {
byte *dst = (byte *)dstv;
byte *src = (byte *)srcv;
const byte *src = (const byte *)srcv;
if (bytes < MIN_AMOUNT_FOR_COMPLEX_COPY) {
copy8(dst, src, bytes);
@ -114,9 +114,9 @@ private:
public:
static void fastSwap(byte *dst, const byte *src, uint32 bytes, PSPPixelFormat &format) {
if (bytes < MIN_AMOUNT_FOR_COMPLEX_COPY * 2) {
swap16((uint16 *)dst, (uint16 *)src, bytes, format);
swap16((uint16 *)dst, (const uint16 *)src, bytes, format);
} else { // go to more powerful copy
swap((uint16 *)dst, (uint16 *)src, bytes, format);
swap((uint16 *)dst, (const uint16 *)src, bytes, format);
}
}
};

View file

@ -98,13 +98,13 @@ bool Mp3PspStream::initDecoder() {
uint32 firmware = sceKernelDevkitVersion();
PSP_DEBUG_PRINT("Firmware version 0x%x\n", firmware);
if (firmware == 0x01050001){
if (!loadStartAudioModule((char *)(void *)"flash0:/kd/me_for_vsh.prx",
if (!loadStartAudioModule("flash0:/kd/me_for_vsh.prx",
PSP_MEMORY_PARTITION_KERNEL)) {
PSP_ERROR("failed to load me_for_vsh.prx. ME cannot start.\n");
_decoderFail = true;
return false;
}
if (!loadStartAudioModule((char *)(void *)"flash0:/kd/audiocodec.prx", PSP_MEMORY_PARTITION_KERNEL)) {
if (!loadStartAudioModule("flash0:/kd/audiocodec.prx", PSP_MEMORY_PARTITION_KERNEL)) {
PSP_ERROR("failed to load audiocodec.prx. ME cannot start.\n");
_decoderFail = true;
return false;