summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/account/indication_common.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/account/indication_common.c b/src/account/indication_common.c
index 5f3c47e..aedf864 100644
--- a/src/account/indication_common.c
+++ b/src/account/indication_common.c
@@ -111,8 +111,7 @@ static int timecmp(struct timespec a, struct timespec b)
(wd) = inotify_add_watch((fd), (file), IN_CLOSE_WRITE | IN_MODIFY |\
IN_DELETE | IN_DELETE_SELF);\
if ((wd) < 0) {\
- close((fd));\
- return false;\
+ goto bail;\
}\
bool watcher(void *data)
@@ -129,10 +128,6 @@ bool watcher(void *data)
int wd_pwd, wd_grp;
ADD_WATCH(fd, wd_pwd, PASSWD_FILE);
ADD_WATCH(fd, wd_grp, GROUP_FILE);
- if (wd_pwd < 0 || wd_grp < 0) {
- close(fd);
- return false;
- }
do {
int len = 0, i = 0;
@@ -180,4 +175,13 @@ out:
inotify_rm_watch(fd, wd_grp);
close(fd);
return true;
+bail:
+ if (wd_pwd > 0) {
+ inotify_rm_watch(fd, wd_pwd);
+ }
+ if (wd_grp > 0) {
+ inotify_rm_watch(fd, wd_grp);
+ }
+ close(fd);
+ return false;
}