Skip to content

Commit a0b112a

Browse files
author
Mika Leppänen
committed
Corrected defects and coding style
1 parent 2f4678a commit a0b112a

File tree

1 file changed

+20
-28
lines changed

1 file changed

+20
-28
lines changed

source/6LoWPAN/ws/ws_pae_key_storage.c

Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ typedef struct {
101101
uint16_t store_timer; /**< Storing timer */
102102
uint32_t restart_cnt; /**< Re-start counter */
103103
uint32_t scatter_timer; /**< NVM storing scatter timer */
104-
bool scatter_timer_running : 1; /**< NVM storing scatter timer is running */
105104
} key_storage_params_t;
106105

107106
static key_storage_params_t key_storage_params;
@@ -170,7 +169,6 @@ void ws_pae_key_storage_init(void)
170169
key_storage_params.store_bitfield = 0,
171170
key_storage_params.restart_cnt = 0;
172171
key_storage_params.scatter_timer = 0;
173-
key_storage_params.scatter_timer_running = false;
174172
}
175173

176174
void ws_pae_key_storage_delete(void)
@@ -720,31 +718,30 @@ static void ws_pae_key_storage_scatter_timer_timeout(void)
720718
bool pending_entry = false;
721719

722720
ns_list_foreach(key_storage_array_t, entry, &key_storage_array_list) {
723-
if (!entry->pending_storing) {
724-
entry_offset++;
725-
continue;
726-
}
727-
pending_entry = true;
728-
729-
char filename[KEY_STORAGE_FILE_LEN];
730-
ws_pae_key_storage_filename_set(filename, entry_offset);
731-
tr_info("KeyS write array: %p file: %s", (void *) entry->storage_array, filename);
732-
nvm_tlv_t *tlv = (nvm_tlv_t *) entry->storage_array_handle;
733-
ws_pae_nvm_store_tlv_file_write(filename, tlv);
734-
735-
// Item has been stored, reset pending storing and modified flag
736-
entry->pending_storing = false;
737-
entry->modified = false;
738-
break;
739-
}
721+
if (!entry->pending_storing) {
722+
entry_offset++;
723+
continue;
724+
}
725+
pending_entry = true;
726+
727+
char filename[KEY_STORAGE_FILE_LEN];
728+
ws_pae_key_storage_filename_set(filename, entry_offset);
729+
tr_info("KeyS write array: %p file: %s", (void *) entry->storage_array, filename);
730+
nvm_tlv_t *tlv = (nvm_tlv_t *) entry->storage_array_handle;
731+
ws_pae_nvm_store_tlv_file_write(filename, tlv);
732+
733+
// Item has been stored, reset pending storing and modified flag
734+
entry->pending_storing = false;
735+
entry->modified = false;
736+
break;
737+
}
740738

741739
if (pending_entry) {
742740
ws_pae_key_storage_fast_timer_ticks_set();
743741
return;
744742
}
745743

746744
tr_info("KeyS all pending entries stored");
747-
key_storage_params.scatter_timer_running = false;
748745
}
749746

750747
void ws_pae_key_storage_read(uint32_t restart_cnt)
@@ -897,11 +894,9 @@ void ws_pae_key_storage_timer(uint16_t seconds)
897894

898895
void ws_pae_key_storage_fast_timer(uint16_t ticks)
899896
{
900-
if (!key_storage_params.scatter_timer_running) {
897+
if (key_storage_params.scatter_timer == 0) {
901898
return;
902-
}
903-
904-
if (key_storage_params.scatter_timer > ticks) {
899+
} else if (key_storage_params.scatter_timer > ticks) {
905900
key_storage_params.scatter_timer -= ticks;
906901
} else {
907902
key_storage_params.scatter_timer = 0;
@@ -911,10 +906,7 @@ void ws_pae_key_storage_fast_timer(uint16_t ticks)
911906

912907
static void ws_pae_key_storage_fast_timer_start(void)
913908
{
914-
if (!key_storage_params.scatter_timer_running) {
915-
key_storage_params.scatter_timer_running = true;
916-
ws_pae_key_storage_fast_timer_ticks_set();
917-
}
909+
ws_pae_key_storage_fast_timer_ticks_set();
918910
}
919911

920912
static void ws_pae_key_storage_fast_timer_ticks_set(void)

0 commit comments

Comments
 (0)