Skip to content

Commit

Permalink
Fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephane Gouache committed Sep 27, 2024
1 parent 77ae532 commit 3682736
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ target_link_libraries(khiopsdriver_file_gcs PRIVATE google-cloud-cpp::storage
spdlog::spdlog)
target_compile_options(
khiopsdriver_file_gcs
PRIVATE $<$<CXX_COMPILER_ID:MSVC>:-Wall;/wd4101;/wd4710;/wd4711>
PRIVATE $<$<CXX_COMPILER_ID:MSVC>:-Wall;/wd4710;/wd4711;/wd4868>
PRIVATE $<$<CXX_COMPILER_ID:AppleClang,Clang,GNU>:-Wall;-Wextra;-pedantic>)

option(BUILD_TESTS "Build test programs" OFF)
Expand Down
6 changes: 6 additions & 0 deletions src/gcsplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,13 @@ std::string ToLower(const std::string &str) {

std::string GetEnvironmentVariableOrDefault(const std::string &variable_name,
const std::string &default_value) {
#ifdef _WIN32
size_t len;
char value[2048];
getenv_s(&len, value, 2048, "TEMP");
#else
char *value = getenv(variable_name.c_str());
#endif

if (value && std::strlen(value) > 0) {
return value;
Expand Down
13 changes: 8 additions & 5 deletions test/drivertest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,11 @@ int launch_test(const char *inputFilename, int nBufferSize) {
<< boost::uuids::random_generator()() << "/output.txt";
std::stringstream localOutput;
#ifdef _WIN32
localOutput << std::getenv("TEMP") << "\\out-"
<< boost::uuids::random_generator()() << ".txt";
size_t len;
char tempValue[2048];
getenv_s(&len, tempValue, 2048, "TEMP");
localOutput << tempValue << "\\out-" << boost::uuids::random_generator()()
<< ".txt";
#else
localOutput << "/tmp/out-" << boost::uuids::random_generator()() << ".txt";
#endif
Expand Down Expand Up @@ -333,9 +336,9 @@ int copyFileWithFseek(const char *file_name_input, const char *file_name_output,
// Reads the file by steps of nBufferSize and writes to the output file at
// each step
char *buffer = new char[nBufferSize + 1]();
long long int sizeRead = nBufferSize;
long long int sizeWrite;
int cummulativeRead = 0;
long long sizeRead = nBufferSize;
long long sizeWrite;
long long cummulativeRead = 0;
driver_fseek(fileinput, 0, SEEK_SET);
while (sizeRead == nBufferSize && copy_status == kSuccess) {
driver_fseek(fileinput, cummulativeRead, SEEK_SET);
Expand Down
2 changes: 1 addition & 1 deletion test/path_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ std::string getExecutableDir() {

std::string dirname(std::string path) {
char *pathBuffer = new char[path.length() + 1];
strcpy(pathBuffer, path.c_str());
strncpy(pathBuffer, path.c_str(), path.length() + 1);
std::string pathDir = std::string(::dirname(pathBuffer));
delete[] pathBuffer;
return pathDir;
Expand Down

0 comments on commit 3682736

Please sign in to comment.