1
0
mirror of https://github.com/systemd/systemd.git synced 2025-01-11 09:18:07 +03:00

env-util: suppress unnecessary setenv() in setenvf()

This commit is contained in:
Lennart Poettering 2024-07-17 17:54:09 +02:00
parent 95a8308d53
commit cc915eefaf

View File

@ -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));
}