chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
[4/5] Apply missing fixes from upstream
[elogind.git]
/
src
/
login
/
logind-button.c
diff --git
a/src/login/logind-button.c
b/src/login/logind-button.c
index 9c0c6302a9cd9c8bcb5727325439f1b71680ef56..f40e35a8cbbf60ffec2eb369fd7f3b24ddca6e7b 100644
(file)
--- a/
src/login/logind-button.c
+++ b/
src/login/logind-button.c
@@
-19,7
+19,6
@@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include <assert.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
@@
-28,9
+27,7
@@
#include <linux/input.h>
#include "sd-messages.h"
#include <linux/input.h>
#include "sd-messages.h"
-#include "conf-parser.h"
#include "util.h"
#include "util.h"
-#include "special.h"
#include "logind-button.h"
Button* button_new(Manager *m, const char *name) {
#include "logind-button.h"
Button* button_new(Manager *m, const char *name) {
@@
-69,12
+66,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() */
/* If the device has been unplugged close() returns
* ENODEV, let's ignore this, hence we don't use
* safe_close() */
- close(b->fd);
- }
+ (void) close(b->fd);
free(b->name);
free(b->seat);
free(b->name);
free(b->seat);
@@
-103,7
+99,7
@@
static void button_lid_switch_handle_action(Manager *manager, bool is_edge) {
assert(manager);
/* If we are docked, handle the lid switch differently */
assert(manager);
/* If we are docked, handle the lid switch differently */
- if (manager_is_docked_or_
multiple
_displays(manager))
+ if (manager_is_docked_or_
external
_displays(manager))
handle_action = manager->handle_lid_switch_docked;
else
handle_action = manager->handle_lid_switch;
handle_action = manager->handle_lid_switch_docked;
else
handle_action = manager->handle_lid_switch;
@@
-242,22
+238,16
@@
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 = str
append
a("/dev/input/", b->name);
+ p = str
join
a("/dev/input/", b->name);
b->fd = open(p, O_RDWR|O_CLOEXEC|O_NOCTTY|O_NONBLOCK);
b->fd = open(p, O_RDWR|O_CLOEXEC|O_NOCTTY|O_NONBLOCK);
- if (b->fd < 0) {
- log_warning("Failed to open %s: %m", b->name);
- return -errno;
- }
+ if (b->fd < 0)
+ return log_warning_errno(errno, "Failed to open %s: %m", b->name);
if (ioctl(b->fd, EVIOCGNAME(sizeof(name)), name) < 0) {
if (ioctl(b->fd, EVIOCGNAME(sizeof(name)), name) < 0) {
- log_error("Failed to get input name: %m");
- r = -errno;
+ r = log_error_errno(errno, "Failed to get input name: %m");
goto fail;
}
goto fail;
}
@@
-272,8
+262,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;
}