From: Lennart Poettering Date: Thu, 5 Mar 2026 15:13:34 +0000 (+0100) Subject: vconsole-setup: add a bunch of assert()s X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3d153bfeb64d6fd60218418facb1c5f8528b414d;p=thirdparty%2Fsystemd.git vconsole-setup: add a bunch of assert()s --- diff --git a/src/vconsole/vconsole-setup.c b/src/vconsole/vconsole-setup.c index f1039319fd8..0fb8cf0381e 100644 --- a/src/vconsole/vconsole-setup.c +++ b/src/vconsole/vconsole-setup.c @@ -155,6 +155,8 @@ static void context_load_config(Context *c) { } static int verify_vc_device(int fd) { + assert(fd >= 0); + unsigned char data[] = { TIOCL_GETFGCONSOLE, }; @@ -171,8 +173,9 @@ static int verify_vc_allocation(unsigned idx) { } static int verify_vc_allocation_byfd(int fd) { - struct vt_stat vcs = {}; + assert(fd >= 0); + struct vt_stat vcs = {}; if (ioctl(fd, VT_GETSTATE, &vcs) < 0) return -errno; @@ -375,8 +378,9 @@ static void setup_remaining_vcs(int src_fd, unsigned src_idx, bool utf8) { struct unimapdesc unimapd; _cleanup_free_ struct unipair* unipairs = NULL; _cleanup_free_ void *fontbuf = NULL; - int log_level = LOG_WARNING; - int r; + int log_level = LOG_WARNING, r; + + assert(src_fd >= 0); unipairs = new(struct unipair, USHRT_MAX); if (!unipairs) @@ -549,6 +553,8 @@ static int verify_source_vc(char **ret_path, const char *src_vc) { char *path; int r; + assert(ret_path); + fd = open_terminal(src_vc, O_RDWR|O_CLOEXEC|O_NOCTTY); if (fd < 0) return log_error_errno(fd, "Failed to open %s: %m", src_vc);