Skip to content

Commit

Permalink
Fix configuration manager initialization (nanoframework#1424)
Browse files Browse the repository at this point in the history
***NO_CI***
  • Loading branch information
josesimoes authored Jul 30, 2019
1 parent 15201ed commit 4796a5b
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions targets/CMSIS-OS/ChibiOS/common/targetHAL_ConfigurationManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
// provided as weak so it can be replaced at target level, if required because of the target implementing the storage with a mechanism other then saving to flash
__nfweak void ConfigurationManager_Initialize()
{
// init g_TargetConfiguration
memset(&g_TargetConfiguration, 0, sizeof(HAL_TARGET_CONFIGURATION));

// enumerate the blocks
ConfigurationManager_EnumerateConfigurationBlocks();
};
Expand Down Expand Up @@ -151,8 +154,9 @@ __nfweak bool ConfigurationManager_StoreConfigurationBlock(void* configurationBl

if(configuration == DeviceConfigurationOption_Network)
{
if( g_TargetConfiguration.NetworkInterfaceConfigs->Count == 0 &&
configurationIndex == 0 )
if( g_TargetConfiguration.NetworkInterfaceConfigs == NULL ||
( g_TargetConfiguration.NetworkInterfaceConfigs->Count == 0 &&
configurationIndex == 0 ))
{
// there is no network config block, we are storing the default one
// THIS IS THE ONLY CONFIG BLOCK THAT'S AUTO-CREATED
Expand Down Expand Up @@ -182,8 +186,9 @@ __nfweak bool ConfigurationManager_StoreConfigurationBlock(void* configurationBl
}
else if(configuration == DeviceConfigurationOption_Wireless80211Network)
{
if( g_TargetConfiguration.Wireless80211Configs->Count == 0 ||
(configurationIndex + 1) > g_TargetConfiguration.Wireless80211Configs->Count)
if( g_TargetConfiguration.Wireless80211Configs == NULL ||
(g_TargetConfiguration.Wireless80211Configs->Count == 0 ||
(configurationIndex + 1) > g_TargetConfiguration.Wireless80211Configs->Count))
{
// there is no room for this block, or there are no blocks stored at all
// failing the operation
Expand All @@ -201,8 +206,9 @@ __nfweak bool ConfigurationManager_StoreConfigurationBlock(void* configurationBl
}
else if(configuration == DeviceConfigurationOption_X509CaRootBundle)
{
if( g_TargetConfiguration.CertificateStore->Count == 0 ||
(configurationIndex + 1) > g_TargetConfiguration.CertificateStore->Count)
if( g_TargetConfiguration.Wireless80211Configs == NULL ||
(g_TargetConfiguration.CertificateStore->Count == 0 ||
(configurationIndex + 1) > g_TargetConfiguration.CertificateStore->Count))
{
// there is no room for this block, or there are no blocks stored at all
// failing the operation
Expand Down

0 comments on commit 4796a5b

Please sign in to comment.