From: Suyeon Hwang Date: Tue, 11 Jul 2023 05:31:48 +0000 (+0900) Subject: Use macro for length of file path X-Git-Tag: accepted/tizen/unified/20230718.162132~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0eec3b095468759e5229bf643c81e00932816f78;p=platform%2Fcore%2Fuifw%2Fvoice-control.git Use macro for length of file path Change-Id: I5352069100e10540f69cb763a88a560013644920 Signed-off-by: Suyeon Hwang --- diff --git a/common/vc_cmd_db.c b/common/vc_cmd_db.c index 6626bd5..dff7ec0 100644 --- a/common/vc_cmd_db.c +++ b/common/vc_cmd_db.c @@ -19,6 +19,7 @@ #include #include #include +#include #include "vc_cmd_db.h" #include "vc_main.h" @@ -58,8 +59,8 @@ const char* vc_db_tag() //#define DB_PATH tzplatform_mkpath(TZ_USER_DB, ".vc_info.db") static sqlite3* g_db_handle = NULL; static sqlite3* g_db_backup_handle = NULL; -static char g_path[256] = {0, }; -static char g_backup_path[256] = {0, }; +static char g_path[_POSIX_PATH_MAX] = {0, }; +static char g_backup_path[_POSIX_PATH_MAX] = {0, }; static int g_ref_cnt = 0; int g_fpid = -1; @@ -1613,7 +1614,7 @@ static int __vc_db_integrity_check_cb(void *NotUsed, int argc, char **argv, char if (0 != remove(g_path)) { SLOG(LOG_ERROR, vc_db_tag(), "[Error] remove file(%s) is failed for daemon", g_path); g_db_cnt = (g_db_cnt + 1) % 1000; - snprintf(g_path, 256, "%s/.vc_info_%d.db", VC_RUNTIME_INFO_ROOT, g_db_cnt); + snprintf(g_path, _POSIX_PATH_MAX, "%s/.vc_info_%d.db", VC_RUNTIME_INFO_ROOT, g_db_cnt); } bool is_connect = __vc_db_connect_db_for_daemon(g_path, &g_db_handle); if (true == is_connect) { @@ -1654,10 +1655,10 @@ int vc_db_initialize_for_daemon(void) /* For voice control DB */ /* This should be changed to general DB space - TZ_USER_DB */ - snprintf(g_path, 256, "%s/.vc_info.db", VC_RUNTIME_INFO_ROOT); + snprintf(g_path, _POSIX_PATH_MAX, "%s/.vc_info.db", VC_RUNTIME_INFO_ROOT); /* For Backup DB */ - snprintf(g_backup_path, 256, "%s/.vc_backup.db", VC_RUNTIME_INFO_ROOT); + snprintf(g_backup_path, _POSIX_PATH_MAX, "%s/.vc_backup.db", VC_RUNTIME_INFO_ROOT); bool is_connect = __vc_db_connect_db_for_daemon(g_path, &g_db_handle); if (false == is_connect) { @@ -1665,7 +1666,7 @@ int vc_db_initialize_for_daemon(void) if (0 != remove(g_path)) { SLOG(LOG_ERROR, vc_db_tag(), "[Error] remove file(%s) is failed for daemon", g_path); g_db_cnt = (g_db_cnt + 1) % 1000; - snprintf(g_path, 256, "%s/.vc_info_%d.db", VC_RUNTIME_INFO_ROOT, g_db_cnt); + snprintf(g_path, _POSIX_PATH_MAX, "%s/.vc_info_%d.db", VC_RUNTIME_INFO_ROOT, g_db_cnt); } is_connect = __vc_db_connect_db_for_daemon(g_path, &g_db_handle); if (true == is_connect) { @@ -1696,7 +1697,7 @@ int vc_db_initialize_for_daemon(void) if (0 != remove(g_path)) { SLOG(LOG_ERROR, vc_db_tag(), "[Error] remove file(%s) is failed for daemon", g_path); g_db_cnt = (g_db_cnt + 1) % 1000; - snprintf(g_path, 256, "%s/.vc_info_%d.db", VC_RUNTIME_INFO_ROOT, g_db_cnt); + snprintf(g_path, _POSIX_PATH_MAX, "%s/.vc_info_%d.db", VC_RUNTIME_INFO_ROOT, g_db_cnt); } is_connect = __vc_db_connect_db_for_daemon(g_path, &g_db_handle); if (true == is_connect) { @@ -1724,7 +1725,7 @@ int vc_db_initialize_for_daemon(void) if (0 != remove(g_backup_path)) { g_backup_db_cnt = (g_backup_db_cnt + 1) % 1000; SLOG(LOG_ERROR, vc_db_tag(), "[Error] remove file(%s) is failed", g_backup_path); - snprintf(g_backup_path, 256, "%s/.vc_backup_%d.db", VC_RUNTIME_INFO_ROOT, g_backup_db_cnt); + snprintf(g_backup_path, _POSIX_PATH_MAX, "%s/.vc_backup_%d.db", VC_RUNTIME_INFO_ROOT, g_backup_db_cnt); } is_connect = __vc_db_connect_db_for_daemon(g_path, &g_db_backup_handle); if (true == is_connect) { @@ -1792,10 +1793,10 @@ int vc_db_initialize(void) /* For voice control DB */ /* This should be changed to general DB space - TZ_USER_DB */ - snprintf(g_path, 256, "%s/.vc_info.db", VC_RUNTIME_INFO_ROOT); + snprintf(g_path, _POSIX_PATH_MAX, "%s/.vc_info.db", VC_RUNTIME_INFO_ROOT); /* For Backup DB */ - snprintf(g_backup_path, 256, "%s/.vc_backup.db", VC_RUNTIME_INFO_ROOT); + snprintf(g_backup_path, _POSIX_PATH_MAX, "%s/.vc_backup.db", VC_RUNTIME_INFO_ROOT); bool is_connect = __vc_db_connect_db(g_path, &g_db_handle); if (false == is_connect) { @@ -1803,7 +1804,7 @@ int vc_db_initialize(void) if (0 != remove(g_path)) { SLOG(LOG_ERROR, vc_db_tag(), "[Error] remove file(%s) is failed", g_path); g_db_cnt = (g_db_cnt + 1) % 1000; - snprintf(g_path, 256, "%s/.vc_info_%d.db", VC_RUNTIME_INFO_ROOT, g_db_cnt); + snprintf(g_path, _POSIX_PATH_MAX, "%s/.vc_info_%d.db", VC_RUNTIME_INFO_ROOT, g_db_cnt); } is_connect = __vc_db_connect_db(g_path, &g_db_handle); if (true == is_connect) { @@ -1827,7 +1828,7 @@ int vc_db_initialize(void) if (0 != remove(g_backup_path)) { g_backup_db_cnt = (g_backup_db_cnt + 1) % 1000; SLOG(LOG_ERROR, vc_db_tag(), "[Error] remove file(%s) is failed", g_backup_path); - snprintf(g_backup_path, 256, "%s/.vc_backup_%d.db", VC_RUNTIME_INFO_ROOT, g_backup_db_cnt); + snprintf(g_backup_path, _POSIX_PATH_MAX, "%s/.vc_backup_%d.db", VC_RUNTIME_INFO_ROOT, g_backup_db_cnt); } is_connect = __vc_db_connect_db(g_path, &g_db_backup_handle); if (true == is_connect) { @@ -1850,9 +1851,9 @@ int vc_db_finalize(void) if (0 != --g_ref_cnt) return VC_DB_ERROR_NONE; - memset(g_path, 0, 256); + memset(g_path, 0, _POSIX_PATH_MAX); - memset(g_backup_path, 0, 256); + memset(g_backup_path, 0, _POSIX_PATH_MAX); if (!g_db_handle) return VC_DB_ERROR_NONE;