mirror of https://github.com/encounter/SDL.git
SDL_rwops.c: simplify `foo <= 0` checks to `!foo` with unsigned types.
This commit is contained in:
parent
30f895a5f3
commit
565ef63873
|
@ -122,9 +122,6 @@ SDL_syscond.obj: "src/thread/generic/SDL_syscond.c"
|
||||||
SDL_cpuinfo.obj: SDL_cpuinfo.c
|
SDL_cpuinfo.obj: SDL_cpuinfo.c
|
||||||
wcc386 $(CFLAGS) -wcd=200 -fo=$^@ $<
|
wcc386 $(CFLAGS) -wcd=200 -fo=$^@ $<
|
||||||
|
|
||||||
SDL_rwops.obj: SDL_rwops.c
|
|
||||||
wcc386 $(CFLAGS) -wcd=136 -fo=$^@ $<
|
|
||||||
|
|
||||||
SDL_wave.obj: SDL_wave.c
|
SDL_wave.obj: SDL_wave.c
|
||||||
wcc386 $(CFLAGS) -wcd=124 -fo=$^@ $<
|
wcc386 $(CFLAGS) -wcd=124 -fo=$^@ $<
|
||||||
|
|
||||||
|
|
|
@ -166,8 +166,7 @@ vita_file_size(SDL_RWops * context)
|
||||||
return SDL_SetError("vita_file_size: invalid context/file not opened");
|
return SDL_SetError("vita_file_size: invalid context/file not opened");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sceIoGetstatByFd(context->hidden.vitaio.h, &st) < 0)
|
if (sceIoGetstatByFd(context->hidden.vitaio.h, &st) < 0) {
|
||||||
{
|
|
||||||
return SDL_SetError("vita_file_size: could not get file size");
|
return SDL_SetError("vita_file_size: could not get file size");
|
||||||
}
|
}
|
||||||
return st.st_size;
|
return st.st_size;
|
||||||
|
@ -215,9 +214,9 @@ vita_file_read(SDL_RWops * context, void *ptr, size_t size, size_t maxnum)
|
||||||
|
|
||||||
total_need = size * maxnum;
|
total_need = size * maxnum;
|
||||||
|
|
||||||
if (!context || context->hidden.vitaio.h < 0
|
if (!context || context->hidden.vitaio.h < 0 || !total_need) {
|
||||||
|| !total_need)
|
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (context->hidden.vitaio.buffer.left > 0) {
|
if (context->hidden.vitaio.buffer.left > 0) {
|
||||||
void *data = (char *) context->hidden.vitaio.buffer.data +
|
void *data = (char *) context->hidden.vitaio.buffer.data +
|
||||||
|
@ -261,9 +260,9 @@ vita_file_write(SDL_RWops * context, const void *ptr, size_t size,
|
||||||
|
|
||||||
total_bytes = size * num;
|
total_bytes = size * num;
|
||||||
|
|
||||||
if (!context || context->hidden.vitaio.h < 0
|
if (!context || context->hidden.vitaio.h < 0 || !size || !total_bytes) {
|
||||||
|| total_bytes <= 0 || !size)
|
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (context->hidden.vitaio.buffer.left) {
|
if (context->hidden.vitaio.buffer.left) {
|
||||||
sceIoLseek(context->hidden.vitaio.h, -(SceOff)context->hidden.vitaio.buffer.left, SCE_SEEK_CUR);
|
sceIoLseek(context->hidden.vitaio.h, -(SceOff)context->hidden.vitaio.buffer.left, SCE_SEEK_CUR);
|
||||||
|
@ -433,9 +432,9 @@ windows_file_read(SDL_RWops * context, void *ptr, size_t size, size_t maxnum)
|
||||||
|
|
||||||
total_need = size * maxnum;
|
total_need = size * maxnum;
|
||||||
|
|
||||||
if (!context || context->hidden.windowsio.h == INVALID_HANDLE_VALUE
|
if (!context || context->hidden.windowsio.h == INVALID_HANDLE_VALUE || !total_need) {
|
||||||
|| !total_need)
|
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (context->hidden.windowsio.buffer.left > 0) {
|
if (context->hidden.windowsio.buffer.left > 0) {
|
||||||
void *data = (char *) context->hidden.windowsio.buffer.data +
|
void *data = (char *) context->hidden.windowsio.buffer.data +
|
||||||
|
@ -488,9 +487,9 @@ windows_file_write(SDL_RWops * context, const void *ptr, size_t size,
|
||||||
|
|
||||||
total_bytes = size * num;
|
total_bytes = size * num;
|
||||||
|
|
||||||
if (!context || context->hidden.windowsio.h == INVALID_HANDLE_VALUE
|
if (!context || context->hidden.windowsio.h == INVALID_HANDLE_VALUE || !size || !total_bytes) {
|
||||||
|| total_bytes <= 0 || !size)
|
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (context->hidden.windowsio.buffer.left) {
|
if (context->hidden.windowsio.buffer.left) {
|
||||||
SetFilePointer(context->hidden.windowsio.h,
|
SetFilePointer(context->hidden.windowsio.h,
|
||||||
|
@ -709,8 +708,7 @@ mem_read(SDL_RWops * context, void *ptr, size_t size, size_t maxnum)
|
||||||
size_t mem_available;
|
size_t mem_available;
|
||||||
|
|
||||||
total_bytes = (maxnum * size);
|
total_bytes = (maxnum * size);
|
||||||
if ((maxnum <= 0) || (size <= 0)
|
if (!maxnum || !size || ((total_bytes / maxnum) != size)) {
|
||||||
|| ((total_bytes / maxnum) != size)) {
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue