diff options
author | Jiwoong Im <jiwoong.im@samsung.com> | 2017-02-14 10:59:21 +0900 |
---|---|---|
committer | Jiwoong Im <jiwoong.im@samsung.com> | 2017-02-14 10:59:21 +0900 |
commit | 4d1363f6b33c464e364553ac817017f70258f974 (patch) | |
tree | aa5d0b8f57f6acf93572bc66877c131998b9719b | |
parent | 0a5f7c9594ad9a0e69bc5de86e276fb2d92f5979 (diff) | |
download | application-4d1363f6b33c464e364553ac817017f70258f974.tar.gz application-4d1363f6b33c464e364553ac817017f70258f974.tar.bz2 application-4d1363f6b33c464e364553ac817017f70258f974.zip |
Add error handling in preference api
- Add errno check in using opendir for proper return.
Change-Id: I066ae1786067ababac0e396ebf88496360040f50
Signed-off-by: Jiwoong Im <jiwoong.im@samsung.com>
-rwxr-xr-x | preference/preference.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/preference/preference.c b/preference/preference.c index 558faf4..6e78b4e 100755 --- a/preference/preference.c +++ b/preference/preference.c @@ -1324,6 +1324,8 @@ API int preference_remove_all(void) dir = opendir(pref_dir_path); if (dir == NULL) { + if (errno == ENOENT) + return PREFERENCE_ERROR_NONE; strerror_r(errno, err_buf, sizeof(err_buf)); LOGE("opendir() failed. pref_path: %s, error: %d(%s)", pref_dir_path, errno, err_buf); return PREFERENCE_ERROR_IO_ERROR; @@ -1539,6 +1541,8 @@ API int preference_foreach_item(preference_item_cb callback, void *user_data) dir = opendir(pref_dir_path); if (dir == NULL) { + if (errno == ENOENT) + return PREFERENCE_ERROR_NONE; strerror_r(errno, err_buf, sizeof(err_buf)); LOGE("opendir() failed. path: %s, error: %d(%s)", pref_dir_path, errno, err_buf); return PREFERENCE_ERROR_IO_ERROR; |