tree-wide: port various places to read_boolean_file()

This commit is contained in:
Lennart Poettering
2026-05-11 12:04:02 +02:00
parent db8046535b
commit 4f63cff1f4
3 changed files with 6 additions and 27 deletions
+1 -9
View File
@@ -869,16 +869,8 @@ int vt_disallocate(const char *tty_path) {
}
static int vt_default_utf8(void) {
_cleanup_free_ char *b = NULL;
int r;
/* Read the default VT UTF8 setting from the kernel */
r = read_one_line_file("/sys/module/vt/parameters/default_utf8", &b);
if (r < 0)
return r;
return parse_boolean(b);
return read_boolean_file("/sys/module/vt/parameters/default_utf8");
}
static int vt_reset_keyboard(int fd) {
+2 -8
View File
@@ -12,7 +12,6 @@
#include "journald-console.h"
#include "journald-manager.h"
#include "log.h"
#include "parse-util.h"
#include "process-util.h"
#include "stdio-util.h"
#include "terminal-util.h"
@@ -22,13 +21,8 @@ static bool prefix_timestamp(void) {
static int cached_printk_time = -1;
if (_unlikely_(cached_printk_time < 0)) {
_cleanup_free_ char *p = NULL;
cached_printk_time =
read_one_line_file("/sys/module/printk/parameters/time", &p) >= 0
&& parse_boolean(p) > 0;
}
if (_unlikely_(cached_printk_time < 0))
cached_printk_time = read_boolean_file("/sys/module/printk/parameters/time") > 0;
return cached_printk_time;
}
+3 -10
View File
@@ -9,9 +9,7 @@
#include "sd-dlopen.h"
#include "alloc-util.h"
#include "fileio.h"
#include "parse-util.h"
static void *libapparmor_dl = NULL;
@@ -31,18 +29,13 @@ bool mac_apparmor_use(void) {
if (cached_use >= 0)
return cached_use;
_cleanup_free_ char *p = NULL;
r = read_one_line_file("/sys/module/apparmor/parameters/enabled", &p);
r = read_boolean_file("/sys/module/apparmor/parameters/enabled");
if (r < 0) {
if (r != -ENOENT)
log_debug_errno(r, "Failed to read /sys/module/apparmor/parameters/enabled, assuming AppArmor is not available: %m");
log_debug_errno(r, "Failed to read and parse /sys/module/apparmor/parameters/enabled, assuming AppArmor is not available: %m");
return (cached_use = false);
}
r = parse_boolean(p);
if (r < 0)
log_debug_errno(r, "Failed to parse /sys/module/apparmor/parameters/enabled, assuming AppArmor is not available: %m");
if (r <= 0)
if (r == 0)
return (cached_use = false);
if (dlopen_libapparmor(LOG_DEBUG) < 0)