From 688821665a86ba5c7ccbc9a90cceeb67610809da Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Wed, 31 Mar 2021 01:18:28 +0300 Subject: [PATCH] Remove stoull_full() from etcd_state_client.cpp --- src/etcd_state_client.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/etcd_state_client.cpp b/src/etcd_state_client.cpp index 95a8e05c7..cafdffb06 100644 --- a/src/etcd_state_client.cpp +++ b/src/etcd_state_client.cpp @@ -336,8 +336,10 @@ void etcd_state_client_t::parse_state(const std::string & key, const json11::Jso { pool_config_t pc; // ID - pool_id_t pool_id = stoull_full(pool_item.first); - if (!pool_id || pool_id >= POOL_ID_MAX) + pool_id_t pool_id; + char null_byte = 0; + sscanf(pool_item.first.c_str(), "%u%c", &pool_id, &null_byte); + if (!pool_id || pool_id >= POOL_ID_MAX || null_byte != 0) { printf("Pool ID %s is invalid (must be a number less than 0x%x), skipping pool\n", pool_item.first.c_str(), POOL_ID_MAX); continue; @@ -449,16 +451,19 @@ void etcd_state_client_t::parse_state(const std::string & key, const json11::Jso } for (auto & pool_item: value["items"].object_items()) { - pool_id_t pool_id = stoull_full(pool_item.first); - if (!pool_id || pool_id >= POOL_ID_MAX) + pool_id_t pool_id; + char null_byte = 0; + sscanf(pool_item.first.c_str(), "%u%c", &pool_id, &null_byte); + if (!pool_id || pool_id >= POOL_ID_MAX || null_byte != 0) { printf("Pool ID %s is invalid in PG configuration (must be a number less than 0x%x), skipping pool\n", pool_item.first.c_str(), POOL_ID_MAX); continue; } for (auto & pg_item: pool_item.second.object_items()) { - pg_num_t pg_num = stoull_full(pg_item.first); - if (!pg_num) + pg_num_t pg_num = 0; + sscanf(pg_item.first.c_str(), "%u%c", &pg_num, &null_byte); + if (!pg_num || null_byte != 0) { printf("Bad key in pool %u PG configuration: %s (must be a number), skipped\n", pool_id, pg_item.first.c_str()); continue;