projects
/
systemd
/
.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
95a8308
)
env-util: suppress unnecessary setenv() in setenvf()
author
Lennart Poettering
<lennart@poettering.net>
Wed, 17 Jul 2024 15:54:09 +0000
(17:54 +0200)
committer
Lennart Poettering
<lennart@poettering.net>
Fri, 19 Jul 2024 09:41:42 +0000
(11:41 +0200)
src/basic/env-util.c
patch
|
blob
|
history
diff --git
a/src/basic/env-util.c
b/src/basic/env-util.c
index 3e385e5ee4b6253ba47e95ab6e78da438e30a517..cf2c47d2142728bc61fae4f5e30ec51429a5ece9 100644
(file)
--- a/
src/basic/env-util.c
+++ b/
src/basic/env-util.c
@@
-1146,5
+1146,10
@@
int setenvf(const char *name, bool overwrite, const char *valuef, ...) {
if (r < 0)
return -ENOMEM;
+ /* Try to suppress writes if the value is already set correctly (simply because memory management of
+ * environment variables sucks a bit. */
+ if (streq_ptr(getenv(name), value))
+ return 0;
+
return RET_NERRNO(setenv(name, value, overwrite));
}