summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVernon Mauery <vernon.mauery@linux.intel.com>2018-05-10 16:19:16 -0700
committerGunnar Mills <gmills@us.ibm.com>2018-05-23 20:35:20 +0000
commit8ff0ee5419a304297889e78e4d30357cef77c4ce (patch)
treeaf44daade5c3d3a3f222570a5e2361e1ff3c3ff2
parentb6aadecd483ebfb56cef9a1979e6a0e9b6f36262 (diff)
downloadphosphor-bmc-code-mgmt-8ff0ee5419a304297889e78e4d30357cef77c4ce.tar.gz
phosphor-bmc-code-mgmt-8ff0ee5419a304297889e78e4d30357cef77c4ce.zip
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>
-rw-r--r--watch.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/watch.cpp b/watch.cpp
index a84c5ef..2ad8c4c 100644
--- a/watch.cpp
+++ b/watch.cpp
@@ -60,9 +60,12 @@ Watch::Watch(sd_event* loop, std::function<int(std::string&)> imageCallback) :
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);
}
}
OpenPOWER on IntegriCloud