From 5313732a9c12ff7da24afacc5a6bee894647cec4 Mon Sep 17 00:00:00 2001 From: sfc-gh-ext-simba-hx Date: Wed, 7 Feb 2024 11:26:05 -0800 Subject: [PATCH] fix for review comments --- cpp/FileTransferAgent.cpp | 4 ++-- cpp/util/ThreadPool.hpp | 2 +- include/snowflake/platform.h | 1 + lib/client.c | 2 +- lib/logger.c | 2 +- tests/test_connect.c | 2 +- tests/test_simple_put.cpp | 8 ++++---- 7 files changed, 11 insertions(+), 10 deletions(-) diff --git a/cpp/FileTransferAgent.cpp b/cpp/FileTransferAgent.cpp index 40df3e324b..556645e869 100755 --- a/cpp/FileTransferAgent.cpp +++ b/cpp/FileTransferAgent.cpp @@ -829,6 +829,8 @@ RemoteStorageRequestOutcome Snowflake::Client::FileTransferAgent::downloadSingle FileMetadata *fileMetadata, size_t resultIndex) { + char strerr_buf[SF_ERROR_BUFSIZE]; + fileMetadata->destPath = std::string(response.localLocation) + PATH_SEP + fileMetadata->destFileName; std::string destPathPlatform = m_stmtPutGet->UTF8ToPlatformString(fileMetadata->destPath); @@ -847,7 +849,6 @@ RemoteStorageRequestOutcome Snowflake::Client::FileTransferAgent::downloadSingle } catch (...) { std::string err = "Could not open file " + fileMetadata->destPath + " to downoad"; - char strerr_buf[1024]; char* str_error = sf_strerror(errno, strerr_buf, sizeof(strerr_buf)); CXX_LOG_DEBUG("Could not open file %s to downoad: %s", fileMetadata->destPath.c_str(), str_error); @@ -857,7 +858,6 @@ RemoteStorageRequestOutcome Snowflake::Client::FileTransferAgent::downloadSingle if (!dstFile.is_open()) { std::string err = "Could not open file " + fileMetadata->destPath + " to downoad"; - char strerr_buf[1024]; char* str_error = sf_strerror(errno, strerr_buf, sizeof(strerr_buf)); CXX_LOG_DEBUG("Could not open file %s to downoad: %s", fileMetadata->destPath.c_str(), str_error); diff --git a/cpp/util/ThreadPool.hpp b/cpp/util/ThreadPool.hpp index 81a80e2a99..7d11dc5325 100755 --- a/cpp/util/ThreadPool.hpp +++ b/cpp/util/ThreadPool.hpp @@ -155,7 +155,7 @@ class ThreadPool { int err = pthread_key_create(&key, NULL); if (err) { - char strerrbuf[1024]; + char strerrbuf[SF_ERROR_BUFSIZE]; CXX_LOG_ERROR("Thread pool creating key failed with error: %s", sf_strerror(err, strerrbuf, sizeof(strerrbuf))); throw SnowflakeTransferException(TransferError::INTERNAL_ERROR, "Thread context fail to initialize"); diff --git a/include/snowflake/platform.h b/include/snowflake/platform.h index d7004979fe..9b75e7a1ea 100755 --- a/include/snowflake/platform.h +++ b/include/snowflake/platform.h @@ -62,6 +62,7 @@ int STDCALL sf_unsetenv(const char *name); int STDCALL sf_mkdir(const char *path); +#define SF_ERROR_BUFSIZE 1024 char* STDCALL sf_strerror(int errnum, char* outbuf, size_t bufsize); int STDCALL diff --git a/lib/client.c b/lib/client.c index ddc5158e6a..ebe3b9b4ca 100644 --- a/lib/client.c +++ b/lib/client.c @@ -312,7 +312,7 @@ static sf_bool STDCALL log_init(const char *log_path, SF_LOG_LEVEL log_level) { const char *sf_log_level_str; char log_level_buf[64]; SF_LOG_LEVEL sf_log_level = log_level; - char strerror_buf[1024]; + char strerror_buf[SF_ERROR_BUFSIZE]; size_t log_path_size = 1; //Start with 1 to include null terminator log_path_size += strlen(time_str); diff --git a/lib/logger.c b/lib/logger.c index 8a0caedce6..119f30ad76 100644 --- a/lib/logger.c +++ b/lib/logger.c @@ -109,7 +109,7 @@ log_log_va_list(int level, const char *file, int line, const char *ns, return; } - char strerr_buf[1024]; + char strerr_buf[SF_ERROR_BUFSIZE]; char tsbuf[50]; /* timestamp buffer*/ sf_log_timestamp(tsbuf, sizeof(tsbuf)); diff --git a/tests/test_connect.c b/tests/test_connect.c index b92adfb187..2b67e40e4b 100644 --- a/tests/test_connect.c +++ b/tests/test_connect.c @@ -194,7 +194,7 @@ void test_connect_with_ocsp_cache_server_on(void **unused) { * in parameter are being used. */ void test_connect_with_proxy(void **unused) { - SKIP_IF_PROXY_ENV_IS_SET + SKIP_IF_PROXY_ENV_IS_SET; // set invalid proxy in environment variables sf_setenv("https_proxy", "a.b.c"); diff --git a/tests/test_simple_put.cpp b/tests/test_simple_put.cpp index 5d9b6ae3cc..966fb43508 100755 --- a/tests/test_simple_put.cpp +++ b/tests/test_simple_put.cpp @@ -1262,7 +1262,7 @@ void test_2GBlarge_get(void **unused) void test_simple_put_with_proxy(void **unused) { - SKIP_IF_PROXY_ENV_IS_SET + SKIP_IF_PROXY_ENV_IS_SET; // set invalid proxy in environment variables sf_setenv("https_proxy", "a.b.c"); @@ -1302,7 +1302,7 @@ void test_simple_put_with_proxy(void **unused) void test_simple_put_with_noproxy(void **unused) { - SKIP_IF_PROXY_ENV_IS_SET + SKIP_IF_PROXY_ENV_IS_SET; // set invalid proxy in environment variables sf_setenv("https_proxy", "a.b.c"); @@ -1343,7 +1343,7 @@ void test_simple_put_with_noproxy(void **unused) void test_simple_put_with_proxy_fromenv(void **unused) { - SKIP_IF_PROXY_ENV_IS_SET + SKIP_IF_PROXY_ENV_IS_SET; // set invalid proxy settings sf_setenv("https_proxy", "a.b.c"); @@ -1390,7 +1390,7 @@ void test_simple_put_with_proxy_fromenv(void **unused) void test_simple_put_with_noproxy_fromenv(void **unused) { - SKIP_IF_PROXY_ENV_IS_SET + SKIP_IF_PROXY_ENV_IS_SET; // set invalid proxy settings sf_setenv("https_proxy", "a.b.c");