[systemd-commits] 5 commits - src/libsystemd-terminal src/login
David Herrmann
dvdhrm at kemper.freedesktop.org
Tue Sep 23 11:07:19 PDT 2014
src/libsystemd-terminal/grdev-drm.c | 25 +++++++++++++++++++------
src/libsystemd-terminal/grdev.c | 17 ++++++++++++++++-
src/libsystemd-terminal/grdev.h | 2 ++
src/login/logind-session.c | 6 +++++-
4 files changed, 42 insertions(+), 8 deletions(-)
New commits:
commit 158c1e3e0c1e9dd8ebf1b93061e1c81805eac339
Author: David Herrmann <dh.herrmann at gmail.com>
Date: Tue Sep 23 13:52:50 2014 +0200
terminal: provide display dimensions to API users
Allow users to query the display dimensions of a grdev_display. This is
required to properly resize the objects to be rendered.
diff --git a/src/libsystemd-terminal/grdev.c b/src/libsystemd-terminal/grdev.c
index fa1fc37..aaac06e 100644
--- a/src/libsystemd-terminal/grdev.c
+++ b/src/libsystemd-terminal/grdev.c
@@ -301,6 +301,18 @@ const char *grdev_display_get_name(grdev_display *display) {
return display->name;
}
+uint32_t grdev_display_get_width(grdev_display *display) {
+ assert_return(display, 0);
+
+ return display->width;
+}
+
+uint32_t grdev_display_get_height(grdev_display *display) {
+ assert_return(display, 0);
+
+ return display->height;
+}
+
bool grdev_display_is_enabled(grdev_display *display) {
return display && display->enabled;
}
@@ -572,6 +584,8 @@ static bool display_cache(grdev_display *display) {
}
display_cache_targets(display);
+ display->width = display->tile->cache_w;
+ display->height = display->tile->cache_h;
r = 0;
diff --git a/src/libsystemd-terminal/grdev.h b/src/libsystemd-terminal/grdev.h
index 5f745aa..6ca8a76 100644
--- a/src/libsystemd-terminal/grdev.h
+++ b/src/libsystemd-terminal/grdev.h
@@ -112,6 +112,8 @@ void grdev_display_set_userdata(grdev_display *display, void *userdata);
void *grdev_display_get_userdata(grdev_display *display);
const char *grdev_display_get_name(grdev_display *display);
+uint32_t grdev_display_get_width(grdev_display *display);
+uint32_t grdev_display_get_height(grdev_display *display);
bool grdev_display_is_enabled(grdev_display *display);
void grdev_display_enable(grdev_display *display);
commit a908d213557cfbe874b7bd1ae3a1b0d3c05c29e9
Author: David Herrmann <dh.herrmann at gmail.com>
Date: Tue Sep 23 13:51:42 2014 +0200
terminal: verify kernel-returned DRM events are not truncated
Make sure the kernel always returns events properly. This is guaranteed
right now, otherwise, we do something really wrong. But lets be sure and
verify the received values properly. This also silences some coverity
warnings.
diff --git a/src/libsystemd-terminal/grdev-drm.c b/src/libsystemd-terminal/grdev-drm.c
index 5c65c09..5393ebf 100644
--- a/src/libsystemd-terminal/grdev-drm.c
+++ b/src/libsystemd-terminal/grdev-drm.c
@@ -2223,7 +2223,7 @@ static int grdrm_card_io_fn(sd_event_source *s, int fd, uint32_t revents, void *
for (i = 0; i < l; i += event->length) {
event = (void*)&buf[i];
- if (i + event->length > l) {
+ if (i + (ssize_t)sizeof(*event) > l || i + (ssize_t)event->length > l) {
log_debug("grdrm: %s/%s: truncated event", card->base.session->name, card->base.name);
break;
}
commit c5e6bfc6bc46dd8bc187e035929d6a49cd23ec09
Author: David Herrmann <dh.herrmann at gmail.com>
Date: Tue Sep 23 13:40:18 2014 +0200
terminal: verify grdev tiles are correctly linked
We used to set "pipe->tile = tile" inside of the leaf allocation. We no
longer do that. Verify that "out" is non-NULL, otherwise we'd leak memory.
This is currently always given, but make sure to add an assert(), so
coverity does not complain.
diff --git a/src/libsystemd-terminal/grdev.c b/src/libsystemd-terminal/grdev.c
index 80a71be..fa1fc37 100644
--- a/src/libsystemd-terminal/grdev.c
+++ b/src/libsystemd-terminal/grdev.c
@@ -158,6 +158,7 @@ int grdev_tile_new_leaf(grdev_tile **out, grdev_pipe *pipe) {
_cleanup_(grdev_tile_freep) grdev_tile *tile = NULL;
int r;
+ assert_return(out, -EINVAL);
assert_return(pipe, -EINVAL);
assert_return(!pipe->tile, -EINVAL);
commit b4170aed36e667e52ce4a353bda1964e3872ab34
Author: David Herrmann <dh.herrmann at gmail.com>
Date: Tue Sep 23 13:38:09 2014 +0200
terminal: fix tile-offset calculation
Binary operators with two pointers as arguments always operate on
object-size, not bytes. That is, "int *a, *b", (a - b) calculates the
number of integers between b and a, not the number of bytes.
Fix our cache-offset calculation to not use sizeof() with full-ptr
arithmetic.
diff --git a/src/libsystemd-terminal/grdev.c b/src/libsystemd-terminal/grdev.c
index c5ea524..80a71be 100644
--- a/src/libsystemd-terminal/grdev.c
+++ b/src/libsystemd-terminal/grdev.c
@@ -345,7 +345,7 @@ const grdev_display_target *grdev_display_next_target(grdev_display *display, co
assert(cache->pipe->tile->display == display);
assert(display->pipes >= cache);
- idx = (cache - display->pipes) / sizeof(*cache) + 1;
+ idx = cache - display->pipes + 1;
} else {
idx = 0;
}
commit ce540a24d53e1751a5b69224d5a7f5a59f2de7ad
Author: David Herrmann <dh.herrmann at gmail.com>
Date: Tue Sep 23 13:33:53 2014 +0200
Silence some "unchecked return-value" warnings
This adds some log-messages to ioctl() calls where we don't really care
for the return value. It isn't strictly necessary to look for those, but
lets be sure and print warnings. This silences gcc and coverity, and also
makes sure we get reports in case something goes wrong and we didn't
expect it to fail that way.
diff --git a/src/libsystemd-terminal/grdev-drm.c b/src/libsystemd-terminal/grdev-drm.c
index 2e55ad3..5c65c09 100644
--- a/src/libsystemd-terminal/grdev-drm.c
+++ b/src/libsystemd-terminal/grdev-drm.c
@@ -1474,14 +1474,19 @@ static int grdrm_fb_new(grdrm_fb **out, grdrm_card *card, const struct drm_mode_
grdrm_fb *grdrm_fb_free(grdrm_fb *fb) {
unsigned int i;
+ int r;
if (!fb)
return NULL;
assert(fb->card);
- if (fb->id > 0 && fb->card->fd >= 0)
- ioctl(fb->card->fd, DRM_IOCTL_MODE_RMFB, fb->id);
+ if (fb->id > 0 && fb->card->fd >= 0) {
+ r = ioctl(fb->card->fd, DRM_IOCTL_MODE_RMFB, fb->id);
+ if (r < 0)
+ log_debug("grdrm: %s: cannot delete framebuffer %" PRIu32 ": %m",
+ fb->card->base.name, fb->id);
+ }
for (i = 0; i < ELEMENTSOF(fb->handles); ++i) {
struct drm_mode_destroy_dumb destroy_dumb = { };
@@ -1491,7 +1496,10 @@ grdrm_fb *grdrm_fb_free(grdrm_fb *fb) {
if (fb->handles[i] > 0 && fb->card->fd >= 0) {
destroy_dumb.handle = fb->handles[i];
- ioctl(fb->card->fd, DRM_IOCTL_MODE_DESTROY_DUMB, &destroy_dumb);
+ r = ioctl(fb->card->fd, DRM_IOCTL_MODE_DESTROY_DUMB, &destroy_dumb);
+ if (r < 0)
+ log_debug("grdrm: %s: cannot destroy dumb-buffer %" PRIu32 ": %m",
+ fb->card->base.name, fb->handles[i]);
}
}
@@ -2549,8 +2557,13 @@ static int unmanaged_card_new(grdev_card **out, grdev_session *session, struct u
basecard->session->name, basecard->name, cu->devnode);
} else {
/* We might get DRM-Master implicitly on open(); drop it immediately
- * so we acquire it only once we're actually enabled. */
- ioctl(fd, DRM_IOCTL_DROP_MASTER, 0);
+ * so we acquire it only once we're actually enabled. We don't
+ * really care whether this call fails or not, but lets log any
+ * weird errors, anyway. */
+ r = ioctl(fd, DRM_IOCTL_DROP_MASTER, 0);
+ if (r < 0 && errno != EACCES && errno != EINVAL)
+ log_debug("grdrm: %s/%s: cannot drop DRM-Master: %m",
+ basecard->session->name, basecard->name);
r = grdrm_card_open(&cu->card, fd);
if (r < 0)
diff --git a/src/login/logind-session.c b/src/login/logind-session.c
index 477ac9a..65bbb77 100644
--- a/src/login/logind-session.c
+++ b/src/login/logind-session.c
@@ -1054,6 +1054,8 @@ void session_restore_vt(Session *s) {
}
void session_leave_vt(Session *s) {
+ int r;
+
assert(s);
/* This is called whenever we get a VT-switch signal from the kernel.
@@ -1071,7 +1073,9 @@ void session_leave_vt(Session *s) {
return;
session_device_pause_all(s);
- ioctl(s->vtfd, VT_RELDISP, 1);
+ r = ioctl(s->vtfd, VT_RELDISP, 1);
+ if (r < 0)
+ log_debug("Cannot release VT of session %s: %m", s->id);
}
bool session_is_controller(Session *s, const char *sender) {
More information about the systemd-commits
mailing list