Skip to content

Commit

Permalink
Cleanup GetEnvironmentVariable and remove unused variable under
Browse files Browse the repository at this point in the history
NO_GETENV
  • Loading branch information
ThomsonTan committed Sep 9, 2021
1 parent fc8f854 commit 1b0cb55
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions sdk/include/opentelemetry/sdk/common/env_variables.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ namespace common
// Returns the env variable set.
inline const std::string GetEnvironmentVariable(const char *env_var_name)
{
#if !defined(NO_GETENV)
const char *endpoint_from_env = nullptr;

#ifndef NO_GETENV
# if defined(_MSC_VER)
// avoid calling std::getenv which is deprecated in MSVC.
size_t required_size = 0;
Expand All @@ -31,10 +30,12 @@ inline const std::string GetEnvironmentVariable(const char *env_var_name)
}
# else
endpoint_from_env = std::getenv(env_var_name);
# endif
#endif
return endpoint_from_env == nullptr ? std::string() : endpoint_from_env;
# endif // defined(_MSC_VER)
return endpoint_from_env == nullptr ? std::string{} : std::string{endpoint_from_env};
#else
return std::string{};
#endif // !defined(NO_GETENV)
}
} // namespace common
} // namespace sdk
OPENTELEMETRY_END_NAMESPACE
OPENTELEMETRY_END_NAMESPACE

0 comments on commit 1b0cb55

Please sign in to comment.