From: Zbigniew Jędrzejewski-Szmek Date: Sat, 3 Dec 2022 10:55:55 +0000 (+0100) Subject: manager: define a string constant for LONG_MAX and use that for sysctl X-Git-Tag: v253-rc1~378^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a5fac1df2743e6407b23d22dbcbf7a25deddbb5c;p=thirdparty%2Fsystemd.git manager: define a string constant for LONG_MAX and use that for sysctl This moves the formatting of the constant to compilation time and let's us avoid asprintf() in the very hot path of initial boot. --- diff --git a/meson.build b/meson.build index 5706c776ffe..504644bca8a 100644 --- a/meson.build +++ b/meson.build @@ -510,6 +510,10 @@ conf.set('SIZEOF_TIME_T', cc.sizeof('time_t', prefix : '#include ')) conf.set('SIZEOF_RLIM_T', cc.sizeof('rlim_t', prefix : '#include ')) conf.set('SIZEOF_TIMEX_MEMBER', cc.sizeof('typeof(((struct timex *)0)->freq)', prefix : '#include ')) +long_max = cc.compute_int('LONG_MAX', prefix : '#include ') +assert(long_max > 100000) +conf.set_quoted('LONG_MAX_STR', '@0@'.format(long_max)) + decl_headers = ''' #include #include diff --git a/src/core/main.c b/src/core/main.c index ffe5c1688aa..df83a1d2d42 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -1184,7 +1184,7 @@ static void bump_file_max_and_nr_open(void) { #if BUMP_PROC_SYS_FS_FILE_MAX /* The maximum the kernel allows for this since 5.2 is LONG_MAX, use that. (Previously things were * different, but the operation would fail silently.) */ - r = sysctl_writef("fs/file-max", "%li", LONG_MAX); + r = sysctl_write("fs/file-max", LONG_MAX_STR); 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");