This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
laforge gerrit-no-reply at lists.osmocom.orglaforge has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/19295 ) Change subject: stat_item: Add function to reset stat items and groups ...................................................................... stat_item: Add function to reset stat items and groups Change-Id: I80fc0ea8865ec4efdcd4c982e69d863275fd9919 Related: SYS#4877 --- M TODO-RELEASE M include/osmocom/core/stat_item.h M src/stat_item.c 3 files changed, 34 insertions(+), 0 deletions(-) Approvals: laforge: Looks good to me, approved pespin: Looks good to me, but someone else must approve Jenkins Builder: Verified diff --git a/TODO-RELEASE b/TODO-RELEASE index 3696681..a4d9dfb 100644 --- a/TODO-RELEASE +++ b/TODO-RELEASE @@ -16,3 +16,4 @@ gsm new API new gsm0808_create_common_id() gb new API new bssgp_tx_bvc_reset2() core new API new rate_ctr_reset(), rate_ctr_group_reset() +core new API new osmo_stat_item_reset(), osmo_stat_item_group_reset() diff --git a/include/osmocom/core/stat_item.h b/include/osmocom/core/stat_item.h index 806173a..4710dba 100644 --- a/include/osmocom/core/stat_item.h +++ b/include/osmocom/core/stat_item.h @@ -114,4 +114,8 @@ { return item->values[item->last_offs].value; } + +void osmo_stat_item_reset(struct osmo_stat_item *item); +void osmo_stat_item_group_reset(struct osmo_stat_item_group *statg); + /*! @} */ diff --git a/src/stat_item.c b/src/stat_item.c index 6716575..ba36464 100644 --- a/src/stat_item.c +++ b/src/stat_item.c @@ -356,4 +356,33 @@ return rc; } + +/*! Remove all values of a stat item + * \param[in] item stat item to reset + */ +void osmo_stat_item_reset(struct osmo_stat_item *item) +{ + unsigned int i; + + item->last_offs = item->desc->num_values - 1; + item->last_value_index = -1; + + for (i = 0; i <= item->last_offs; i++) { + item->values[i].value = item->desc->default_value; + item->values[i].id = OSMO_STAT_ITEM_NOVALUE_ID; + } +} + +/*! Reset all osmo stat items in a group + * \param[in] statg stat item group to reset + */ +void osmo_stat_item_group_reset(struct osmo_stat_item_group *statg) +{ + int i; + + for (i = 0; i < statg->desc->num_items; i++) { + struct osmo_stat_item *item = statg->items[i]; + osmo_stat_item_reset(item); + } +} /*! @} */ -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/19295 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: I80fc0ea8865ec4efdcd4c982e69d863275fd9919 Gerrit-Change-Number: 19295 Gerrit-PatchSet: 5 Gerrit-Owner: daniel <dwillmann at sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: daniel <dwillmann at sysmocom.de> Gerrit-Reviewer: laforge <laforge at osmocom.org> Gerrit-Reviewer: lynxis lazus <lynxis at fe80.eu> Gerrit-Reviewer: pespin <pespin at sysmocom.de> Gerrit-MessageType: merged -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200717/ff336106/attachment.htm>