From 09ac58c30b36192f90013310b303c98eda8cbe6d Mon Sep 17 00:00:00 2001 From: H1ghBre4k3r Date: Wed, 24 Mar 2021 15:52:02 +0100 Subject: [PATCH] Rename sequence number functions to fit pattern --- src/records.c | 4 ++-- src/sequencenumber.c | 4 ++-- src/sequencenumber.h | 4 ++-- src/storage.c | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/records.c b/src/records.c index d1cfbed..514f18d 100644 --- a/src/records.c +++ b/src/records.c @@ -37,11 +37,11 @@ record_t* ens_records_iterator_next(record_iterator_t* iter) { // TODO lome: timestamp? } - if (sequence_number_eq(iter->sn_next, iter->sn_end)) { + if (sn_equal(iter->sn_next, iter->sn_end)) { iter->finished = true; // this iterator will finish after this execution } else { // increase the current sn - iter->sn_next = sequence_number_increment(iter->sn_next); + iter->sn_next = sn_increment(iter->sn_next); } } diff --git a/src/sequencenumber.c b/src/sequencenumber.c index b2ddcab..5d3d514 100644 --- a/src/sequencenumber.c +++ b/src/sequencenumber.c @@ -4,10 +4,10 @@ record_sequence_number_t sn_mask(record_sequence_number_t sn) { return (sn & SN_MASK); } -int sequence_number_eq(record_sequence_number_t a, record_sequence_number_t b) { +int sn_equal(record_sequence_number_t a, record_sequence_number_t b) { return sn_mask(a) == sn_mask(b); } -record_sequence_number_t sequence_number_increment(record_sequence_number_t sn) { +record_sequence_number_t sn_increment(record_sequence_number_t sn) { return sn_mask(++sn); } \ No newline at end of file diff --git a/src/sequencenumber.h b/src/sequencenumber.h index 7865803..e594aeb 100644 --- a/src/sequencenumber.h +++ b/src/sequencenumber.h @@ -24,7 +24,7 @@ record_sequence_number_t sn_mask(record_sequence_number_t sn); * @param b second sequence number * @return 1, if sequence numbers are equal, 0 otherwise. */ -int sequence_number_eq(record_sequence_number_t a, record_sequence_number_t b); +int sn_equal(record_sequence_number_t a, record_sequence_number_t b); /** * Increment the given sequence number. Wraps around, if 2^24 is reached. @@ -32,5 +32,5 @@ int sequence_number_eq(record_sequence_number_t a, record_sequence_number_t b); * @param sn sequence number to increment * @return the incremented sequenced number */ -record_sequence_number_t sequence_number_increment(record_sequence_number_t sn); +record_sequence_number_t sn_increment(record_sequence_number_t sn); #endif \ No newline at end of file diff --git a/src/storage.c b/src/storage.c index 61534ff..a41156c 100644 --- a/src/storage.c +++ b/src/storage.c @@ -60,7 +60,7 @@ int save_storage_information() { void increment_stored_contact_counter() { if (contact_information.count >= MAX_CONTACTS) { - contact_information.oldest_contact = sequence_number_increment(contact_information.oldest_contact); + contact_information.oldest_contact = sn_increment(contact_information.oldest_contact); } else { contact_information.count++; } @@ -105,7 +105,7 @@ int load_contact(contact_t* dest, record_sequence_number_t sn) { } int add_contact(contact_t* src) { - record_sequence_number_t curr_sn = sequence_number_increment(get_latest_sequence_number()); + record_sequence_number_t curr_sn = sn_increment(get_latest_sequence_number()); storage_id_t id = convert_sn_to_storage_id(curr_sn); int rc = nvs_write(&fs, id, src, sizeof(*src));