|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
From ce540a24d53e1751a5b69224d5a7f5a59f2de7ad Mon Sep 17 00:00:00 2001
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
From: David Herrmann <dh.herrmann@gmail.com>
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Date: Tue, 23 Sep 2014 13:33:53 +0200
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Subject: [PATCH] Silence some "unchecked return-value" warnings
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
This adds some log-messages to ioctl() calls where we don't really care
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
for the return value. It isn't strictly necessary to look for those, but
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
lets be sure and print warnings. This silences gcc and coverity, and also
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
makes sure we get reports in case something goes wrong and we didn't
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
expect it to fail that way.
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
---
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/libsystemd-terminal/grdev-drm.c | 23 ++++++++++++++++++-----
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/login/logind-session.c | 6 +++++-
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
2 files changed, 23 insertions(+), 6 deletions(-)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/libsystemd-terminal/grdev-drm.c b/src/libsystemd-terminal/grdev-drm.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 2e55ad326b..5c65c096de 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/libsystemd-terminal/grdev-drm.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/libsystemd-terminal/grdev-drm.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -1474,14 +1474,19 @@ static int grdrm_fb_new(grdrm_fb **out, grdrm_card *card, const struct drm_mode_
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
grdrm_fb *grdrm_fb_free(grdrm_fb *fb) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
unsigned int i;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ int r;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!fb)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return NULL;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert(fb->card);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- if (fb->id > 0 && fb->card->fd >= 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- ioctl(fb->card->fd, DRM_IOCTL_MODE_RMFB, fb->id);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ if (fb->id > 0 && fb->card->fd >= 0) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ r = ioctl(fb->card->fd, DRM_IOCTL_MODE_RMFB, fb->id);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ log_debug("grdrm: %s: cannot delete framebuffer %" PRIu32 ": %m",
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ fb->card->base.name, fb->id);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ }
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
for (i = 0; i < ELEMENTSOF(fb->handles); ++i) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
struct drm_mode_destroy_dumb destroy_dumb = { };
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -1491,7 +1496,10 @@ grdrm_fb *grdrm_fb_free(grdrm_fb *fb) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (fb->handles[i] > 0 && fb->card->fd >= 0) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
destroy_dumb.handle = fb->handles[i];
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- ioctl(fb->card->fd, DRM_IOCTL_MODE_DESTROY_DUMB, &destroy_dumb);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ r = ioctl(fb->card->fd, DRM_IOCTL_MODE_DESTROY_DUMB, &destroy_dumb);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ log_debug("grdrm: %s: cannot destroy dumb-buffer %" PRIu32 ": %m",
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ fb->card->base.name, fb->handles[i]);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -2549,8 +2557,13 @@ static int unmanaged_card_new(grdev_card **out, grdev_session *session, struct u
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
basecard->session->name, basecard->name, cu->devnode);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
} else {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
/* We might get DRM-Master implicitly on open(); drop it immediately
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- * so we acquire it only once we're actually enabled. */
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- ioctl(fd, DRM_IOCTL_DROP_MASTER, 0);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ * so we acquire it only once we're actually enabled. We don't
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ * really care whether this call fails or not, but lets log any
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ * weird errors, anyway. */
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ r = ioctl(fd, DRM_IOCTL_DROP_MASTER, 0);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ if (r < 0 && errno != EACCES && errno != EINVAL)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ log_debug("grdrm: %s/%s: cannot drop DRM-Master: %m",
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ basecard->session->name, basecard->name);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
r = grdrm_card_open(&cu->card, fd);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/login/logind-session.c b/src/login/logind-session.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 477ac9ab1b..65bbb77750 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/login/logind-session.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/login/logind-session.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -1054,6 +1054,8 @@ void session_restore_vt(Session *s) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
void session_leave_vt(Session *s) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ int r;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert(s);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
/* This is called whenever we get a VT-switch signal from the kernel.
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -1071,7 +1073,9 @@ void session_leave_vt(Session *s) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
session_device_pause_all(s);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- ioctl(s->vtfd, VT_RELDISP, 1);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ r = ioctl(s->vtfd, VT_RELDISP, 1);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ log_debug("Cannot release VT of session %s: %m", s->id);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
bool session_is_controller(Session *s, const char *sender) {
|