chiark / gitweb /
login: support more than just power-gpio-key
[elogind.git] / src / login / logind-button.c
index 210b889c4f987cd7998b38ac69e0578c77e98603..92c1b67951606e194065e75fecbe0985523565c7 100644 (file)
@@ -239,10 +239,7 @@ int button_open(Button *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);
 
@@ -267,8 +264,7 @@ int button_open(Button *b) {
         return 0;
 
 fail:
-        close(b->fd);
-        b->fd = -1;
+        b->fd = safe_close(b->fd);
         return r;
 }