@@ -674,7 +674,7 @@ bool CheckHashRange(const std::vector<HashRange>& hashes)
674
674
return false ;
675
675
}
676
676
677
- static void LoadFromRegKeyOrEnvVarOrOptions (const std::string& options = " " , std::string registrykeypath = IGC_REGISTRY_KEY)
677
+ static void LoadFromRegKeyOrEnvVarOrOptions (const std::string& options = " " , bool * RegFlagNameError = nullptr , std::string registrykeypath = IGC_REGISTRY_KEY)
678
678
{
679
679
SRegKeyVariableMetaData* pRegKeyVariable = (SRegKeyVariableMetaData*)&g_RegKeyList;
680
680
unsigned NUM_REGKEY_ENTRIES = sizeof (SRegKeysList) / sizeof (SRegKeyVariableMetaData);
@@ -703,32 +703,39 @@ static void LoadFromRegKeyOrEnvVarOrOptions(const std::string& options = "", std
703
703
std::size_t foundComma = options.find (' ,' , found);
704
704
if (foundComma != std::string::npos)
705
705
{
706
- std::string token = options.substr (found + nameWithEqual.size (), foundComma - (found + nameWithEqual.size ()));
707
- unsigned int size = sizeof (value);
708
- void * pValueFromOptions = &valueFromOptions;
709
-
710
- const char * envValFromOptions = token.c_str ();
711
- bool valueIsInt = false ;
712
- if (envValFromOptions != NULL )
706
+ if (found == 0 || options[found - 1 ] == ' ' || options[found - 1 ] == ' ,' )
713
707
{
714
- if (size >= sizeof (unsigned int ))
708
+ std::string token = options.substr (found + nameWithEqual.size (), foundComma - (found + nameWithEqual.size ()));
709
+ unsigned int size = sizeof (value);
710
+ void * pValueFromOptions = &valueFromOptions;
711
+
712
+ const char * envValFromOptions = token.c_str ();
713
+ bool valueIsInt = false ;
714
+ if (envValFromOptions != NULL )
715
715
{
716
- // Try integer conversion
717
- char * pStopped = nullptr ;
718
- unsigned int * puValFromOptions = (unsigned int *)pValueFromOptions;
719
- *puValFromOptions = strtoul (envValFromOptions, &pStopped, 0 );
720
- if (pStopped == envValFromOptions + strlen (envValFromOptions))
716
+ if (size >= sizeof (unsigned int ))
721
717
{
722
- valueIsInt = true ;
718
+ // Try integer conversion
719
+ char * pStopped = nullptr ;
720
+ unsigned int * puValFromOptions = (unsigned int *)pValueFromOptions;
721
+ *puValFromOptions = strtoul (envValFromOptions, &pStopped, 0 );
722
+ if (pStopped == envValFromOptions + strlen (envValFromOptions))
723
+ {
724
+ valueIsInt = true ;
725
+ }
726
+ }
727
+ if (!valueIsInt)
728
+ {
729
+ // Just return the string
730
+ strncpy_s ((char *)pValueFromOptions, size, envValFromOptions, size);
723
731
}
724
732
}
725
- if (!valueIsInt)
726
- {
727
- // Just return the string
728
- strncpy_s (( char *)pValueFromOptions, size, envValFromOptions, size);
729
- }
733
+ memcpy_s (pRegKeyVariable[i]. m_string , sizeof (valueFromOptions), valueFromOptions, sizeof (valueFromOptions));
734
+ }
735
+ else if (RegFlagNameError != nullptr )
736
+ {
737
+ *RegFlagNameError = true ;
730
738
}
731
- memcpy_s (pRegKeyVariable[i].m_string , sizeof (valueFromOptions), valueFromOptions, sizeof (valueFromOptions));
732
739
}
733
740
}
734
741
}
@@ -754,7 +761,7 @@ void SetCurrentDebugHash(unsigned long long hash)
754
761
None
755
762
756
763
\*****************************************************************************/
757
- void LoadRegistryKeys (const std::string& options)
764
+ void LoadRegistryKeys (const std::string& options, bool *RegFlagNameError )
758
765
{
759
766
// only load the debug flags once before compiling to avoid any multi-threading issue
760
767
static std::mutex loadFlags;
@@ -772,12 +779,12 @@ void LoadRegistryKeys(const std::string& options)
772
779
{
773
780
std::string driverStoreRegKeyPath = getNewRegistryPath (driverInfo);
774
781
std::string registryKeyPath = " SYSTEM\\ ControlSet001\\ Control\\ Class\\ " + driverStoreRegKeyPath + " \\ IGC" ;
775
- LoadFromRegKeyOrEnvVarOrOptions (options, registryKeyPath);
782
+ LoadFromRegKeyOrEnvVarOrOptions (options, RegFlagNameError, registryKeyPath);
776
783
}
777
784
#endif
778
785
// DumpIGCRegistryKeyDefinitions();
779
786
LoadDebugFlagsFromFile ();
780
- LoadFromRegKeyOrEnvVarOrOptions (options);
787
+ LoadFromRegKeyOrEnvVarOrOptions (options, RegFlagNameError );
781
788
782
789
if (IGC_IS_FLAG_ENABLED (LLVMCommandLine))
783
790
{
0 commit comments