From 478b965e6cced31dd1cc1e54d567e7f7599d8dae Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Tue, 19 Mar 2024 16:02:54 -0700 Subject: [PATCH] Fixed warning C4702: unreachable code Also switched SDL_IOFromFile() to use SDL_InvalidParamError() --- src/file/SDL_iostream.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/file/SDL_iostream.c b/src/file/SDL_iostream.c index d88c2f8f00..d261094f36 100644 --- a/src/file/SDL_iostream.c +++ b/src/file/SDL_iostream.c @@ -535,10 +535,16 @@ static SDL_bool IsRegularFileOrPipe(FILE *f) SDL_IOStream *SDL_IOFromFile(const char *file, const char *mode) { SDL_IOStream *iostr = NULL; - if (!file || !*file || !mode || !*mode) { - SDL_SetError("SDL_IOFromFile(): No file or no mode specified"); + + if (!file || !*file) { + SDL_InvalidParamError("file"); return NULL; } + if (!mode || !*mode) { + SDL_InvalidParamError("mode"); + return NULL; + } + #ifdef SDL_PLATFORM_ANDROID #ifdef HAVE_STDIO_H /* Try to open the file on the filesystem first */ @@ -599,9 +605,6 @@ SDL_IOStream *SDL_IOFromFile(const char *file, const char *mode) } } - return iostr; - - #elif defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK) || defined(SDL_PLATFORM_WINRT) IOStreamWindowsData *iodata = (IOStreamWindowsData *) SDL_malloc(sizeof (*iodata)); if (!iodata) { @@ -631,8 +634,6 @@ SDL_IOStream *SDL_IOFromFile(const char *file, const char *mode) } } - return iostr; - #elif defined(HAVE_STDIO_H) { #if defined(SDL_PLATFORM_APPLE)