diff options
author | Lennart Poettering <lennart@poettering.net> | 2019-07-12 11:04:12 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2019-07-13 11:05:07 +0200 |
commit | 56e8419aa8a2c6c336a4823b8323df13c85c9c30 (patch) | |
tree | ddd3b5b7f053c4b16682c1755b2c74a2ef9a21a2 /src/core/main.c | |
parent | shutdown: merge variable declaration lines a bit (diff) | |
download | systemd-56e8419aa8a2c6c336a4823b8323df13c85c9c30.tar.xz systemd-56e8419aa8a2c6c336a4823b8323df13c85c9c30.zip |
main: use sysctl_writef() where appropriate
Diffstat (limited to '')
-rw-r--r-- | src/core/main.c | 20 |
1 files changed, 2 insertions, 18 deletions
diff --git a/src/core/main.c b/src/core/main.c index 75c488795e..5bc3298fe0 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -1072,27 +1072,17 @@ static void bump_file_max_and_nr_open(void) { * hard) the only ones that really matter. */ #if BUMP_PROC_SYS_FS_FILE_MAX || BUMP_PROC_SYS_FS_NR_OPEN - _cleanup_free_ char *t = NULL; int r; #endif #if BUMP_PROC_SYS_FS_FILE_MAX /* The maximum the kernel allows for this since 5.2 is LONG_MAX, use that. (Previously thing where * different but the operation would fail silently.) */ - if (asprintf(&t, "%li\n", LONG_MAX) < 0) { - log_oom(); - return; - } - - r = sysctl_write("fs/file-max", t); + r = sysctl_writef("fs/file-max", "%li\n", LONG_MAX); if (r < 0) log_full_errno(IN_SET(r, -EROFS, -EPERM, -EACCES) ? LOG_DEBUG : LOG_WARNING, r, "Failed to bump fs.file-max, ignoring: %m"); #endif -#if BUMP_PROC_SYS_FS_FILE_MAX && BUMP_PROC_SYS_FS_NR_OPEN - t = mfree(t); -#endif - #if BUMP_PROC_SYS_FS_NR_OPEN int v = INT_MAX; @@ -1122,13 +1112,7 @@ static void bump_file_max_and_nr_open(void) { break; } - if (asprintf(&t, "%i\n", v) < 0) { - log_oom(); - return; - } - - r = sysctl_write("fs/nr_open", t); - t = mfree(t); + r = sysctl_writef("fs/nr_open", "%i\n", v); if (r == -EINVAL) { log_debug("Couldn't write fs.nr_open as %i, halving it.", v); v /= 2; |