Fix exceptions about checking errno 07/194007/2
authorHwankyu Jhun <h.jhun@samsung.com>
Wed, 28 Nov 2018 07:39:38 +0000 (16:39 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Thu, 29 Nov 2018 02:55:24 +0000 (11:55 +0900)
Before calling dlog_print function, the result value should be set.
While calling dlog_print function, the errno value can be changed.
If the error is occurred after calling inotify_rm_watch function,
the errno value is EBADF or EINVAL.

Change-Id: Ic0773c09db18235d9db3c3f2ceb901c17e3b525f
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/preference_inoti.c

index 9e553edab0c0df720fd7a297acef4983110ff5ab..5512629b9311d85989a2d28af1d66a77ad3c0580 100644 (file)
@@ -386,11 +386,13 @@ int _preference_kdb_del_notify(keynode_t *keynode)
        /* get wd */
        wd = inotify_add_watch(_kdb_inoti_fd, path, INOTY_EVENT_MASK);
        if (wd == -1) {
+               if (errno == ENOENT)
+                       func_ret = PREFERENCE_ERROR_NO_KEY;
+               else
+                       func_ret = PREFERENCE_ERROR_IO_ERROR;
                strerror_r(errno, err_buf, sizeof(err_buf));
                ERR("Error: inotify_add_watch() [%s]: %s", path, err_buf);
-               if (errno == ENOENT)
-                       return PREFERENCE_ERROR_NO_KEY;
-               return PREFERENCE_ERROR_IO_ERROR;
+               return func_ret;
        }
 
        pthread_mutex_lock(&_kdb_g_ns_mutex);
@@ -410,10 +412,7 @@ int _preference_kdb_del_notify(keynode_t *keynode)
                if (r == -1) {
                        strerror_r(errno, err_buf, sizeof(err_buf));
                        ERR("Error: inotify_rm_watch [%s]: %s", keyname, err_buf);
-                       if (errno == ENOENT)
-                               func_ret = PREFERENCE_ERROR_NO_KEY;
-                       else
-                               func_ret = PREFERENCE_ERROR_IO_ERROR;
+                       func_ret = PREFERENCE_ERROR_IO_ERROR;
                }
 
                INFO("key(%s) cb is removed. remained noti list total length(%d)",