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

Use std::getenv #28117

Merged
merged 1 commit into from Oct 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions FWCore/FWLite/src/FWLiteEnabler.cc
Expand Up @@ -57,7 +57,7 @@ void FWLiteEnabler::enable() {

//Make it easy to load our headers
TInterpreter* intrp = gROOT->GetInterpreter();
char const* env = getenv("CMSSW_FWLITE_INCLUDE_PATH");
char const* env = std::getenv("CMSSW_FWLITE_INCLUDE_PATH");
if (nullptr != env) {
//this is a comma separated list
char const* start = env;
Expand All @@ -73,15 +73,15 @@ void FWLiteEnabler::enable() {
}

bool foundCMSIncludes = false;
env = getenv("CMSSW_BASE");
env = std::getenv("CMSSW_BASE");
if (nullptr != env) {
foundCMSIncludes = true;
std::string dir(env);
dir += "/src";
intrp->AddIncludePath(dir.c_str());
}

env = getenv("CMSSW_RELEASE_BASE");
env = std::getenv("CMSSW_RELEASE_BASE");
if (nullptr != env) {
foundCMSIncludes = true;
std::string dir(env);
Expand Down
10 changes: 5 additions & 5 deletions FWCore/ParameterSet/src/FileInPath.cc
Expand Up @@ -38,7 +38,7 @@ namespace {

// Remove symlinks from path
std::string removeSymLinks(std::string const& envName) {
char const* const var = getenv(envName.c_str());
char const* const var = std::getenv(envName.c_str());
if (var == nullptr) {
return std::string();
}
Expand All @@ -48,7 +48,7 @@ namespace {
}

std::string removeSymLinksSrc(std::string const& envName) {
char const* const var = getenv(envName.c_str());
char const* const var = std::getenv(envName.c_str());
if (var == nullptr) {
return std::string();
}
Expand All @@ -61,7 +61,7 @@ namespace {
}

std::string removeSymLinksTokens(std::string const& envName) {
char const* const var = getenv(envName.c_str());
char const* const var = std::getenv(envName.c_str());
if (var == nullptr) {
return std::string();
}
Expand Down Expand Up @@ -429,8 +429,8 @@ namespace edm {
throw edm::Exception(edm::errors::FileInPathError)
<< "edm::FileInPath unable to find file " << relativePath_ << " anywhere in the search path."
<< "\nThe search path is defined by: " << PathVariableName << "\n${" << PathVariableName
<< "} is: " << getenv(PathVariableName.c_str()) << "\nCurrent directory is: " << bf::initial_path().string()
<< "\n";
<< "} is: " << std::getenv(PathVariableName.c_str())
<< "\nCurrent directory is: " << bf::initial_path().string() << "\n";
}

void FileInPath::disableFileLookup() { s_fileLookupDisabled = true; }
Expand Down
4 changes: 2 additions & 2 deletions FWCore/PluginManager/src/standard.cc
Expand Up @@ -22,9 +22,9 @@ namespace edmplugin {
PluginManager::Config returnValue;

#ifdef __APPLE__
const char* path = getenv("DYLD_FALLBACK_LIBRARY_PATH");
const char* path = std::getenv("DYLD_FALLBACK_LIBRARY_PATH");
#else
const char* path = getenv("LD_LIBRARY_PATH");
const char* path = std::getenv("LD_LIBRARY_PATH");
#endif
if (!path)
path = "";
Expand Down
4 changes: 2 additions & 2 deletions FWCore/PyDevParameterSet/test/makepset_t.cppunit.cc
Expand Up @@ -208,8 +208,8 @@ void testmakepset::fileinpathAux() {
edm::FileInPath ufip = innerps.getUntrackedParameter<edm::FileInPath>("ufip");
CPPUNIT_ASSERT(innerps.existsAs<int>("extraneous"));
CPPUNIT_ASSERT(!innerps.existsAs<int>("absent"));
char* releaseBase = getenv("CMSSW_RELEASE_BASE");
char* localBase = getenv("CMSSW_BASE");
char* releaseBase = std::getenv("CMSSW_RELEASE_BASE");
char* localBase = std::getenv("CMSSW_BASE");
localArea = (releaseBase != nullptr && strlen(releaseBase) != 0 && strcmp(releaseBase, localBase));
if (localArea) {
// Need to account for possible symbolic links
Expand Down
4 changes: 2 additions & 2 deletions FWCore/PythonParameterSet/test/makepset_t.cppunit.cc
Expand Up @@ -208,8 +208,8 @@ void testmakepset::fileinpathAux() {
edm::FileInPath ufip = innerps.getUntrackedParameter<edm::FileInPath>("ufip");
CPPUNIT_ASSERT(innerps.existsAs<int>("extraneous"));
CPPUNIT_ASSERT(!innerps.existsAs<int>("absent"));
char* releaseBase = getenv("CMSSW_RELEASE_BASE");
char* localBase = getenv("CMSSW_BASE");
char* releaseBase = std::getenv("CMSSW_RELEASE_BASE");
char* localBase = std::getenv("CMSSW_BASE");
localArea = (releaseBase != nullptr && strlen(releaseBase) != 0 && strcmp(releaseBase, localBase));
if (localArea) {
// Need to account for possible symbolic links
Expand Down
2 changes: 1 addition & 1 deletion FWCore/Services/plugins/CondorStatusUpdater.cc
Expand Up @@ -211,7 +211,7 @@ bool CondorStatusService::isChirpSupported() {
return true;
}

return getenv("_CONDOR_CHIRP_CONFIG") && updateChirp("Elapsed", "0");
return std::getenv("_CONDOR_CHIRP_CONFIG") && updateChirp("Elapsed", "0");
}

void CondorStatusService::firstUpdate() {
Expand Down
2 changes: 1 addition & 1 deletion FWCore/Services/src/SiteLocalConfigService.cc
Expand Up @@ -53,7 +53,7 @@ namespace {

std::string defaultURL() {
std::string returnValue;
const char *tmp = getenv("CMS_PATH");
const char *tmp = std::getenv("CMS_PATH");
if (tmp) {
returnValue = tmp;
}
Expand Down
4 changes: 2 additions & 2 deletions FWCore/Services/test/test_catch2_SiteLocalConfigService.cc
Expand Up @@ -6,11 +6,11 @@

TEST_CASE("Test SiteLocalConfigService", "[sitelocalconfig]") {
std::string dirString;
auto dir = getenv("LOCAL_TEST_DIR");
auto dir = std::getenv("LOCAL_TEST_DIR");
if (dir) {
dirString = dir;
} else {
auto base_dir = getenv("CMSSW_BASE");
auto base_dir = std::getenv("CMSSW_BASE");
if (base_dir) {
dirString = base_dir;
dirString += "/src/FWCore/Services/test";
Expand Down
2 changes: 1 addition & 1 deletion FWCore/Utilities/interface/GetEnvironmentVariable.h
Expand Up @@ -6,7 +6,7 @@

namespace edm {
inline std::string getEnvironmentVariable(std::string const& name, std::string const& defaultValue = std::string()) {
char* p = ::getenv(name.c_str());
char* p = std::getenv(name.c_str());
return (p ? std::string(p) : defaultValue);
}
} // namespace edm
Expand Down
2 changes: 1 addition & 1 deletion FWCore/Utilities/src/DebugMacros.cc
Expand Up @@ -5,7 +5,7 @@

namespace edm {

debugvalue::debugvalue() : cvalue_(getenv("PROC_DEBUG")), value_(cvalue_ == nullptr ? 0 : atoi(cvalue_)) {}
debugvalue::debugvalue() : cvalue_(std::getenv("PROC_DEBUG")), value_(cvalue_ == nullptr ? 0 : atoi(cvalue_)) {}

debugvalue debugit;

Expand Down
2 changes: 1 addition & 1 deletion FWCore/Utilities/src/MallocOpts.cc
Expand Up @@ -164,7 +164,7 @@ namespace edm {
}

bool MallocOptionSetter::retrieveFromEnv() {
const char* par = getenv("CMSRUN_MALLOC_RESET");
const char* par = std::getenv("CMSRUN_MALLOC_RESET");
if (par == nullptr)
return false; // leave quickly here
std::string spar(par);
Expand Down
8 changes: 4 additions & 4 deletions FWCore/Utilities/src/TestHelper.cc
Expand Up @@ -86,9 +86,9 @@ int do_work(int argc, char* argv[], char** env) {
std::cout << "Current directory is: " << currentPath.string() << '\n';
// It is unclear about which of these environment variables should
// be used.
char const* topdir = getenv("SCRAMRT_LOCALRT");
char const* topdir = std::getenv("SCRAMRT_LOCALRT");
if (!topdir)
topdir = getenv("LOCALRT");
topdir = std::getenv("LOCALRT");
try {
if (!edm::untaintString(topdir, goodDirectory)) {
std::cerr << "Invalid top directory '" << topdir << "'" << std::endl;
Expand All @@ -100,7 +100,7 @@ int do_work(int argc, char* argv[], char** env) {
return -1;
}

char const* arch = getenv("SCRAM_ARCH");
char const* arch = std::getenv("SCRAM_ARCH");

if (!arch) {
// Try to synthesize SCRAM_ARCH value.
Expand All @@ -114,7 +114,7 @@ int do_work(int argc, char* argv[], char** env) {
std::cerr << "SCRAM_ARCH not set and attempt to set it failed\n";
return -1;
}
arch = getenv("SCRAM_ARCH");
arch = std::getenv("SCRAM_ARCH");
}

int rc = 0;
Expand Down
2 changes: 1 addition & 1 deletion Utilities/StorageFactory/plugins/StormLCGStorageMaker.cc
Expand Up @@ -14,7 +14,7 @@ class StormLcgGtStorageMaker : public StorageMaker {
std::string getTURL(const std::string &surl) const {
// PrepareToGet timeout
std::string timeout("300");
if (char *p = getenv("CMS_STORM_LCG_GT_TIMEOUT"))
if (char *p = std::getenv("CMS_STORM_LCG_GT_TIMEOUT"))
timeout = p;

/* Build the command line:
Expand Down
2 changes: 1 addition & 1 deletion Utilities/StorageFactory/plugins/StormStorageMaker.cc
Expand Up @@ -13,7 +13,7 @@ class StormStorageMaker : public StorageMaker {
/* getTURL: Executes a prepare to get script and extracts the physical file path */
std::string getTURL(const std::string &surl) const {
std::string client;
if (char *p = getenv("CMS_STORM_PTG_CLIENT"))
if (char *p = std::getenv("CMS_STORM_PTG_CLIENT"))
client = p;
else
throw cms::Exception("StormStorageMaker") << "$CMS_STORM_PTG_CLIENT has no value";
Expand Down
2 changes: 1 addition & 1 deletion Utilities/StorageFactory/src/LocalCacheFile.cc
Expand Up @@ -29,7 +29,7 @@ LocalCacheFile::LocalCacheFile(std::unique_ptr<Storage> base, const std::string

std::string pattern(tmpdir);
if (pattern.empty())
if (char *p = getenv("TMPDIR"))
if (char *p = std::getenv("TMPDIR"))
pattern = p;
if (pattern.empty())
pattern = "/tmp";
Expand Down
2 changes: 1 addition & 1 deletion Utilities/StorageFactory/src/LocalFileSystem.cc
Expand Up @@ -441,7 +441,7 @@ std::pair<std::string, std::string> LocalFileSystem::findCachePath(const std::ve
const char *path = inpath;

if (*path == '$') {
char *p = getenv(path + 1);
char *p = std::getenv(path + 1);
if (p && *p)
path = p;
else if (!strcmp(path, "$TMPDIR"))
Expand Down
6 changes: 3 additions & 3 deletions Utilities/StorageFactory/src/StatisticsSenderService.cc
Expand Up @@ -143,9 +143,9 @@ StatisticsSenderService::StatisticsSenderService(edm::ParameterSet const & /*pse
}

const char *StatisticsSenderService::getJobID() {
const char *id = getenv(JOB_UNIQUE_ID_ENV);
const char *id = std::getenv(JOB_UNIQUE_ID_ENV);
// Dashboard developers requested that we migrate to this environment variable.
return id ? id : getenv(JOB_UNIQUE_ID_ENV_V2);
return id ? id : std::getenv(JOB_UNIQUE_ID_ENV_V2);
}

void StatisticsSenderService::setCurrentServer(const std::string &servername) {
Expand Down Expand Up @@ -373,7 +373,7 @@ static bool getX509SubjectFromFile(const std::string &filename, std::string &res
}

bool StatisticsSenderService::getX509Subject(std::string &result) {
char *filename = getenv("X509_USER_PROXY");
char *filename = std::getenv("X509_USER_PROXY");
if (filename && getX509SubjectFromFile(filename, result)) {
return true;
}
Expand Down