along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include <assert.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include <linux/input.h>
#include "sd-messages.h"
-#include "conf-parser.h"
#include "util.h"
-#include "special.h"
#include "logind-button.h"
Button* button_new(Manager *m, const char *name) {
b->fd = -1;
}
- p = strappenda("/dev/input/", b->name);
+ p = strjoina("/dev/input/", b->name);
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) {
- log_error("Failed to get input name: %m");
+ log_error_errno(errno, "Failed to get input name: %m");
r = -errno;
goto fail;
}
r = sd_event_add_io(b->manager->event, &b->io_event_source, b->fd, EPOLLIN, button_dispatch, b);
if (r < 0) {
- log_error("Failed to add button event: %s", strerror(-r));
+ log_error_errno(r, "Failed to add button event: %m");
goto fail;
}