Make SDL_SetError and friends unconditionally return -1.
This lets us change things like this... if (Failed) { SDL_SetError("We failed"); return -1; } ...into this... if (Failed) { return SDL_SetError("We failed"); } Fixes Bugzilla #1778.
This commit is contained in:
parent
8c6b9f4743
commit
4f438b70a2
106 changed files with 616 additions and 1189 deletions
|
@ -87,8 +87,7 @@ windows_file_open(SDL_RWops * context, const char *filename, const char *mode)
|
|||
context->hidden.windowsio.buffer.data =
|
||||
(char *) SDL_malloc(READAHEAD_BUFFER_SIZE);
|
||||
if (!context->hidden.windowsio.buffer.data) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
/* Do not open a dialog box if failure */
|
||||
old_error_mode =
|
||||
|
@ -124,13 +123,11 @@ windows_file_size(SDL_RWops * context)
|
|||
LARGE_INTEGER size;
|
||||
|
||||
if (!context || context->hidden.windowsio.h == INVALID_HANDLE_VALUE) {
|
||||
SDL_SetError("windows_file_size: invalid context/file not opened");
|
||||
return -1;
|
||||
return SDL_SetError("windows_file_size: invalid context/file not opened");
|
||||
}
|
||||
|
||||
if (!GetFileSizeEx(context->hidden.windowsio.h, &size)) {
|
||||
WIN_SetError("windows_file_size");
|
||||
return -1;
|
||||
return WIN_SetError("windows_file_size");
|
||||
}
|
||||
|
||||
return size.QuadPart;
|
||||
|
@ -143,8 +140,7 @@ windows_file_seek(SDL_RWops * context, Sint64 offset, int whence)
|
|||
LARGE_INTEGER windowsoffset;
|
||||
|
||||
if (!context || context->hidden.windowsio.h == INVALID_HANDLE_VALUE) {
|
||||
SDL_SetError("windows_file_seek: invalid context/file not opened");
|
||||
return -1;
|
||||
return SDL_SetError("windows_file_seek: invalid context/file not opened");
|
||||
}
|
||||
|
||||
/* FIXME: We may be able to satisfy the seek within buffered data */
|
||||
|
@ -164,14 +160,12 @@ windows_file_seek(SDL_RWops * context, Sint64 offset, int whence)
|
|||
windowswhence = FILE_END;
|
||||
break;
|
||||
default:
|
||||
SDL_SetError("windows_file_seek: Unknown value for 'whence'");
|
||||
return -1;
|
||||
return SDL_SetError("windows_file_seek: Unknown value for 'whence'");
|
||||
}
|
||||
|
||||
windowsoffset.QuadPart = offset;
|
||||
if (!SetFilePointerEx(context->hidden.windowsio.h, windowsoffset, &windowsoffset, windowswhence)) {
|
||||
WIN_SetError("windows_file_seek");
|
||||
return -1;
|
||||
return WIN_SetError("windows_file_seek");
|
||||
}
|
||||
return windowsoffset.QuadPart;
|
||||
}
|
||||
|
@ -325,8 +319,7 @@ stdio_seek(SDL_RWops * context, Sint64 offset, int whence)
|
|||
return (ftell(context->hidden.stdio.fp));
|
||||
}
|
||||
#endif
|
||||
SDL_Error(SDL_EFSEEK);
|
||||
return (-1);
|
||||
return SDL_Error(SDL_EFSEEK);
|
||||
}
|
||||
|
||||
static size_t SDLCALL
|
||||
|
@ -361,8 +354,7 @@ stdio_close(SDL_RWops * context)
|
|||
if (context->hidden.stdio.autoclose) {
|
||||
/* WARNING: Check the return value here! */
|
||||
if (fclose(context->hidden.stdio.fp) != 0) {
|
||||
SDL_Error(SDL_EFWRITE);
|
||||
status = -1;
|
||||
status = SDL_Error(SDL_EFWRITE);
|
||||
}
|
||||
}
|
||||
SDL_FreeRW(context);
|
||||
|
@ -395,8 +387,7 @@ mem_seek(SDL_RWops * context, Sint64 offset, int whence)
|
|||
newpos = context->hidden.mem.stop + offset;
|
||||
break;
|
||||
default:
|
||||
SDL_SetError("Unknown value for 'whence'");
|
||||
return (-1);
|
||||
return SDL_SetError("Unknown value for 'whence'");
|
||||
}
|
||||
if (newpos < context->hidden.mem.base) {
|
||||
newpos = context->hidden.mem.base;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue