Skip to content
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

Fix configuration manager initialization #1424

Merged
merged 1 commit into from
Jul 30, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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