microsoft / SymCrypt

Cryptographic library
MIT License
660 stars 68 forks source link

LLVM Clang error: function with no prototype cannot use the fastcall calling convention #28

Closed ajkhoury closed 11 months ago

ajkhoury commented 1 year ago

Building on Windows with LLVM Clang 15 the following error occurs when targeting the i386 architecture:

SymCrypt\inc\symcrypt.h:493:1: error: function with no prototype cannot use the fastcall calling convention

Clang considers a function with no arguments unprototyped if the function is declared without a void type. See: https://github.com/llvm/llvm-project/issues/28263

Please consider declaring functions without arguments with the void type in the prototype. Below is a patch:

diff --git inc/symcrypt.h inc/symcrypt.h
index 8ae5fb3..a4570ea 100644
--- inc/symcrypt.h
+++ inc/symcrypt.h
@@ -490,7 +490,7 @@ SymCryptUint64Bytesize( UINT64 value );

 VOID
 SYMCRYPT_CALL
-SymCryptInit();
+SymCryptInit( void );
 //
 // Initialize the static library.
 // This function MUST be called before any other function in the library.
@@ -893,7 +893,7 @@ SymCryptMd2StateImport(

 VOID
 SYMCRYPT_CALL
-SymCryptMd2Selftest();
+SymCryptMd2Selftest( void );

 extern const PCSYMCRYPT_HASH SymCryptMd2Algorithm;

@@ -956,7 +956,7 @@ SymCryptMd4StateImport(

 VOID
 SYMCRYPT_CALL
-SymCryptMd4Selftest();
+SymCryptMd4Selftest( void );

 extern const PCSYMCRYPT_HASH SymCryptMd4Algorithm;

@@ -1019,7 +1019,7 @@ SymCryptMd5StateImport(

 VOID
 SYMCRYPT_CALL
-SymCryptMd5Selftest();
+SymCryptMd5Selftest( void );

 extern const PCSYMCRYPT_HASH SymCryptMd5Algorithm;

@@ -1157,7 +1157,7 @@ SymCryptSha256StateImport(

 VOID
 SYMCRYPT_CALL
-SymCryptSha256Selftest();
+SymCryptSha256Selftest( void );

 extern const PCSYMCRYPT_HASH SymCryptSha256Algorithm;

@@ -1222,7 +1222,7 @@ SymCryptSha384StateImport(

 VOID
 SYMCRYPT_CALL
-SymCryptSha384Selftest();
+SymCryptSha384Selftest( void );

 extern const PCSYMCRYPT_HASH SymCryptSha384Algorithm;

@@ -1287,7 +1287,7 @@ SymCryptSha512StateImport(

 VOID
 SYMCRYPT_CALL
-SymCryptSha512Selftest();
+SymCryptSha512Selftest( void );

 extern const PCSYMCRYPT_HASH SymCryptSha512Algorithm;

@@ -1356,7 +1356,7 @@ SymCryptSha3_256StateImport(

 VOID
 SYMCRYPT_CALL
-SymCryptSha3_256Selftest();
+SymCryptSha3_256Selftest( void );

 extern const PCSYMCRYPT_HASH SymCryptSha3_256Algorithm;

@@ -1410,7 +1410,7 @@ SymCryptSha3_384StateImport(

 VOID
 SYMCRYPT_CALL
-SymCryptSha3_384Selftest();
+SymCryptSha3_384Selftest( void );

 extern const PCSYMCRYPT_HASH SymCryptSha3_384Algorithm;

@@ -1464,7 +1464,7 @@ SymCryptSha3_512StateImport(

 VOID
 SYMCRYPT_CALL
-SymCryptSha3_512Selftest();
+SymCryptSha3_512Selftest( void );

 extern const PCSYMCRYPT_HASH SymCryptSha3_512Algorithm;

@@ -1654,7 +1654,7 @@ SymCryptShake128StateCopy(_In_ PCSYMCRYPT_SHAKE128_STATE pSrc, _Out_ PSYMCRYPT_S

 VOID
 SYMCRYPT_CALL
-SymCryptShake128Selftest();
+SymCryptShake128Selftest( void );

 extern const PCSYMCRYPT_HASH SymCryptShake128HashAlgorithm;

@@ -1711,7 +1711,7 @@ SymCryptShake256StateCopy(_In_ PCSYMCRYPT_SHAKE256_STATE pSrc, _Out_ PSYMCRYPT_S

 VOID
 SYMCRYPT_CALL
-SymCryptShake256Selftest();
+SymCryptShake256Selftest( void );

 extern const PCSYMCRYPT_HASH SymCryptShake256HashAlgorithm;

@@ -1835,7 +1835,7 @@ SymCryptCShake128StateCopy(_In_ PCSYMCRYPT_CSHAKE128_STATE pSrc, _Out_ PSYMCRYPT

 VOID
 SYMCRYPT_CALL
-SymCryptCShake128Selftest();
+SymCryptCShake128Selftest( void );

 //
@@ -1892,7 +1892,7 @@ SymCryptCShake256StateCopy(_In_ PCSYMCRYPT_CSHAKE256_STATE pSrc, _Out_ PSYMCRYPT

 VOID
 SYMCRYPT_CALL
-SymCryptCShake256Selftest();
+SymCryptCShake256Selftest( void );

@@ -2064,15 +2064,15 @@ SymCryptParallelSha512Process(

 VOID
 SYMCRYPT_CALL
-SymCryptParallelSha256Selftest();
+SymCryptParallelSha256Selftest( void );

 VOID
 SYMCRYPT_CALL
-SymCryptParallelSha384Selftest();
+SymCryptParallelSha384Selftest( void );

 VOID
 SYMCRYPT_CALL
-SymCryptParallelSha512Selftest();
+SymCryptParallelSha512Selftest( void );

@@ -2326,7 +2326,7 @@ SymCryptHmacMd5Result(

 VOID
 SYMCRYPT_CALL
-SymCryptHmacMd5Selftest();
+SymCryptHmacMd5Selftest( void );

 extern const PCSYMCRYPT_MAC SymCryptHmacMd5Algorithm;

@@ -2391,7 +2391,7 @@ SymCryptHmacSha1Result(

 VOID
 SYMCRYPT_CALL
-SymCryptHmacSha1Selftest();
+SymCryptHmacSha1Selftest( void );

 extern const PCSYMCRYPT_MAC SymCryptHmacSha1Algorithm;

@@ -2455,7 +2455,7 @@ SymCryptHmacSha256Result(

 VOID
 SYMCRYPT_CALL
-SymCryptHmacSha256Selftest();
+SymCryptHmacSha256Selftest( void );

 extern const PCSYMCRYPT_MAC  SymCryptHmacSha256Algorithm;

@@ -2519,7 +2519,7 @@ SymCryptHmacSha384Result(

 VOID
 SYMCRYPT_CALL
-SymCryptHmacSha384Selftest();
+SymCryptHmacSha384Selftest( void );

 extern const PCSYMCRYPT_MAC  SymCryptHmacSha384Algorithm;

@@ -2583,7 +2583,7 @@ SymCryptHmacSha512Result(

 VOID
 SYMCRYPT_CALL
-SymCryptHmacSha512Selftest();
+SymCryptHmacSha512Selftest( void );

 extern const PCSYMCRYPT_MAC  SymCryptHmacSha512Algorithm;

@@ -2649,7 +2649,7 @@ SymCryptAesCmacResult(

 VOID
 SYMCRYPT_CALL
-SymCryptAesCmacSelftest();
+SymCryptAesCmacSelftest( void );

 extern const PCSYMCRYPT_MAC SymCryptAesCmacAlgorithm;

@@ -2908,7 +2908,7 @@ SymCryptKmac128StateCopy(_In_ const SYMCRYPT_KMAC128_STATE* pSrc, _Out_ SYMCRYPT

 VOID
 SYMCRYPT_CALL
-SymCryptKmac128Selftest();
+SymCryptKmac128Selftest( void );

 extern const PCSYMCRYPT_MAC SymCryptKmac128Algorithm;

@@ -2995,7 +2995,7 @@ SymCryptKmac256StateCopy(_In_ const SYMCRYPT_KMAC256_STATE* pSrc, _Out_ SYMCRYPT

 VOID
 SYMCRYPT_CALL
-SymCryptKmac256Selftest();
+SymCryptKmac256Selftest( void );

 extern const PCSYMCRYPT_MAC SymCryptKmac256Algorithm;

@@ -3047,7 +3047,7 @@ SymCryptPoly1305Result(

 VOID
 SYMCRYPT_CALL
-SymCryptPoly1305Selftest();
+SymCryptPoly1305Selftest( void );

 //
 // We do NOT define a SYMCRYPT_MAC structure SymCryptPoly1305Algorithm
@@ -3103,7 +3103,7 @@ SymCryptChaCha20Poly1305Decrypt(

 VOID
 SYMCRYPT_CALL
-SymCryptChaCha20Poly1305Selftest();
+SymCryptChaCha20Poly1305Selftest( void );

 ////////////////////////////////////////////////////////////////////////////
 //   MARVIN32
@@ -3205,7 +3205,7 @@ SymCryptMarvin32Result(

 VOID
 SYMCRYPT_CALL
-SymCryptMarvin32Selftest();
+SymCryptMarvin32Selftest( void );

 //==========================================================================
@@ -3571,7 +3571,7 @@ SymCryptDesSetOddParity(

 VOID
 SYMCRYPT_CALL
-SymCryptDesSelftest();
+SymCryptDesSelftest( void );

 extern const PCSYMCRYPT_BLOCKCIPHER SymCryptDesBlockCipher;

@@ -3634,7 +3634,7 @@ SymCrypt3DesCbcDecrypt(

 VOID
 SYMCRYPT_CALL
-SymCrypt3DesSelftest();
+SymCrypt3DesSelftest( void );

 extern const PCSYMCRYPT_BLOCKCIPHER SymCrypt3DesBlockCipher;

@@ -3672,7 +3672,7 @@ SymCryptDesxDecrypt(

 VOID
 SYMCRYPT_CALL
-SymCryptDesxSelftest();
+SymCryptDesxSelftest( void );

 extern const PCSYMCRYPT_BLOCKCIPHER SymCryptDesxBlockCipher;

@@ -3743,7 +3743,7 @@ SymCryptRc2Decrypt(

 VOID
 SYMCRYPT_CALL
-SymCryptRc2Selftest();
+SymCryptRc2Selftest( void );

 extern const PCSYMCRYPT_BLOCKCIPHER SymCryptRc2BlockCipher;

@@ -4201,7 +4201,7 @@ SymCryptCcmDecryptFinal(

 VOID
 SYMCRYPT_CALL
-SymCryptCcmSelftest();
+SymCryptCcmSelftest( void );
 //
 // Self test for CCM cipher mode
 //
@@ -4395,7 +4395,7 @@ SymCryptGcmDecryptFinal(

 VOID
 SYMCRYPT_CALL
-SymCryptGcmSelftest();
+SymCryptGcmSelftest( void );
 //
 // Self test for GCM cipher mode
 //
@@ -4591,7 +4591,7 @@ SymCryptRc4Crypt(

 VOID
 SYMCRYPT_CALL
-SymCryptRc4Selftest();
+SymCryptRc4Selftest( void );

 //
@@ -4667,7 +4667,7 @@ SymCryptChaCha20Crypt(

 VOID
 SYMCRYPT_CALL
-SymCryptChaCha20Selftest();
+SymCryptChaCha20Selftest( void );

@@ -4726,11 +4726,11 @@ SymCryptPbkdf2(

 VOID
 SYMCRYPT_CALL
-SymCryptPbkdf2_HmacSha1SelfTest();
+SymCryptPbkdf2_HmacSha1SelfTest( void );

 VOID
 SYMCRYPT_CALL
-SymCryptPbkdf2_HmacSha256SelfTest();
+SymCryptPbkdf2_HmacSha256SelfTest( void );

 ////////////////////////////////////////////////////////////////////////////
 // SP800-108 Counter mode
@@ -4777,19 +4777,19 @@ SymCryptSp800_108(

 VOID
 SYMCRYPT_CALL
-SymCryptSp800_108_HmacSha1SelfTest();
+SymCryptSp800_108_HmacSha1SelfTest( void );

 VOID
 SYMCRYPT_CALL
-SymCryptSp800_108_HmacSha256SelfTest();
+SymCryptSp800_108_HmacSha256SelfTest( void );

 VOID
 SYMCRYPT_CALL
-SymCryptSp800_108_HmacSha384SelfTest();
+SymCryptSp800_108_HmacSha384SelfTest( void );

 VOID
 SYMCRYPT_CALL
-SymCryptSp800_108_HmacSha512SelfTest();
+SymCryptSp800_108_HmacSha512SelfTest( void );

 ////////////////////////////////////////////////////////////////////////////
 // TLS Key Derivation PRFs
@@ -4840,7 +4840,7 @@ SymCryptTlsPrf1_1(

 VOID
 SYMCRYPT_CALL
-SymCryptTlsPrf1_1SelfTest();
+SymCryptTlsPrf1_1SelfTest( void );

 //
 //  Version 1.2
@@ -4879,7 +4879,7 @@ SymCryptTlsPrf1_2(

 VOID
 SYMCRYPT_CALL
-SymCryptTlsPrf1_2SelfTest();
+SymCryptTlsPrf1_2SelfTest( void );

 ////////////////////////////////////////////////////////////////////////////
@@ -4980,11 +4980,11 @@ SymCryptSshKdf(

 VOID
 SYMCRYPT_CALL
-SymCryptSshKdfSha256SelfTest();
+SymCryptSshKdfSha256SelfTest( void );

 VOID
 SYMCRYPT_CALL
-SymCryptSshKdfSha512SelfTest();
+SymCryptSshKdfSha512SelfTest( void );

 ////////////////////////////////////////////////////////////////////////////
@@ -5089,7 +5089,7 @@ SymCryptSrtpKdf(

 VOID
 SYMCRYPT_CALL
-SymCryptSrtpKdfSelfTest();
+SymCryptSrtpKdfSelfTest( void );

 ////////////////////////////////////////////////////////////////////////////
@@ -5170,7 +5170,7 @@ SymCryptHkdf(

 VOID
 SYMCRYPT_CALL
-SymCryptHkdfSelfTest();
+SymCryptHkdfSelfTest( void );

 //==========================================================================
 //   RNG ALGORITHMS
@@ -5274,7 +5274,7 @@ SymCryptRngAesUninstantiate(

 VOID
 SYMCRYPT_CALL
-SymCryptRngAesInstantiateSelftest();
+SymCryptRngAesInstantiateSelftest( void );
 //
 // For FIPS-certified modules, this function should be called before every instantiation.
 // If multiple DRBGs are instantiated 'in quick succession', a single self-test is sufficient
@@ -5284,14 +5284,14 @@ SymCryptRngAesInstantiateSelftest();

 VOID
 SYMCRYPT_CALL
-SymCryptRngAesReseedSelftest();
+SymCryptRngAesReseedSelftest( void );
 //
 // FIPS-certified modules should call this function before every call to the reseed function.
 //

 VOID
 SYMCRYPT_CALL
-SymCryptRngAesGenerateSelftest();
+SymCryptRngAesGenerateSelftest( void );
 //
 // FIPS-certified modules should call this function at least once on startup, and whenever
 // they want to re-test the generate function.
@@ -5388,7 +5388,7 @@ SymCryptProvideEntropy(

 SYMCRYPT_ERROR
 SYMCRYPT_CALL
-SymCryptRdrandStatus();
+SymCryptRdrandStatus( void );
 //
 // Returns SYMCRYPT_NO_ERROR if RdRand is available.
 // returns SYMCRYPT_NOT_IMPLEMENTED if RdRand is not available.
@@ -5442,7 +5442,7 @@ SymCryptRdrandGet(

 SYMCRYPT_ERROR
 SYMCRYPT_CALL
-SymCryptRdseedStatus();
+SymCryptRdseedStatus( void );
 //
 // Returns SYMCRYPT_NO_ERROR if RdSeed is available.
 // returns SYMCRYPT_NOT_IMPLEMENTED if RdSeed is not available.
@@ -5514,7 +5514,7 @@ SymCryptXtsAesDecrypt(

 VOID
 SYMCRYPT_CALL
-SymCryptXtsAesSelftest();
+SymCryptXtsAesSelftest( void );

 ////////////////////////////////////////////////////////////////////////////////////////////
@@ -5695,7 +5695,7 @@ SymCryptCallbackRandom(

 PVOID
 SYMCRYPT_CALL
-SymCryptCallbackAllocateMutexFastInproc();
+SymCryptCallbackAllocateMutexFastInproc( void );
 //
 // Allocate and initialize a mutex object; returns NULL on failure.
 //
@@ -7514,7 +7514,7 @@ SymCryptRsaPssVerify(

 VOID
 SYMCRYPT_CALL
-SymCryptRsaSelftest( );
+SymCryptRsaSelftest( void );
 //
 // FIPS self-test for RSA sign/verify. This function uses a hardcoded key to perform the self-test
 // without having to generate a key. If the self-test fails, SymCryptFatal will be called to
@@ -7571,7 +7571,7 @@ SymCryptDsaVerify(

 VOID
 SYMCRYPT_CALL
-SymCryptDsaSelftest( );
+SymCryptDsaSelftest( void );
 //
 // FIPS self-test for DSA sign/verify. This function uses a hardcoded key to perform the self-test
 // without having to generate a key. If the self-test fails, SymCryptFatal will be called to
@@ -7605,7 +7605,7 @@ SymCryptDhSecretAgreement(

 VOID
 SYMCRYPT_CALL
-SymCryptDhSecretAgreementSelftest();
+SymCryptDhSecretAgreementSelftest( void );
 //
 // FIPS self-test for DH secret agreement. This function uses two hardcoded keys and a precalculated
 // known answer to perform the self-test without having to generate a key. If the self-test fails,
@@ -7669,7 +7669,7 @@ SymCryptEcDsaVerify(

 VOID
 SYMCRYPT_CALL
-SymCryptEcDsaSelftest( );
+SymCryptEcDsaSelftest( void );
 //
 // FIPS self-test for ECDSA sign/verify. This function uses a hardcoded key to perform the self-test
 // without having to generate a key. If the self-test fails, SymCryptFatal will be called to
@@ -7702,7 +7702,7 @@ SymCryptEcDhSecretAgreement(

 VOID
 SYMCRYPT_CALL
-SymCryptEcDhSecretAgreementSelftest( );
+SymCryptEcDhSecretAgreementSelftest( void );
 //
 // FIPS self-test for ECDH secret agreement. This function uses two hardcoded keys and a
 // precalculated known answer to perform the self-test without having to generate a key. If the
diff --git inc/symcrypt_internal.h inc/symcrypt_internal.h
index 36b91d7..5f3912f 100644
--- inc/symcrypt_internal.h
+++ inc/symcrypt_internal.h
@@ -420,7 +420,7 @@ extern SYMCRYPT_CPU_FEATURES g_SymCryptCpuFeaturesNotPresent;

 SYMCRYPT_CPU_FEATURES
 SYMCRYPT_CALL
-SymCryptCpuFeaturesNeverPresent();
+SymCryptCpuFeaturesNeverPresent(void);

 #define SYMCRYPT_CPU_FEATURES_PRESENT( x )   ( ((x) & SymCryptCpuFeaturesNeverPresent()) == 0 && ( (x) & g_SymCryptCpuFeaturesNotPresent ) == 0 )

@@ -2671,14 +2671,14 @@ typedef struct _SYMCRYPT_EXTENDED_SAVE_DATA      SYMCRYPT_EXTENDED_SAVE_DATA, *P
 #define SYMCRYPT_ENVIRONMENT_DEFS( envName ) \
 SYMCRYPT_EXTERN_C \
     VOID SYMCRYPT_CALL SymCryptInitEnv##envName( UINT32 version ); \
-    VOID SYMCRYPT_CALL SymCryptInit() \
+    VOID SYMCRYPT_CALL SymCryptInit( void ) \
         { SymCryptInitEnv##envName( SYMCRYPT_API_VERSION ); } \
     \
     _Analysis_noreturn_ VOID SYMCRYPT_CALL SymCryptFatalEnv##envName( UINT32 fatalCode ); \
     _Analysis_noreturn_ VOID SYMCRYPT_CALL SymCryptFatal( UINT32 fatalCode ) \
         { SymCryptFatalEnv##envName( fatalCode ); } \
-    SYMCRYPT_CPU_FEATURES SYMCRYPT_CALL SymCryptCpuFeaturesNeverPresentEnv##envName(); \
-    SYMCRYPT_CPU_FEATURES SYMCRYPT_CALL SymCryptCpuFeaturesNeverPresent() \
+    SYMCRYPT_CPU_FEATURES SYMCRYPT_CALL SymCryptCpuFeaturesNeverPresentEnv##envName( void ); \
+    SYMCRYPT_CPU_FEATURES SYMCRYPT_CALL SymCryptCpuFeaturesNeverPresent( void ) \
         { return SymCryptCpuFeaturesNeverPresentEnv##envName(); } \
     \
     SYMCRYPT_ENVIRONMENT_DEFS_SAVEXMM( envName ) \
@@ -2886,7 +2886,7 @@ extern UINT32 g_SymCryptFipsSelftestsPerformed;

 UINT32
 SYMCRYPT_CALL
-SymCryptFipsGetSelftestsPerformed();
+SymCryptFipsGetSelftestsPerformed(void);
 // Returns current value of g_SymCryptFipsSelftestsPerformed so callers may inspect which FIPS
 // algorithm selftests have run

diff --git lib/sc_lib.h lib/sc_lib.h
index aa8c34f..b86673f 100644
--- lib/sc_lib.h
+++ lib/sc_lib.h
@@ -236,12 +236,12 @@ SymCryptRestoreYmm( _Inout_ PSYMCRYPT_EXTENDED_SAVE_DATA pSaveData );

 VOID
 SYMCRYPT_CALL
-SymCryptLibraryWasNotInitialized();
+SymCryptLibraryWasNotInitialized( void );

 FORCEINLINE
 VOID
 SYMCRYPT_CALL
-SymCryptCheckLibraryInitialized()
+SymCryptCheckLibraryInitialized( void )
 {
     if( !(g_SymCryptFlags & SYMCRYPT_FLAG_LIB_INITIALIZED)  )
     {
@@ -252,7 +252,7 @@ SymCryptCheckLibraryInitialized()
 FORCEINLINE
 VOID
 SYMCRYPT_CALL
-SymCryptCheckLibraryInitialized()
+SymCryptCheckLibraryInitialized( void )
 {
 }
 #endif
@@ -988,15 +988,15 @@ SymCryptDetectCpuFeaturesByCpuid( UINT32 flags );

 VOID
 SYMCRYPT_CALL
-SymCryptDetectCpuFeaturesFromRegisters();
+SymCryptDetectCpuFeaturesFromRegisters( void );

 VOID
 SYMCRYPT_CALL
-SymCryptDetectCpuFeaturesFromRegistersNoTry();
+SymCryptDetectCpuFeaturesFromRegistersNoTry( void );

 VOID
 SYMCRYPT_CALL
-SymCryptDetectCpuFeaturesFromIsProcessorFeaturePresent();
+SymCryptDetectCpuFeaturesFromIsProcessorFeaturePresent( void );

 VOID
 SYMCRYPT_CALL
mlindgren commented 1 year ago

Thanks for your report. We're working on a fix for this which we'll publish with our next release.

mlindgren commented 11 months ago

This is fixed by commit 770f81ffb4df736c40f5c4639b058ea812e7abba