From ff0de119ae9aa0ee43aa67b6f82cb1f32c168a95 Mon Sep 17 00:00:00 2001 From: "minje.ahn" Date: Thu, 15 Sep 2022 08:20:45 +0900 Subject: [PATCH] Rename macro Change-Id: I79324851f31c311209f165ca684177247a0fa54a Signed-off-by: minje.ahn --- include/thumbnail_util_private.h | 29 +++++++++------------------ src/thumbnail_util.c | 34 ++++++++++++++------------------ 2 files changed, 24 insertions(+), 39 deletions(-) diff --git a/include/thumbnail_util_private.h b/include/thumbnail_util_private.h index bdc2809..e6ef700 100755 --- a/include/thumbnail_util_private.h +++ b/include/thumbnail_util_private.h @@ -59,49 +59,38 @@ typedef struct { #define FONT_COLOR_CYAN "\033[36m" #define FONT_COLOR_GRAY "\033[37m" -#define thumbnail_util_gettid() syscall(__NR_gettid) +#define THUMB_GETTID() syscall(__NR_gettid) -#define thumbnail_util_retv_if(expr, val) do { \ +#define THUMB_RETV_IF(expr, val) do { \ if (expr) { \ - LOGE(FONT_COLOR_RED"[%ld]"FONT_COLOR_RESET, thumbnail_util_gettid()); \ + LOGE(FONT_COLOR_RED"[%ld]"FONT_COLOR_RESET, THUMB_GETTID()); \ return (val); \ } \ } while (0) -#define thumbnail_util_retvm_if(expr, val, fmt, arg...) do { \ +#define THUMB_RETVM_IF(expr, val, fmt, arg...) do { \ if (expr) { \ - LOGE(FONT_COLOR_RED"[%ld]"fmt""FONT_COLOR_RESET, thumbnail_util_gettid(), ##arg); \ + LOGE(FONT_COLOR_RED"[%ld]"fmt""FONT_COLOR_RESET, THUMB_GETTID(), ##arg); \ return (val); \ } \ } while (0) -#define thumbnail_util_retm_if(expr, fmt, arg...) do { \ - if (expr) { \ - LOGE(FONT_COLOR_RED""fmt""FONT_COLOR_RESET, ##arg); \ - return; \ - } \ - } while (0) - -#define thumbnail_util_warn(fmt, arg...) do { \ +#define THUMB_WARN(fmt, arg...) do { \ LOGW(FONT_COLOR_GREEN""fmt""FONT_COLOR_RESET, ##arg); \ } while (0) -#define thumbnail_util_debug(fmt, arg...) do { \ +#define THUMB_DBG(fmt, arg...) do { \ LOGD(FONT_COLOR_RESET""fmt""FONT_COLOR_RESET, ##arg); \ } while (0) -#define thumbnail_util_error(fmt, arg...) do { \ +#define THUMB_ERR(fmt, arg...) do { \ LOGE(FONT_COLOR_RED""fmt""FONT_COLOR_RESET, ##arg); \ } while (0) -#define thumbnail_util_sec_debug(fmt, arg...) do { \ +#define THUMB_SDBG(fmt, arg...) do { \ SECURE_LOGD(FONT_COLOR_RESET""fmt""FONT_COLOR_RESET, ##arg); \ } while (0) -#define thumbnail_util_sec_error(fmt, arg...) do { \ - SECURE_LOGE(FONT_COLOR_RED""fmt""FONT_COLOR_RESET, ##arg); \ - } while (0) - #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/src/thumbnail_util.c b/src/thumbnail_util.c index 6d6cfce..3db79d2 100644 --- a/src/thumbnail_util.c +++ b/src/thumbnail_util.c @@ -16,12 +16,8 @@ #include #include - -/* For async API */ #include #include - -/* For sync API */ #include static int __thumbnail_util_error_capi(int internal_error) @@ -45,37 +41,37 @@ static int __thumbnail_util_error_capi(int internal_error) // LCOV_EXCL_START int thumbnail_util_create(thumbnail_h *thumb) { - thumbnail_util_warn("DEPRECATION WARNING: thumbnail_util_create() is deprecated and will be removed from next release."); + THUMB_WARN("DEPRECATION WARNING: thumbnail_util_create() is deprecated and will be removed from next release."); return THUMBNAIL_UTIL_ERROR_NONE; } int thumbnail_util_extract(thumbnail_h thumb, thumbnail_extracted_cb callback, void *user_data, char **request_id) { - thumbnail_util_warn("DEPRECATION WARNING: thumbnail_util_extract() is deprecated and will be removed from next release. Use thumbnail_util_extract_to_file() or thumbnail_util_extract_to_buffer() instead."); + THUMB_WARN("DEPRECATION WARNING: thumbnail_util_extract() is deprecated and will be removed from next release. Use thumbnail_util_extract_to_file() or thumbnail_util_extract_to_buffer() instead."); return THUMBNAIL_UTIL_ERROR_NONE; } int thumbnail_util_set_path(thumbnail_h thumb, const char *path) { - thumbnail_util_warn("DEPRECATION WARNING: thumbnail_util_set_path() is deprecated and will be removed from next release."); + THUMB_WARN("DEPRECATION WARNING: thumbnail_util_set_path() is deprecated and will be removed from next release."); return THUMBNAIL_UTIL_ERROR_NONE; } int thumbnail_util_set_size(thumbnail_h thumb, int width, int height) { - thumbnail_util_warn("DEPRECATION WARNING: thumbnail_util_set_size() is deprecated and will be removed from next release."); + THUMB_WARN("DEPRECATION WARNING: thumbnail_util_set_size() is deprecated and will be removed from next release."); return THUMBNAIL_UTIL_ERROR_NONE; } int thumbnail_util_cancel(thumbnail_h thumb, const char *request_id) { - thumbnail_util_warn("DEPRECATION WARNING: thumbnail_util_cancel() is deprecated and will be removed from next release."); + THUMB_WARN("DEPRECATION WARNING: thumbnail_util_cancel() is deprecated and will be removed from next release."); return THUMBNAIL_UTIL_ERROR_NONE; } int thumbnail_util_destroy(thumbnail_h thumb) { - thumbnail_util_warn("DEPRECATION WARNING: thumbnail_util_destroy() is deprecated and will be removed from next release."); + THUMB_WARN("DEPRECATION WARNING: thumbnail_util_destroy() is deprecated and will be removed from next release."); return THUMBNAIL_UTIL_ERROR_NONE; } // LCOV_EXCL_STOP @@ -87,26 +83,26 @@ static int __thumbnail_util_check_media_type(const char *path, thumbnail_util_me const char *supported_type = "application/vnd.ms-asf"; // Check file is existed - thumbnail_util_retv_if(path == NULL, THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER); + THUMB_RETV_IF(path == NULL, THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER); if (access(path, R_OK) < 0) { if (errno == EACCES || errno == EPERM) { - thumbnail_util_error("Fail to open path: Permission Denied [%s]", path); + THUMB_ERR("Fail to open path: Permission Denied [%s]", path); return THUMBNAIL_UTIL_ERROR_PERMISSION_DENIED; } else { - thumbnail_util_error("Fail to open path: Invalid Path [%s]", path); + THUMB_ERR("Fail to open path: Invalid Path [%s]", path); return THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER; } } // Check media type ret = aul_get_mime_from_file(path, mimetype, sizeof(mimetype)); - thumbnail_util_retvm_if(ret < 0, THUMBNAIL_UTIL_ERROR_INVALID_OPERATION, "aul_get_mime_from_file failed"); + THUMB_RETVM_IF(ret < 0, THUMBNAIL_UTIL_ERROR_INVALID_OPERATION, "aul_get_mime_from_file failed"); - thumbnail_util_debug("mime type : %s", mimetype); + THUMB_DBG("mime type : %s", mimetype); /* categorize from mimetype */ if (strstr(mimetype, "image") != NULL) { - thumbnail_util_retvm_if(!strcmp(mimetype, unsupported_type), THUMBNAIL_UTIL_ERROR_UNSUPPORTED_CONTENT, "This is unsupport file type"); + THUMB_RETVM_IF(!strcmp(mimetype, unsupported_type), THUMBNAIL_UTIL_ERROR_UNSUPPORTED_CONTENT, "This is unsupport file type"); *type = THUMBNAIL_UTIL_IMAGE; return THUMBNAIL_UTIL_ERROR_NONE; } else if (strstr(mimetype, "video") != NULL) { @@ -127,7 +123,7 @@ int thumbnail_util_extract_to_buffer(const char *path, unsigned int width, unsig /* check media type */ ret = __thumbnail_util_check_media_type(path, &type); - thumbnail_util_retvm_if(ret != THUMBNAIL_UTIL_ERROR_NONE, ret, "__thumbnail_util_check_media_type failed"); + THUMB_RETVM_IF(ret != THUMBNAIL_UTIL_ERROR_NONE, ret, "__thumbnail_util_check_media_type failed"); /* If image, check support format */ if (type == THUMBNAIL_UTIL_IMAGE) @@ -145,14 +141,14 @@ int thumbnail_util_extract_to_file(const char *path, unsigned int width, unsigne /* check media type */ ret = __thumbnail_util_check_media_type(path, &type); - thumbnail_util_retvm_if(ret != THUMBNAIL_UTIL_ERROR_NONE, ret, "__thumbnail_util_check_media_type failed"); + THUMB_RETVM_IF(ret != THUMBNAIL_UTIL_ERROR_NONE, ret, "__thumbnail_util_check_media_type failed"); /* If image, check support format */ if (type == THUMBNAIL_UTIL_IMAGE) { ret = create_image_thumbnail_to_file(path, width, height, thumbnail_path, false); } else { if (!g_regex_match_simple("[^/]\\.jpe?g$", thumbnail_path, G_REGEX_CASELESS, 0)) { - thumbnail_util_error("Unsupported path or extensions [%s]", thumbnail_path); + THUMB_ERR("Unsupported path or extensions [%s]", thumbnail_path); return THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER; } -- 2.34.1