-
Notifications
You must be signed in to change notification settings - Fork 5k
Fix compilation of Apple native shim on newer Clang #108888
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Newer versions of Clang warn when you are doing enum comparisons of different enum types.
@@ -6,21 +6,21 @@ | |||
|
|||
#include <assert.h> | |||
|
|||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both the enum types are uint32_t
.
@@ -151,7 +151,7 @@ int32_t AppleCryptoNative_X509GetRawData(SecCertificateRef cert, CFDataRef* ppDa | |||
} | |||
|
|||
*ppDataOut = SecCertificateCopyData(cert); | |||
*pOSStatus = *ppDataOut == NULL ? errSecParam : noErr; | |||
*pOSStatus = *ppDataOut == NULL ? errSecParam : (OSStatus)noErr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.