diff --git a/libbpf_android/include/bpf/BpfMap.h b/libbpf_android/include/bpf/BpfMap.h index 243d9dc..60f114f 100644 --- a/libbpf_android/include/bpf/BpfMap.h +++ b/libbpf_android/include/bpf/BpfMap.h @@ -146,7 +146,7 @@ class BpfMap { const auto deleteAllEntries = [](const Key& key, BpfMap& map) -> base::Result { base::Result res = map.deleteValue(key); - if (!res && res.error().code() != ENOENT) { + if (!res.ok() && res.error().code() != ENOENT) { ALOGE("Failed to delete data %s", strerror(res.error().code())); } return {}; @@ -182,10 +182,10 @@ base::Result BpfMap::iterate( const std::function(const Key& key, const BpfMap& map)>& filter) const { base::Result curKey = getFirstKey(); - while (curKey) { + while (curKey.ok()) { const base::Result& nextKey = getNextKey(curKey.value()); base::Result status = filter(curKey.value(), *this); - if (!status) return status; + if (!status.ok()) return status; curKey = nextKey; } if (curKey.error().code() == ENOENT) return {}; @@ -197,12 +197,12 @@ base::Result BpfMap::iterateWithValue( const std::function(const Key& key, const Value& value, const BpfMap& map)>& filter) const { base::Result curKey = getFirstKey(); - while (curKey) { + while (curKey.ok()) { const base::Result& nextKey = getNextKey(curKey.value()); base::Result curValue = this->readValue(curKey.value()); - if (!curValue) return curValue.error(); + if (!curValue.ok()) return curValue.error(); base::Result status = filter(curKey.value(), curValue.value(), *this); - if (!status) return status; + if (!status.ok()) return status; curKey = nextKey; } if (curKey.error().code() == ENOENT) return {}; @@ -213,10 +213,10 @@ template base::Result BpfMap::iterate( const std::function(const Key& key, BpfMap& map)>& filter) { base::Result curKey = getFirstKey(); - while (curKey) { + while (curKey.ok()) { const base::Result& nextKey = getNextKey(curKey.value()); base::Result status = filter(curKey.value(), *this); - if (!status) return status; + if (!status.ok()) return status; curKey = nextKey; } if (curKey.error().code() == ENOENT) return {}; @@ -228,12 +228,12 @@ base::Result BpfMap::iterateWithValue( const std::function(const Key& key, const Value& value, BpfMap& map)>& filter) { base::Result curKey = getFirstKey(); - while (curKey) { + while (curKey.ok()) { const base::Result& nextKey = getNextKey(curKey.value()); base::Result curValue = this->readValue(curKey.value()); - if (!curValue) return curValue.error(); + if (!curValue.ok()) return curValue.error(); base::Result status = filter(curKey.value(), curValue.value(), *this); - if (!status) return status; + if (!status.ok()) return status; curKey = nextKey; } if (curKey.error().code() == ENOENT) return {};