Skip to content

Commit 68fdd17

Browse files
committed
futils: simplify getEnv slightly
Signed-off-by: Rosen Penev <[email protected]>
1 parent ed82141 commit 68fdd17

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/futils.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,11 @@ namespace Exiv2 {
9191
// free functions
9292
std::string getEnv(int env_var) {
9393
// this check is relying on undefined behavior and might not be effective
94-
if (env_var < envHTTPPOST || env_var > envTIMEOUT) {
94+
if (env_var < envHTTPPOST || env_var > envTIMEOUT)
9595
throw std::out_of_range("Unexpected env variable");
96-
}
97-
return getenv(ENVARKEY[env_var]) ? getenv(ENVARKEY[env_var]) : ENVARDEF[env_var];
96+
if (auto val = std::getenv(ENVARKEY[env_var]))
97+
return val;
98+
return ENVARDEF[env_var];
9899
}
99100

100101
std::string urlencode(const std::string& str) {

0 commit comments

Comments
 (0)