]> sigrok.org Git - libserialport.git/commit
windows: Handle registry lookup failures correctly.
authorMartin Ling <redacted>
Mon, 20 Jan 2020 01:28:17 +0000 (01:28 +0000)
committerMartin Ling <redacted>
Thu, 23 Jan 2020 03:35:47 +0000 (03:35 +0000)
commitc79e0ac8ef8e978de0a5bc15af0b555ba59d7da0
tree1cb4e8722146999dfff83c9bc8f455ec943eb0ca
parent060d1d8a7398851288caf66059b7858cdd6ee11c
windows: Handle registry lookup failures correctly.

RegOpenKeyEx() and RegQueryInfoKey() return system error codes directly,
not by setting the thread-local errno equivalent that is returned by
GetLastError().

When returning SP_ERR_FAIL, our API specifies that sp_last_error_code()
may be called immediately afterwards to get the system error code. In
this case that would not work, as it would call GetLastError() and miss
the directly-returned result.

We therefore need to call SetLastError() with the error code before
returning with SP_ERR_FAIL.
windows.c