chiark / gitweb /
update TODO
[elogind.git] / src / libsystemd-terminal / subterm.c
index 920b661af4c95e1ec372ac59f998af0c078412cb..78efc9d7c0f6d7e31f1636cbf7a2effcdee95d2a 100644 (file)
@@ -102,10 +102,8 @@ static int output_winch(Output *o) {
         assert_return(o, -EINVAL);
 
         r = ioctl(o->fd, TIOCGWINSZ, &wsz);
-        if (r < 0) {
-                log_error("error: cannot read window-size: %m");
-                return -errno;
-        }
+        if (r < 0)
+                return log_error_errno(errno, "error: cannot read window-size: %m");
 
         if (wsz.ws_col != o->width || wsz.ws_row != o->height) {
                 o->width = wsz.ws_col;
@@ -119,14 +117,14 @@ static int output_winch(Output *o) {
 }
 
 static int output_flush(Output *o) {
-        ssize_t len;
+        int r;
 
         if (o->n_obuf < 1)
                 return 0;
 
-        len = loop_write(o->fd, o->obuf, o->n_obuf, false);
-        if (len < 0)
-                return log_error_errno(len, "error: cannot write to TTY (%zd): %m", len);
+        r = loop_write(o->fd, o->obuf, o->n_obuf, false);
+        if (r < 0)
+                return log_error_errno(r, "error: cannot write to TTY: %m");
 
         o->n_obuf = 0;
 
@@ -707,7 +705,7 @@ static int terminal_io_fn(sd_event_source *source, int fd, uint32_t revents, voi
                 if (errno == EAGAIN || errno == EINTR)
                         return 0;
 
-                log_error("error: cannot read from TTY (%d): %m", -errno);
+                log_error_errno(errno, "error: cannot read from TTY (%d): %m", -errno);
                 return -errno;
         }
 
@@ -822,16 +820,12 @@ static int terminal_new(Terminal **out, int in_fd, int out_fd) {
         assert_return(out, -EINVAL);
 
         r = tcgetattr(in_fd, &in_attr);
-        if (r < 0) {
-                log_error("error: tcgetattr() (%d): %m", -errno);
-                return -errno;
-        }
+        if (r < 0)
+                return log_error_errno(errno, "error: tcgetattr() (%d): %m", -errno);
 
         r = tcgetattr(out_fd, &out_attr);
-        if (r < 0) {
-                log_error("error: tcgetattr() (%d): %m", -errno);
-                return -errno;
-        }
+        if (r < 0)
+                return log_error_errno(errno, "error: tcgetattr() (%d): %m", -errno);
 
         t = new0(Terminal, 1);
         if (!t)
@@ -955,7 +949,7 @@ static int terminal_run(Terminal *t) {
                 setenv("COLORTERM", "systemd-subterm", 1);
 
                 execve(argv[0], argv, environ);
-                log_error("error: cannot exec %s (%d): %m", argv[0], -errno);
+                log_error_errno(errno, "error: cannot exec %s (%d): %m", argv[0], -errno);
                 _exit(1);
         }