Always call close on fd if file has been opened
The previous logic only called close if the file had been opened AND
there was a valid inotify watch handle. Even if there is not a watch
handle, the file should be closed.
Change-Id: I0bfb3a0fac88d5b648790c4e60755e01af6f5bd7
Signed-off-by: Vernon Mauery <vernon.mauery@linux.intel.com>
diff --git a/watch.cpp b/watch.cpp
index a84c5ef..2ad8c4c 100644
--- a/watch.cpp
+++ b/watch.cpp
@@ -60,9 +60,12 @@
Watch::~Watch()
{
- if ((-1 != fd) && (-1 != wd))
+ if (-1 != fd)
{
- inotify_rm_watch(fd, wd);
+ if (-1 != wd)
+ {
+ inotify_rm_watch(fd, wd);
+ }
close(fd);
}
}