Skip to content

Commit

Permalink
Fixing various issues reported by static code analysis and compiler w…
Browse files Browse the repository at this point in the history
…arnings
  • Loading branch information
jgaa committed Aug 17, 2024
1 parent a4249fe commit ca7f2db
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions include/restc-cpp/test_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,17 @@ namespace restc_cpp {
// Substitute localhost with whatever is in the environment-variable
// RESTC_CPP_TEST_DOCKER_ADDRESS
inline std::string GetDockerUrl(std::string url) {
const char* docker_addr = nullptr;

#ifdef _WIN32
// On Windows, use _dupenv_s to safely retrieve the environment variable
size_t len = 0;
char* docker_addr = nullptr;
errno_t err = _dupenv_s(&docker_addr, &len, "RESTC_CPP_TEST_DOCKER_ADDRESS");
if (err != 0 || docker_addr == nullptr) {
docker_addr = nullptr; // Ensure docker_addr is nullptr if the variable isn't set
}
#else
// On Linux/macOS, use std::getenv
docker_addr = std::getenv("RESTC_CPP_TEST_DOCKER_ADDRESS");
auto docker_addr = std::getenv("RESTC_CPP_TEST_DOCKER_ADDRESS");
#endif

if (docker_addr) {
Expand Down

0 comments on commit ca7f2db

Please sign in to comment.