Core: defensive programming

Defensively set return-by-reference value to -1 in error condition

NB: The comments do not match the implementation.

Comments: "[return] the index of the configuration matching a specific
bConfigurationValue in the idx output parameter, or -1 if the config was
not found"

There is a code path where idx is never touched. Perhaps clients of the
function are careful to only read idx if the return value is success,
but also setting idx to -1 is much safer.