We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 4548

Summary: Fix DirectInput error codes being silently discarded.
Product: SDL Reporter: Jimb Esser <wasteland>
Component: joystickAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2    
Version: HG 2.1   
Hardware: x86   
OS: Windows 10   
Attachments: Patch

Description Jimb Esser 2019-03-12 22:14:05 UTC
Created attachment 3696 [details]
Patch

SDL_dinputjoystick.c:SetDIerror includes the line:
  SDL_SetError("%s() DirectX error 0x%8.8lx", function, code);

SDL_SetError() does not handle %lx

Due to this, SDL_GetErrorMsg() returns a string like "... DirectX error 0x", silently discarding the error code, making troubleshooting difficult.

Fix here: https://github.com/Jimbly/SDL/commit/76fe4910590a2fe1d3ea4d78bb090c785b0bc32c
Patch attached.

The fix trivially adds support for %lx to SDL_SetError and SDL_GetErrorMsg.  Changing the SDL_SetError call to "%8.8x" would also reasonably fix this.
Comment 1 Sam Lantinga 2019-03-17 01:11:32 UTC
Fixed, thanks!
https://hg.libsdl.org/SDL/rev/8a70b87401c3