From 7f00ba15e4e199a167a963afbc3a5facfdca4a58 Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Thu, 25 Apr 2019 22:11:12 +0200 Subject: [PATCH] mesh: simplify mesh_transport_key_iterator --- test/mesh/mesh_keys.c | 14 +++++++------- test/mesh/mesh_keys.h | 1 - 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/test/mesh/mesh_keys.c b/test/mesh/mesh_keys.c index 7276ed3f0..ea2fcdb08 100644 --- a/test/mesh/mesh_keys.c +++ b/test/mesh/mesh_keys.c @@ -201,13 +201,17 @@ mesh_transport_key_iterator_init(mesh_transport_key_iterator_t *it, uint16_t net it->netkey_index = netkey_index; it->aid = aid; it->akf = akf; - it->first = 1; - it->key = NULL; + if (it->akf){ + it->key = NULL; + } else { + it->key = &mesh_transport_device_key; + } + } int mesh_transport_key_iterator_has_more(mesh_transport_key_iterator_t *it){ if (it->akf == 0){ - return it->first; + return it->key != NULL; } // find next matching key while (1){ @@ -219,10 +223,6 @@ int mesh_transport_key_iterator_has_more(mesh_transport_key_iterator_t *it){ } const mesh_transport_key_t * mesh_transport_key_iterator_get_next(mesh_transport_key_iterator_t *it){ - if (it->akf == 0) { - it->first = 0; - return &mesh_transport_device_key; - } mesh_transport_key_t * key = it->key; it->key = NULL; return key; diff --git a/test/mesh/mesh_keys.h b/test/mesh/mesh_keys.h index 859595bd7..a85103908 100644 --- a/test/mesh/mesh_keys.h +++ b/test/mesh/mesh_keys.h @@ -104,7 +104,6 @@ typedef struct { uint16_t netkey_index; uint8_t akf; uint8_t aid; - uint8_t first; } mesh_transport_key_iterator_t; /**