summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMinje Ahn <minje.ahn@samsung.com>2017-07-07 07:18:45 (GMT)
committerMinje Ahn <minje.ahn@samsung.com>2017-07-10 01:57:39 (GMT)
commit19fcd8fbf7baff560bc70737d42a5c3ea26887bb (patch)
tree479c5df9bcf968725ad70ae4bf978b95b168d66f
parentc5ad1ae3877f3578a820bedbf253c7dd72e8e382 (diff)
downloadlibmedia-thumbnail-19fcd8fbf7baff560bc70737d42a5c3ea26887bb.zip
libmedia-thumbnail-19fcd8fbf7baff560bc70737d42a5c3ea26887bb.tar.gz
libmedia-thumbnail-19fcd8fbf7baff560bc70737d42a5c3ea26887bb.tar.bz2
Remove double checkrefs/changes/14/137714/4
Change-Id: I170b95a4f6a60119d53a33d1ed602b50a0cd31ab Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
-rwxr-xr-xsrc/include/util/media-thumb-db.h6
-rwxr-xr-xsrc/include/util/media-thumb-debug.h19
-rwxr-xr-xsrc/util/media-thumb-db.c95
3 files changed, 40 insertions, 80 deletions
diff --git a/src/include/util/media-thumb-db.h b/src/include/util/media-thumb-db.h
index fc407fa..a4cfc52 100755
--- a/src/include/util/media-thumb-db.h
+++ b/src/include/util/media-thumb-db.h
@@ -36,11 +36,7 @@
sqlite3 *_media_thumb_db_get_handle();
int _media_thumb_db_connect(uid_t uid);
int _media_thumb_db_disconnect();
-int _media_thumb_get_thumb_from_db_with_size(const char *origin_path,
- char *thumb_path,
- int max_length,
- int *width,
- int *height);
+int _media_thumb_get_thumb_from_db_with_size(const char *origin_path, char *thumb_path, int max_length, int *width, int *height);
int _media_thumb_update_db(const char *origin_path, char *thumb_path, int width, int height, uid_t uid);
#endif /*_MEDIA_THUMB_DB_H_*/
diff --git a/src/include/util/media-thumb-debug.h b/src/include/util/media-thumb-debug.h
index a4b4607..9cfbe2d 100755
--- a/src/include/util/media-thumb-debug.h
+++ b/src/include/util/media-thumb-debug.h
@@ -75,6 +75,25 @@
LOGE(FONT_COLOR_RED fmt" : standard error [%s]", strerror_r(errno, thumb_stderror_buffer, ERR_BUF_LENGHT)); \
} while (0)
+#define thumb_retm_if(expr, fmt, arg...) do { \
+ if (expr) { \
+ LOGE(FONT_COLOR_RED""fmt""FONT_COLOR_RESET, ##arg); \
+ return; \
+ } \
+ } while (0)
+#define thumb_retv_if(expr, val) do { \
+ if (expr) { \
+ LOGE(FONT_COLOR_RED""FONT_COLOR_RESET); \
+ return (val); \
+ } \
+ } while (0)
+#define thumb_retvm_if(expr, val, fmt, arg...) do { \
+ if (expr) { \
+ LOGE(FONT_COLOR_RED""fmt""FONT_COLOR_RESET, ##arg); \
+ return (val); \
+ } \
+ } while (0)
+
#ifdef _USE_LOG_FILE_
void thumb_init_file_debug();
void thumb_close_file_debug();
diff --git a/src/util/media-thumb-db.c b/src/util/media-thumb-db.c
index a572734..6f20e12 100755
--- a/src/util/media-thumb-db.c
+++ b/src/util/media-thumb-db.c
@@ -46,23 +46,14 @@ int _media_thumb_get_thumb_path_wh_from_db(sqlite3 *handle,
char *query_string = NULL;
sqlite3_stmt *stmt = NULL;
- if (handle == NULL) {
- thumb_err("DB handle is NULL");
- return MS_MEDIA_ERR_INVALID_PARAMETER;
- }
-
- if (!STRING_VALID(origin_path)) {
- thumb_err("Invalid origin_path");
- return MS_MEDIA_ERR_INVALID_PARAMETER;
- }
+ thumb_retvm_if(handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "DB handle is NULL");
+ thumb_retvm_if(!STRING_VALID(origin_path), MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid origin_path");
query_string = sqlite3_mprintf(SELECT_THUMB_BY_PATH, origin_path);
- if (!STRING_VALID(query_string)) {
- thumb_err("Memory allocation is failed");
- return MS_MEDIA_ERR_OUT_OF_MEMORY;
- }
+ thumb_retvm_if(!STRING_VALID(query_string), MS_MEDIA_ERR_OUT_OF_MEMORY, "Memory allocation is failed");
thumb_dbg_slog("Query: %s", query_string);
+
err = sqlite3_prepare_v2(handle, query_string, strlen(query_string), &stmt, NULL);
SQLITE3_SAFE_FREE(query_string);
if (SQLITE_OK != err) {
@@ -92,42 +83,6 @@ int _media_thumb_get_thumb_path_wh_from_db(sqlite3 *handle,
return MS_MEDIA_ERR_NONE;
}
-int _media_thumb_update_thumb_path_wh_to_db(const char *origin_path,
- char *thumb_path,
- int width,
- int height,
- uid_t uid)
-{
- int err = MS_MEDIA_ERR_NONE;
- char *query_string = NULL;
-
- if (!STRING_VALID(origin_path)) {
- thumb_err("Invalid origin_path");
- return MS_MEDIA_ERR_INVALID_PARAMETER;
- }
-
- if (width > 0 && height > 0)
- query_string = sqlite3_mprintf(UPDATE_THUMB_WH_BY_PATH, thumb_path, width, height, origin_path);
- else
- query_string = sqlite3_mprintf(UPDATE_THUMB_BY_PATH, thumb_path, origin_path);
-
- if (!STRING_VALID(query_string)) {
- thumb_err("Memory allocation is failed");
- return MS_MEDIA_ERR_OUT_OF_MEMORY;
- }
-
- err = media_db_request_update_db(query_string, uid);
- if (err != MS_MEDIA_ERR_NONE) {
- thumb_err("media_db_request_update_db failed : %d", err);
- } else {
- thumb_dbg("Query success");
- }
-
- SQLITE3_SAFE_FREE(query_string);
-
- return err;
-}
-
int _media_thumb_db_connect(uid_t uid)
{
int err = MS_MEDIA_ERR_NONE;
@@ -155,26 +110,15 @@ int _media_thumb_db_disconnect()
return err;
}
-int _media_thumb_get_thumb_from_db_with_size(const char *origin_path,
- char *thumb_path,
- int max_length,
- int *width,
- int *height)
+int _media_thumb_get_thumb_from_db_with_size(const char *origin_path, char *thumb_path, int max_length, int *width, int *height)
{
int err = MS_MEDIA_ERR_NONE;
int orig_w = 0;
int orig_h = 0;
err = _media_thumb_get_thumb_path_wh_from_db(db_handle, origin_path, thumb_path, max_length, &orig_w, &orig_h);
- if (err != MS_MEDIA_ERR_NONE) {
- thumb_warn("Original path doesn't exist in DB");
- return err;
- }
-
- if (strlen(thumb_path) == 0) {
- thumb_warn("thumb path doesn't exist in DB");
- return MS_MEDIA_ERR_INTERNAL;
- }
+ thumb_retvm_if(err != MS_MEDIA_ERR_NONE, err, "Original path doesn't exist in DB");
+ thumb_retvm_if(!STRING_VALID(thumb_path), MS_MEDIA_ERR_INTERNAL, "[No-error] thumb path doesn't exist in DB");
thumb_dbg_slog("Thumb path in DB is %s", thumb_path);
@@ -190,22 +134,23 @@ int _media_thumb_get_thumb_from_db_with_size(const char *origin_path,
return MS_MEDIA_ERR_NONE;
}
-int _media_thumb_update_db(const char *origin_path,
- char *thumb_path,
- int width,
- int height,
- uid_t uid)
+int _media_thumb_update_db(const char *origin_path, char *thumb_path, int width, int height, uid_t uid)
{
int err = MS_MEDIA_ERR_NONE;
+ char *query_string = NULL;
- err = _media_thumb_update_thumb_path_wh_to_db(origin_path, thumb_path, width, height, uid);
- if (err != MS_MEDIA_ERR_NONE) {
- thumb_err("_media_thumb_update_wh_to_db (%s) failed: %d", origin_path, err);
- return err;
- }
+ thumb_retvm_if(!STRING_VALID(origin_path), MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid origin_path");
+
+ if (width > 0 && height > 0)
+ query_string = sqlite3_mprintf(UPDATE_THUMB_WH_BY_PATH, thumb_path, width, height, origin_path);
+ else
+ query_string = sqlite3_mprintf(UPDATE_THUMB_BY_PATH, thumb_path, origin_path);
- thumb_dbg("_media_thumb_update_db success");
+ thumb_retvm_if(!STRING_VALID(query_string), MS_MEDIA_ERR_OUT_OF_MEMORY, "Memory allocation is failed");
- return MS_MEDIA_ERR_NONE;
+ err = media_db_request_update_db(query_string, uid);
+ SQLITE3_SAFE_FREE(query_string);
+
+ return err;
}