]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
vconsole-setup: add a bunch of assert()s
authorLennart Poettering <lennart@amutable.com>
Thu, 5 Mar 2026 15:13:34 +0000 (16:13 +0100)
committerLennart Poettering <lennart@amutable.com>
Thu, 19 Mar 2026 07:51:18 +0000 (08:51 +0100)
src/vconsole/vconsole-setup.c

index f1039319fd872ae5ac126061f10b2e327181664e..0fb8cf0381ef30b88e4781257d34b633d618ec10 100644 (file)
@@ -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);