chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Prep v231.2: Add mor debug messages to find out, why 'loginctl suspend' isn't working.
[elogind.git]
/
src
/
login
/
logind-button.c
diff --git
a/src/login/logind-button.c
b/src/login/logind-button.c
index 210b889c4f987cd7998b38ac69e0578c77e98603..baa6b7113c1038ff4f706589273ad3d421f29d10 100644
(file)
--- a/
src/login/logind-button.c
+++ b/
src/login/logind-button.c
@@
-1,5
+1,3
@@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
/***
This file is part of systemd.
/***
This file is part of systemd.
@@
-19,16
+17,20
@@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include <errno.h>
#include <fcntl.h>
+#include <string.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <linux/input.h>
#include "sd-messages.h"
#include <sys/ioctl.h>
#include <unistd.h>
#include <linux/input.h>
#include "sd-messages.h"
-#include "util.h"
+
+#include "alloc-util.h"
+#include "fd-util.h"
#include "logind-button.h"
#include "logind-button.h"
+#include "string-util.h"
+#include "util.h"
Button* button_new(Manager *m, const char *name) {
Button *b;
Button* button_new(Manager *m, const char *name) {
Button *b;
@@
-66,12
+68,11
@@
void button_free(Button *b) {
sd_event_source_unref(b->io_event_source);
sd_event_source_unref(b->check_event_source);
sd_event_source_unref(b->io_event_source);
sd_event_source_unref(b->check_event_source);
- if (b->fd >= 0)
{
+ if (b->fd >= 0)
/* If the device has been unplugged close() returns
* ENODEV, let's ignore this, hence we don't use
* safe_close() */
(void) close(b->fd);
/* If the device has been unplugged close() returns
* ENODEV, let's ignore this, hence we don't use
* safe_close() */
(void) close(b->fd);
- }
free(b->name);
free(b->seat);
free(b->name);
free(b->seat);
@@
-239,10
+240,7
@@
int button_open(Button *b) {
assert(b);
assert(b);
- if (b->fd >= 0) {
- close(b->fd);
- b->fd = -1;
- }
+ b->fd = safe_close(b->fd);
p = strjoina("/dev/input/", b->name);
p = strjoina("/dev/input/", b->name);
@@
-251,8
+249,7
@@
int button_open(Button *b) {
return log_warning_errno(errno, "Failed to open %s: %m", b->name);
if (ioctl(b->fd, EVIOCGNAME(sizeof(name)), name) < 0) {
return log_warning_errno(errno, "Failed to open %s: %m", b->name);
if (ioctl(b->fd, EVIOCGNAME(sizeof(name)), name) < 0) {
- log_error_errno(errno, "Failed to get input name: %m");
- r = -errno;
+ r = log_error_errno(errno, "Failed to get input name: %m");
goto fail;
}
goto fail;
}
@@
-267,8
+264,7
@@
int button_open(Button *b) {
return 0;
fail:
return 0;
fail:
- close(b->fd);
- b->fd = -1;
+ b->fd = safe_close(b->fd);
return r;
}
return r;
}