Hi Andy,
An error code like CRYPT_E_NOT_FOUND is, in essence, a LONG (signed). Whereas GetLastError() returns a DWORD (unsigned, which does seem inappropriate to me).
Yes, I know what the value of CRYPT_E_NOT_FOUND is, and what the type of GetLastError is. My point is, Microsoft confused signed and unsigned types for their last error values. We have to live with it.
Regarding whether there is a point in removing such errors: I suppose, if we want to apply -Wsign-compare for the whole codebase and have zero warnings during a build, then I don't think we have any choice.
I don't think the cost of adding silly casts or temporaries to avoid giving a warning on a common code idiom is worth it. --Juan