From: Minje Ahn Date: Mon, 8 Apr 2024 01:48:11 +0000 (+0900) Subject: Use %Q instead of '%q' X-Git-Tag: accepted/tizen/unified/20240409.135550^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=54ce2c1b949527b348612d0c5051f380d7961008;p=platform%2Fcore%2Fmultimedia%2Flibmedia-service.git Use %Q instead of '%q' Change-Id: Id62bc2e5aaff4961b947ea607e1f0cbd7595c059 Signed-off-by: Minje Ahn --- diff --git a/src/media-svc-media.c b/src/media-svc-media.c index 31c2985..ee7a737 100755 --- a/src/media-svc-media.c +++ b/src/media-svc-media.c @@ -163,7 +163,7 @@ int _media_svc_get_thumbnail_path_by_path(sqlite3 *handle, const char *path, cha media_svc_retvm_if(!STRING_VALID(path), MS_MEDIA_ERR_INVALID_PARAMETER, "path is NULL"); - sql = sqlite3_mprintf("SELECT media_thumbnail_path FROM %q WHERE media_path='%q'", DB_TABLE_MEDIA, path); + sql = sqlite3_mprintf("SELECT media_thumbnail_path FROM %q WHERE media_path=%Q", DB_TABLE_MEDIA, path); ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt); @@ -208,7 +208,7 @@ int _media_svc_update_item_validity(const char *path, int validity, bool stack_q media_svc_debug("path=[%s], validity=[%d]", path, validity); - sql = sqlite3_mprintf("UPDATE %q SET validity=%d WHERE media_path='%q';", DB_TABLE_MEDIA, validity, path); + sql = sqlite3_mprintf("UPDATE %q SET validity=%d WHERE media_path=%Q;", DB_TABLE_MEDIA, validity, path); if (!stack_query) { ret = _media_svc_sql_query_direct(sql, uid); @@ -235,8 +235,7 @@ int _media_svc_update_thumbnail_path(const char *path, const char *thumb_path, u int _media_svc_update_item_by_path(const char *src_path, const char *dst_storage_id, const char *dest_path, const char *file_name, int modified_time, long long int folder_id, uid_t uid) { int ret = MS_MEDIA_ERR_NONE; - - char *query = sqlite3_mprintf("UPDATE %q SET media_path=%Q, media_display_name=%Q, media_modified_time=%d, folder_id=%lld, storage_uuid='%q' WHERE media_path=%Q;", + char *query = sqlite3_mprintf("UPDATE %q SET media_path=%Q, media_display_name=%Q, media_modified_time=%d, folder_id=%lld, storage_uuid=%Q WHERE media_path=%Q;", DB_TABLE_MEDIA, dest_path, file_name, modified_time, folder_id, dst_storage_id, src_path); ret = _media_svc_sql_query(query, uid); diff --git a/src/media-svc-storage.c b/src/media-svc-storage.c index 1871921..062af7e 100755 --- a/src/media-svc-storage.c +++ b/src/media-svc-storage.c @@ -31,9 +31,9 @@ int _media_svc_check_storage(sqlite3 *handle, const char *storage_id, char **sto sqlite3_stmt *sql_stmt = NULL; char *sql = NULL; - media_svc_retvm_if(storage_id == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "storage_id is NULL"); - media_svc_retvm_if(storage_path == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "storage_path is NULL"); - media_svc_retvm_if(validity == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "validity is NULL"); + media_svc_retvm_if(!storage_id, MS_MEDIA_ERR_INVALID_PARAMETER, "storage_id is NULL"); + media_svc_retvm_if(!storage_path, MS_MEDIA_ERR_INVALID_PARAMETER, "storage_path is NULL"); + media_svc_retvm_if(!validity, MS_MEDIA_ERR_INVALID_PARAMETER, "validity is NULL"); *storage_path = NULL; *validity = 0; @@ -66,11 +66,11 @@ int _media_svc_update_storage_path(sqlite3 *handle, const char *storage_id, cons { int ret = MS_MEDIA_ERR_NONE; char *sql = NULL; - char *old_storage_path = NULL; + g_autofree gchar *old_storage_path = NULL; int validity = 0; - media_svc_retvm_if(storage_id == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "storage_id is NULL"); - media_svc_retvm_if(path == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "path is NULL"); + media_svc_retvm_if(!storage_id, MS_MEDIA_ERR_INVALID_PARAMETER, "storage_id is NULL"); + media_svc_retvm_if(!path, MS_MEDIA_ERR_INVALID_PARAMETER, "path is NULL"); /*Get old path*/ ret = _media_svc_check_storage(handle, storage_id, &old_storage_path, &validity); @@ -80,25 +80,18 @@ int _media_svc_update_storage_path(sqlite3 *handle, const char *storage_id, cons sql = sqlite3_mprintf("UPDATE %q SET storage_path=%Q WHERE storage_id=%Q", DB_TABLE_STORAGE, path, storage_id); ret = _media_svc_sql_query_direct(sql, uid); SQLITE3_SAFE_FREE(sql); - if (ret != MS_MEDIA_ERR_NONE) { - g_free(old_storage_path); - return ret; - } + media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); /*Folder table update*/ sql = sqlite3_mprintf("UPDATE %q SET folder_path=REPLACE(folder_path, %Q, %Q) WHERE storage_uuid=%Q", DB_TABLE_FOLDER, old_storage_path, path, storage_id); ret = _media_svc_sql_query_direct(sql, uid); SQLITE3_SAFE_FREE(sql); - if (ret != MS_MEDIA_ERR_NONE) { - g_free(old_storage_path); - return ret; - } + media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); /*Media table update*/ sql = sqlite3_mprintf("UPDATE %q SET media_path=REPLACE(media_path, %Q, %Q) WHERE storage_uuid=%Q", DB_TABLE_MEDIA, old_storage_path, path, storage_id); ret = _media_svc_sql_query_direct(sql, uid); SQLITE3_SAFE_FREE(sql); - g_free(old_storage_path); media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); return ret; @@ -144,13 +137,11 @@ int _media_svc_update_storage_validity(const char *storage_id, int validity, uid int ret = MS_MEDIA_ERR_NONE; char *sql = NULL; - if (storage_id == NULL) { - sql = sqlite3_mprintf("UPDATE %q SET validity=%d;UPDATE %q SET validity=%d WHERE storage_uuid IS NOT 'media';UPDATE %q SET validity=%d WHERE storage_uuid IS NOT 'media';", - DB_TABLE_STORAGE, validity, DB_TABLE_FOLDER, validity, DB_TABLE_MEDIA, validity); - } else { - sql = sqlite3_mprintf("UPDATE %q SET validity=%d WHERE storage_id=%Q;UPDATE %q SET validity=%d WHERE storage_uuid=%Q;UPDATE %q SET validity=%d WHERE storage_uuid=%Q;", - DB_TABLE_STORAGE, validity, storage_id, DB_TABLE_FOLDER, validity, storage_id, DB_TABLE_MEDIA, validity, storage_id); - } + if (!storage_id) + sql = sqlite3_mprintf("UPDATE %q SET validity=%d;UPDATE %q SET validity=%d WHERE storage_uuid IS NOT 'media';UPDATE %q SET validity=%d WHERE storage_uuid IS NOT 'media';", DB_TABLE_STORAGE, validity, DB_TABLE_FOLDER, validity, DB_TABLE_MEDIA, validity); + else + sql = sqlite3_mprintf("UPDATE %q SET validity=%d WHERE storage_id=%Q;UPDATE %q SET validity=%d WHERE storage_uuid=%Q;UPDATE %q SET validity=%d WHERE storage_uuid=%Q;", DB_TABLE_STORAGE, validity, storage_id, DB_TABLE_FOLDER, validity, storage_id, DB_TABLE_MEDIA, validity, storage_id); + ret = _media_svc_sql_query_direct(sql, uid); SQLITE3_SAFE_FREE(sql); @@ -164,7 +155,7 @@ int _media_svc_get_storage_uuid(sqlite3 *handle, const char *path, char *storage char *sql = NULL; char *internal_path = NULL; - media_svc_retvm_if(path == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "path is NULL"); + media_svc_retvm_if(!path, MS_MEDIA_ERR_INVALID_PARAMETER, "path is NULL"); ret = ms_user_get_internal_root_path(uid, &internal_path); media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "Fail to get root path"); diff --git a/src/media-svc.c b/src/media-svc.c index 1e47c7a..74a2bb2 100755 --- a/src/media-svc.c +++ b/src/media-svc.c @@ -31,7 +31,6 @@ #define CONTENT_INI_DEFAULT_PATH SYSCONFDIR"/multimedia/media_content_config.ini" -//static __thread int g_media_svc_data_cnt = 0; static __thread int g_media_svc_cur_data_cnt = 0; /* Flag for items to be published by notification */ @@ -723,4 +722,4 @@ int media_svc_check_db(sqlite3 *handle, uid_t uid) ret = media_svc_create_table(uid); return ret; -} \ No newline at end of file +}