udev: Clear intermediate errors when attempting to load libudev.so #8419
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Call
SDL_ClearError()
after a successfulSDL_LoadObject()
call to clear the previous error left over by the previousSDL_UDEV_load_syms()
procedure (set bySDL_LoadFunction()
). This ensures that no error is set whenSDL_UDEV_Init()
returns successfully.SDL_UDEV_LoadLibrary()
first attempts to find udev symbols in the libraries that are already loaded, then attempts to find and loadlibudev.so*
using a list of names. Every unsuccessful call toSDL_UDEV_load_syms()
leaves the error set. However, if a subsequent call succeeds (i.e. after loading the library), the previous error remains set untilSDL_UDEV_Init()
returns.This is a serious problem in SDL2 since the (stale) error leaks to the caller after:
In SDL3, the issue is still present but the error is incidentally cleared by the call to
PLATFORM_hid_init()
.