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) {
/* 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);
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;
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_errno(errno, "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_errno(errno, "Failed to get input name: %m");