From 965c1e08d31f8eaf31490baa12300ff5242ad604 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Mon, 26 Nov 2018 08:50:25 +0900 Subject: [PATCH] Fix the exception of preference_set_changed_cb function If the internal function returns a negative error value, the preference_set_changed_cb function also returns the negative error value. Change-Id: I781f86d91aabb8812fd5b0a8feca86bce62bbb97 Signed-off-by: Hwankyu Jhun --- src/preference.c | 5 +++-- src/preference_inoti.c | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/preference.c b/src/preference.c index b075dda..46117d3 100644 --- a/src/preference.c +++ b/src/preference.c @@ -1464,8 +1464,9 @@ API int preference_set_changed_cb(const char *key, preference_changed_cb callbac return PREFERENCE_ERROR_IO_ERROR; } - if (_preference_kdb_add_notify(pKeyNode, callback, user_data)) { - if (errno == ENOENT) { + func_ret = _preference_kdb_add_notify(pKeyNode, callback, user_data); + if (func_ret != PREFERENCE_ERROR_NONE) { + if (func_ret == PREFERENCE_ERROR_NO_KEY) { LOGE("NO_KEY(0x%08x) : fail to find given key(%s)", PREFERENCE_ERROR_NO_KEY, key); _preference_keynode_free(pKeyNode); return PREFERENCE_ERROR_NO_KEY; diff --git a/src/preference_inoti.c b/src/preference_inoti.c index 92ad9fd..9e553ed 100644 --- a/src/preference_inoti.c +++ b/src/preference_inoti.c @@ -288,7 +288,7 @@ int _preference_kdb_add_notify(keynode_t *keynode, preference_changed_cb cb, voi if (access(path, F_OK) != 0) { if (errno == ENOENT) { ERR("_preference_kdb_add_notify : Key(%s) does not exist", keyname); - return PREFERENCE_ERROR_IO_ERROR; + return PREFERENCE_ERROR_NO_KEY; } } -- 2.34.1