From ec60a2cc82641b97e061abbfe0455bffead73c58 Mon Sep 17 00:00:00 2001 From: Xiaoxi Chen Date: Wed, 8 Apr 2015 21:43:29 +0800 Subject: [PATCH] os/KeyValueDB: return -ENOENT if key doesn't exist Previous code return 0 in all cases, caller doesn't know if the key is exists in the db. Signed-off-by: Xiaoxi Chen --- src/os/KeyValueDB.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/os/KeyValueDB.h b/src/os/KeyValueDB.h index 80fdceca81658..028243667dbb1 100644 --- a/src/os/KeyValueDB.h +++ b/src/os/KeyValueDB.h @@ -93,7 +93,12 @@ public: ks.insert(key); map om; int r = get(prefix, ks, &om); - *value = om[key]; + if (om.find(key) != om.end()) { + *value = om[key]; + } else { + *value = bufferlist(); + r = -ENOENT; + } return r; } -- 2.39.5