Skip to content
Snippets Groups Projects
Commit 997b3160 authored by Deucе's avatar Deucе :ok_hand_tone4:
Browse files

Make all DLL handles globals so Coverity stops complaining.

They're not "leaking" if I want them to liver forever. :D
This does prevent an extra needless load if User.dll though...
but sdlfuncs and win32gdi both still load the same two DLLs.
parent 2cb260ab
No related branches found
No related tags found
1 merge request!488Overhaul LZH code
Pipeline #7520 passed
...@@ -21,13 +21,17 @@ static int sdl_funcs_loaded=0; ...@@ -21,13 +21,17 @@ static int sdl_funcs_loaded=0;
static void QuitWrap(void); static void QuitWrap(void);
static dll_handle sdl_dll;
#ifdef _WIN32
static dll_handle userDLL;
static dll_handle shcoreDLL;
#endif
int load_sdl_funcs(struct sdlfuncs *sdlf) int load_sdl_funcs(struct sdlfuncs *sdlf)
{ {
dll_handle sdl_dll;
const char *libnames[]={"SDL2", "SDL", NULL}; const char *libnames[]={"SDL2", "SDL", NULL};
sdlf->gotfuncs=0; sdlf->gotfuncs=0;
if((sdl_dll=xp_dlopen(libnames,RTLD_LAZY|RTLD_GLOBAL,SDL_PATCHLEVEL))==NULL) if(sdl_dll == NULL && (sdl_dll=xp_dlopen(libnames,RTLD_LAZY|RTLD_GLOBAL,SDL_PATCHLEVEL))==NULL)
return(-1); return(-1);
if((sdlf->Init=xp_dlsym(sdl_dll, SDL_Init))==NULL) { if((sdlf->Init=xp_dlsym(sdl_dll, SDL_Init))==NULL) {
...@@ -269,7 +273,8 @@ int init_sdl_video(void) ...@@ -269,7 +273,8 @@ int init_sdl_video(void)
HRESULT(WINAPI *SetProcessDpiAwarenessContext)(enum D3_PROCESS_DPI_AWARENESS dpiAwareness) = NULL; HRESULT(WINAPI *SetProcessDpiAwarenessContext)(enum D3_PROCESS_DPI_AWARENESS dpiAwareness) = NULL;
const char* user32dll[] = {"User32", NULL}; const char* user32dll[] = {"User32", NULL};
dll_handle userDLL = xp_dlopen(user32dll, RTLD_LAZY, 0); if (!userDLL)
userDLL = xp_dlopen(user32dll, RTLD_LAZY, 0);
if (userDLL) if (userDLL)
{ {
...@@ -279,7 +284,8 @@ int init_sdl_video(void) ...@@ -279,7 +284,8 @@ int init_sdl_video(void)
const char* shcoredll[] = {"SHCore", NULL}; const char* shcoredll[] = {"SHCore", NULL};
dll_handle shcoreDLL = xp_dlopen(shcoredll, RTLD_LAZY, 0); if (!shcoreDLL)
shcoreDLL = xp_dlopen(shcoredll, RTLD_LAZY, 0);
if (shcoreDLL) if (shcoreDLL)
{ {
......
...@@ -195,6 +195,7 @@ sp_to_codepoint(uint16_t high, uint16_t low) ...@@ -195,6 +195,7 @@ sp_to_codepoint(uint16_t high, uint16_t low)
return (high - 0xd800) * 0x400 + (low - 0xdc00) + 0x10000; return (high - 0xd800) * 0x400 + (low - 0xdc00) + 0x10000;
} }
static dll_handle userDLL;
static BOOL static BOOL
gdiAdjustWindowRect(LPRECT r, DWORD style, BOOL menu, UINT dpi) gdiAdjustWindowRect(LPRECT r, DWORD style, BOOL menu, UINT dpi)
{ {
...@@ -205,7 +206,8 @@ gdiAdjustWindowRect(LPRECT r, DWORD style, BOOL menu, UINT dpi) ...@@ -205,7 +206,8 @@ gdiAdjustWindowRect(LPRECT r, DWORD style, BOOL menu, UINT dpi)
if (!gotPtr) { if (!gotPtr) {
const char* user32dll[] = {"User32", NULL}; const char* user32dll[] = {"User32", NULL};
dll_handle userDLL = xp_dlopen(user32dll, RTLD_LAZY, 0); if (!userDLL)
userDLL = xp_dlopen(user32dll, RTLD_LAZY, 0);
if (userDLL) { if (userDLL) {
AWREFD = xp_dlsym(userDLL, AdjustWindowRectExForDpi); AWREFD = xp_dlsym(userDLL, AdjustWindowRectExForDpi);
...@@ -1244,6 +1246,7 @@ gdi_get_window_info(int *width, int *height, int *xpos, int *ypos) ...@@ -1244,6 +1246,7 @@ gdi_get_window_info(int *width, int *height, int *xpos, int *ypos)
return(1); return(1);
} }
static dll_handle shcoreDLL;
int int
gdi_init(int mode) gdi_init(int mode)
{ {
...@@ -1269,7 +1272,8 @@ gdi_init(int mode) ...@@ -1269,7 +1272,8 @@ gdi_init(int mode)
HRESULT(WINAPI *SetProcessDpiAwarenessContext)(enum D3_PROCESS_DPI_AWARENESS dpiAwareness) = NULL; HRESULT(WINAPI *SetProcessDpiAwarenessContext)(enum D3_PROCESS_DPI_AWARENESS dpiAwareness) = NULL;
const char* user32dll[] = {"User32", NULL}; const char* user32dll[] = {"User32", NULL};
dll_handle userDLL = xp_dlopen(user32dll, RTLD_LAZY, 0); if (!userDLL)
userDLL = xp_dlopen(user32dll, RTLD_LAZY, 0);
if (userDLL) if (userDLL)
{ {
...@@ -1278,7 +1282,8 @@ gdi_init(int mode) ...@@ -1278,7 +1282,8 @@ gdi_init(int mode)
} }
const char* shcoredll[] = {"SHCore", NULL}; const char* shcoredll[] = {"SHCore", NULL};
dll_handle shcoreDLL = xp_dlopen(shcoredll, RTLD_LAZY, 0); if (!shcoreDLL)
shcoreDLL = xp_dlopen(shcoredll, RTLD_LAZY, 0);
if (shcoreDLL) if (shcoreDLL)
{ {
......
...@@ -182,20 +182,26 @@ void x11_mouse_thread(void *data) ...@@ -182,20 +182,26 @@ void x11_mouse_thread(void *data)
} }
} }
static dll_handle dl;
#ifdef WITH_XRENDER
static dll_handle dl2;
#endif
#ifdef WITH_XINERAMA
static dll_handle dl3;
#endif
#ifdef WITH_XRANDR
static dll_handle dl4;
#endif
int x_initciolib(int mode) int x_initciolib(int mode)
{ {
dll_handle dl;
const char *libnames[]={"X11",NULL}; const char *libnames[]={"X11",NULL};
#ifdef WITH_XRENDER #ifdef WITH_XRENDER
dll_handle dl2;
const char *libnames2[]={"Xrender",NULL}; const char *libnames2[]={"Xrender",NULL};
#endif #endif
#ifdef WITH_XINERAMA #ifdef WITH_XINERAMA
dll_handle dl3;
const char *libnames3[]={"Xinerama",NULL}; const char *libnames3[]={"Xinerama",NULL};
#endif #endif
#ifdef WITH_XRANDR #ifdef WITH_XRANDR
dll_handle dl4;
const char *libnames4[]={"Xrandr",NULL}; const char *libnames4[]={"Xrandr",NULL};
#endif #endif
Status (*xit)(void); Status (*xit)(void);
...@@ -216,7 +222,7 @@ int x_initciolib(int mode) ...@@ -216,7 +222,7 @@ int x_initciolib(int mode)
return(-1); return(-1);
/* Load X11 functions */ /* Load X11 functions */
if((dl=xp_dlopen(libnames,RTLD_LAZY,7))==NULL) if(dl == NULL && (dl=xp_dlopen(libnames,RTLD_LAZY,7))==NULL)
return(-1); return(-1);
if ((_Xdebug = xp_dlsym(dl,_Xdebug))!=NULL) if ((_Xdebug = xp_dlsym(dl,_Xdebug))!=NULL)
*_Xdebug=1; *_Xdebug=1;
...@@ -520,7 +526,7 @@ int x_initciolib(int mode) ...@@ -520,7 +526,7 @@ int x_initciolib(int mode)
} }
#ifdef WITH_XRENDER #ifdef WITH_XRENDER
xrender_found = true; xrender_found = true;
if ((dl2 = xp_dlopen(libnames2,RTLD_LAZY,1)) == NULL) if (dl2 == NULL && (dl2 = xp_dlopen(libnames2,RTLD_LAZY,1)) == NULL)
xrender_found = false; xrender_found = false;
if (xrender_found && ((x11.XRenderFindStandardFormat = xp_dlsym(dl2, XRenderFindStandardFormat)) == NULL)) { if (xrender_found && ((x11.XRenderFindStandardFormat = xp_dlsym(dl2, XRenderFindStandardFormat)) == NULL)) {
xp_dlclose(dl2); xp_dlclose(dl2);
...@@ -557,7 +563,7 @@ int x_initciolib(int mode) ...@@ -557,7 +563,7 @@ int x_initciolib(int mode)
#endif #endif
#ifdef WITH_XINERAMA #ifdef WITH_XINERAMA
xinerama_found = true; xinerama_found = true;
if ((dl3 = xp_dlopen(libnames3,RTLD_LAZY,1)) == NULL) if (dl3 == NULL && (dl3 = xp_dlopen(libnames3,RTLD_LAZY,1)) == NULL)
xinerama_found = false; xinerama_found = false;
if (xinerama_found && ((x11.XineramaQueryVersion = xp_dlsym(dl3, XineramaQueryVersion)) == NULL)) { if (xinerama_found && ((x11.XineramaQueryVersion = xp_dlsym(dl3, XineramaQueryVersion)) == NULL)) {
xp_dlclose(dl3); xp_dlclose(dl3);
...@@ -570,7 +576,7 @@ int x_initciolib(int mode) ...@@ -570,7 +576,7 @@ int x_initciolib(int mode)
#endif #endif
#ifdef WITH_XRANDR #ifdef WITH_XRANDR
xrandr_found = true; xrandr_found = true;
if ((dl4 = xp_dlopen(libnames4,RTLD_LAZY,2)) == NULL) if (dl4 == NULL && (dl4 = xp_dlopen(libnames4,RTLD_LAZY,2)) == NULL)
xrandr_found = false; xrandr_found = false;
if (xrandr_found && ((x11.XRRQueryVersion = xp_dlsym(dl4, XRRQueryVersion)) == NULL)) { if (xrandr_found && ((x11.XRRQueryVersion = xp_dlsym(dl4, XRRQueryVersion)) == NULL)) {
xp_dlclose(dl4); xp_dlclose(dl4);
......
...@@ -36,9 +36,12 @@ bool load_jxl_funcs(void) ...@@ -36,9 +36,12 @@ bool load_jxl_funcs(void)
return true; return true;
} }
#else #else
static dll_handle jxl_dll;
#ifdef WITH_JPEG_XL_THREADS
static dll_handle jxlt_dll;
#endif
bool load_jxl_funcs(void) bool load_jxl_funcs(void)
{ {
dll_handle jxl_dll;
const char *libnames[] = {"jxl", NULL}; const char *libnames[] = {"jxl", NULL};
if (Jxl.status == JXL_STATUS_OK) if (Jxl.status == JXL_STATUS_OK)
...@@ -49,7 +52,7 @@ bool load_jxl_funcs(void) ...@@ -49,7 +52,7 @@ bool load_jxl_funcs(void)
return false; return false;
Jxl.status = JXL_STATUS_FAILED; Jxl.status = JXL_STATUS_FAILED;
if ((jxl_dll = xp_dlopen(libnames, RTLD_LAZY | RTLD_GLOBAL, JPEGXL_MAJOR_VERSION)) == NULL) if (jxl_dll == NULL && (jxl_dll = xp_dlopen(libnames, RTLD_LAZY | RTLD_GLOBAL, JPEGXL_MAJOR_VERSION)) == NULL)
return false; return false;
if ((Jxl.DecoderCloseInput = xp_dlsym(jxl_dll, JxlDecoderCloseInput)) == NULL) { if ((Jxl.DecoderCloseInput = xp_dlsym(jxl_dll, JxlDecoderCloseInput)) == NULL) {
...@@ -109,7 +112,7 @@ bool load_jxl_funcs(void) ...@@ -109,7 +112,7 @@ bool load_jxl_funcs(void)
const char *tlibnames[] = {"jxl_threads", NULL}; const char *tlibnames[] = {"jxl_threads", NULL};
Jxl.status = JXL_STATUS_FAILED; Jxl.status = JXL_STATUS_FAILED;
if ((jxlt_dll = xp_dlopen(tlibnames, RTLD_LAZY | RTLD_GLOBAL, JPEGXL_MAJOR_VERSION)) == NULL) if (jxlt_dll == NULL && (jxlt_dll = xp_dlopen(tlibnames, RTLD_LAZY | RTLD_GLOBAL, JPEGXL_MAJOR_VERSION)) == NULL)
return true; return true;
if ((Jxl.ResizableParallelRunner = xp_dlsym(jxlt_dll, JxlResizableParallelRunner)) == NULL) { if ((Jxl.ResizableParallelRunner = xp_dlsym(jxlt_dll, JxlResizableParallelRunner)) == NULL) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment