Fix compilation of Apple native shim on newer Clang#108888
Fix compilation of Apple native shim on newer Clang#108888vcsjones merged 1 commit intodotnet:mainfrom
Conversation
Newer versions of Clang warn when you are doing enum comparisons of different enum types.
|
|
||
| c_static_assert(PAL_OperationEncrypt == kCCEncrypt); | ||
| c_static_assert(PAL_OperationDecrypt == kCCDecrypt); | ||
| c_static_assert((uint32_t)PAL_OperationEncrypt == (uint32_t)kCCEncrypt); |
There was a problem hiding this comment.
Both the enum types are uint32_t.
|
|
||
| *ppDataOut = SecCertificateCopyData(cert); | ||
| *pOSStatus = *ppDataOut == NULL ? errSecParam : noErr; | ||
| *pOSStatus = *ppDataOut == NULL ? errSecParam : (OSStatus)noErr; |
There was a problem hiding this comment.
This feels like a weird one to me, or the Clang compiler being a little confused. We use noErr all over the place but only complained in this place.
The reason it complains here is it is the only place we don't assign it to some OSStatus as an intermediate, and use it in an expression directly mixing it with an OSStatus. noErr is an anonymous enum in MacTypes.h.
The alternative is to use errSecSuccess. This is functionally the same as noErr (both have a value of 0), but I opted for the smaller change here. It would be a tad weird to use errSecSuccess in this function, but keep using noErr everywhere else, and changing everything seemed unnecessary.
|
With these changes I get a clean build on macOS with Clang 19.1.1. |
|
Hey @vcsjones I want to say thank you for the fix. |
Newer versions of Clang warn when you are doing enum comparisons of different enum types.
Fixes #108827.