chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
treewide: more log_*_errno() conversions, multiline calls
[elogind.git]
/
src
/
libsystemd-terminal
/
subterm.c
diff --git
a/src/libsystemd-terminal/subterm.c
b/src/libsystemd-terminal/subterm.c
index dda6759709b6fba1fbed593664c27eded5ee109a..97a98a9843c6f68522e344217acfa3929e682a1a 100644
(file)
--- a/
src/libsystemd-terminal/subterm.c
+++ b/
src/libsystemd-terminal/subterm.c
@@
-126,7
+126,7
@@
static int output_flush(Output *o) {
len = loop_write(o->fd, o->obuf, o->n_obuf, false);
if (len < 0) {
len = loop_write(o->fd, o->obuf, o->n_obuf, false);
if (len < 0) {
- log_error
("error: cannot write to TTY (%zd): %s", len, strerror(-len)
);
+ log_error
_errno(len, "error: cannot write to TTY (%zd): %m", len
);
return len;
}
return len;
}
@@
-157,7
+157,7
@@
static int output_write(Output *o, const void *buf, size_t size) {
len = loop_write(o->fd, buf, size, false);
if (len < 0) {
len = loop_write(o->fd, buf, size, false);
if (len < 0) {
- log_error
("error: cannot write to TTY (%zd): %s", len, strerror(-len)
);
+ log_error
_errno(len, "error: cannot write to TTY (%zd): %m", len
);
return len;
}
return len;
}
@@
-428,10
+428,7
@@
static int output_draw_cell_fn(term_screen *screen,
output_printf(o, "\e[38;2;%u;%u;%um", attr->fg.red, attr->fg.green, attr->fg.blue);
break;
case TERM_CCODE_BLACK ... TERM_CCODE_WHITE:
output_printf(o, "\e[38;2;%u;%u;%um", attr->fg.red, attr->fg.green, attr->fg.blue);
break;
case TERM_CCODE_BLACK ... TERM_CCODE_WHITE:
- if (attr->bold)
- output_printf(o, "\e[%um", attr->fg.ccode - TERM_CCODE_BLACK + 90);
- else
- output_printf(o, "\e[%um", attr->fg.ccode - TERM_CCODE_BLACK + 30);
+ output_printf(o, "\e[%um", attr->fg.ccode - TERM_CCODE_BLACK + 30);
break;
case TERM_CCODE_LIGHT_BLACK ... TERM_CCODE_LIGHT_WHITE:
output_printf(o, "\e[%um", attr->fg.ccode - TERM_CCODE_LIGHT_BLACK + 90);
break;
case TERM_CCODE_LIGHT_BLACK ... TERM_CCODE_LIGHT_WHITE:
output_printf(o, "\e[%um", attr->fg.ccode - TERM_CCODE_LIGHT_BLACK + 90);
@@
-615,12
+612,12
@@
static int terminal_winch_fn(sd_event_source *source, const struct signalfd_sigi
if (t->pty) {
r = pty_resize(t->pty, t->output->in_width, t->output->in_height);
if (r < 0)
if (t->pty) {
r = pty_resize(t->pty, t->output->in_width, t->output->in_height);
if (r < 0)
- log_error
("error: pty_resize() (%d): %s", r, strerror(-r)
);
+ log_error
_errno(r, "error: pty_resize() (%d): %m", r
);
}
r = term_screen_resize(t->screen, t->output->in_width, t->output->in_height);
if (r < 0)
}
r = term_screen_resize(t->screen, t->output->in_width, t->output->in_height);
if (r < 0)
- log_error
("error: term_screen_resize() (%d): %s", r, strerror(-r)
);
+ log_error
_errno(r, "error: term_screen_resize() (%d): %m", r
);
terminal_dirty(t);
terminal_dirty(t);
@@
-660,7
+657,7
@@
static int terminal_write_tmp(Terminal *t) {
for (i = 0; i < num; ++i) {
r = pty_write(t->pty, vec[i].iov_base, vec[i].iov_len);
if (r < 0) {
for (i = 0; i < num; ++i) {
r = pty_write(t->pty, vec[i].iov_base, vec[i].iov_len);
if (r < 0) {
- log_error
("error: cannot write to PTY (%d): %s", r, strerror(-r)
);
+ log_error
_errno(r, "error: cannot write to PTY (%d): %m", r
);
return r;
}
}
return r;
}
}
@@
-729,7
+726,7
@@
static int terminal_io_fn(sd_event_source *source, int fd, uint32_t revents, voi
for (j = 0; j < n_str; ++j) {
type = term_parser_feed(t->parser, &seq, str[j]);
if (type < 0) {
for (j = 0; j < n_str; ++j) {
type = term_parser_feed(t->parser, &seq, str[j]);
if (type < 0) {
- log_error
("error: term_parser_feed() (%d): %s", type, strerror(-type)
);
+ log_error
_errno(type, "error: term_parser_feed() (%d): %m", type
);
return type;
}
return type;
}
@@
-781,7
+778,7
@@
static int terminal_pty_fn(Pty *pty, void *userdata, unsigned int event, const v
case PTY_DATA:
r = term_screen_feed_text(t->screen, ptr, size);
if (r < 0) {
case PTY_DATA:
r = term_screen_feed_text(t->screen, ptr, size);
if (r < 0) {
- log_error
("error: term_screen_feed_text() (%d): %s", r, strerror(-r)
);
+ log_error
_errno(r, "error: term_screen_feed_text() (%d): %m", r
);
return r;
}
return r;
}
@@
-860,49
+857,49
@@
static int terminal_new(Terminal **out, int in_fd, int out_fd) {
r = tcsetattr(t->in_fd, TCSANOW, &in_attr);
if (r < 0) {
r = tcsetattr(t->in_fd, TCSANOW, &in_attr);
if (r < 0) {
- log_error
("error: tcsetattr() (%d): %s", r, strerror(-r)
);
+ log_error
_errno(r, "error: tcsetattr() (%d): %m", r
);
goto error;
}
r = tcsetattr(t->out_fd, TCSANOW, &out_attr);
if (r < 0) {
goto error;
}
r = tcsetattr(t->out_fd, TCSANOW, &out_attr);
if (r < 0) {
- log_error
("error: tcsetattr() (%d): %s", r, strerror(-r)
);
+ log_error
_errno(r, "error: tcsetattr() (%d): %m", r
);
goto error;
}
r = sd_event_default(&t->event);
if (r < 0) {
goto error;
}
r = sd_event_default(&t->event);
if (r < 0) {
- log_error
("error: sd_event_default() (%d): %s", r, strerror(-r)
);
+ log_error
_errno(r, "error: sd_event_default() (%d): %m", r
);
goto error;
}
r = sigprocmask_many(SIG_BLOCK, SIGINT, SIGQUIT, SIGTERM, SIGWINCH, SIGCHLD, -1);
if (r < 0) {
goto error;
}
r = sigprocmask_many(SIG_BLOCK, SIGINT, SIGQUIT, SIGTERM, SIGWINCH, SIGCHLD, -1);
if (r < 0) {
- log_error
("error: sigprocmask_many() (%d): %s", r, strerror(-r)
);
+ log_error
_errno(r, "error: sigprocmask_many() (%d): %m", r
);
goto error;
}
r = sd_event_add_signal(t->event, NULL, SIGINT, NULL, NULL);
if (r < 0) {
goto error;
}
r = sd_event_add_signal(t->event, NULL, SIGINT, NULL, NULL);
if (r < 0) {
- log_error
("error: sd_event_add_signal() (%d): %s", r, strerror(-r)
);
+ log_error
_errno(r, "error: sd_event_add_signal() (%d): %m", r
);
goto error;
}
r = sd_event_add_signal(t->event, NULL, SIGQUIT, NULL, NULL);
if (r < 0) {
goto error;
}
r = sd_event_add_signal(t->event, NULL, SIGQUIT, NULL, NULL);
if (r < 0) {
- log_error
("error: sd_event_add_signal() (%d): %s", r, strerror(-r)
);
+ log_error
_errno(r, "error: sd_event_add_signal() (%d): %m", r
);
goto error;
}
r = sd_event_add_signal(t->event, NULL, SIGTERM, NULL, NULL);
if (r < 0) {
goto error;
}
r = sd_event_add_signal(t->event, NULL, SIGTERM, NULL, NULL);
if (r < 0) {
- log_error
("error: sd_event_add_signal() (%d): %s", r, strerror(-r)
);
+ log_error
_errno(r, "error: sd_event_add_signal() (%d): %m", r
);
goto error;
}
r = sd_event_add_signal(t->event, NULL, SIGWINCH, terminal_winch_fn, t);
if (r < 0) {
goto error;
}
r = sd_event_add_signal(t->event, NULL, SIGWINCH, terminal_winch_fn, t);
if (r < 0) {
- log_error
("error: sd_event_add_signal() (%d): %s", r, strerror(-r)
);
+ log_error
_errno(r, "error: sd_event_add_signal() (%d): %m", r
);
goto error;
}
goto error;
}
@@
-910,7
+907,7
@@
static int terminal_new(Terminal **out, int in_fd, int out_fd) {
t->is_dirty = true;
r = sd_event_add_time(t->event, &t->frame_timer, CLOCK_MONOTONIC, 0, 0, terminal_frame_timer_fn, t);
if (r < 0) {
t->is_dirty = true;
r = sd_event_add_time(t->event, &t->frame_timer, CLOCK_MONOTONIC, 0, 0, terminal_frame_timer_fn, t);
if (r < 0) {
- log_error
("error: sd_event_add_time() (%d): %s", r, strerror(-r)
);
+ log_error
_errno(r, "error: sd_event_add_time() (%d): %m", r
);
goto error;
}
goto error;
}
@@
-932,7
+929,7
@@
static int terminal_new(Terminal **out, int in_fd, int out_fd) {
r = term_screen_resize(t->screen, t->output->in_width, t->output->in_height);
if (r < 0) {
r = term_screen_resize(t->screen, t->output->in_width, t->output->in_height);
if (r < 0) {
- log_error
("error: term_screen_resize() (%d): %s", r, strerror(-r)
);
+ log_error
_errno(r, "error: term_screen_resize() (%d): %m", r
);
goto error;
}
goto error;
}
@@
-955,7
+952,7
@@
static int terminal_run(Terminal *t) {
pid = pty_fork(&t->pty, t->event, terminal_pty_fn, t, t->output->in_width, t->output->in_height);
if (pid < 0) {
pid = pty_fork(&t->pty, t->event, terminal_pty_fn, t, t->output->in_width, t->output->in_height);
if (pid < 0) {
- log_error
("error: cannot fork PTY (%d): %s", pid, strerror(-pid)
);
+ log_error
_errno(pid, "error: cannot fork PTY (%d): %m", pid
);
return pid;
} else if (pid == 0) {
/* child */
return pid;
} else if (pid == 0) {
/* child */
@@
-996,7
+993,7
@@
int main(int argc, char *argv[]) {
out:
if (r < 0)
out:
if (r < 0)
- log_error
("error: terminal failed (%d): %s", r, strerror(-r)
);
+ log_error
_errno(r, "error: terminal failed (%d): %m", r
);
terminal_free(t);
return -r;
}
terminal_free(t);
return -r;
}