Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup GetEnvironmentVariable and remove unused variable under NO_GETENV #976

Merged
merged 1 commit into from
Sep 9, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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