diff options
author | Christopher R. Hertel <crh@redhat.com> | 2014-01-31 15:11:37 -0600 |
---|---|---|
committer | Vijay Bellur <vbellur@redhat.com> | 2014-02-05 22:26:07 -0800 |
commit | e3162ed7e91510185316eae36f5c2c25bde53a68 (patch) | |
tree | 8c002b5b656f7ac9fe81b4d4eae3e902870ce3b6 /libglusterfs/src | |
parent | e021078220c30e781ef016b42f8cee8229042bb1 (diff) |
libglusterfs: Allow all valid file handle values to be closed.
Zero (0) is a valid file handle. The code, as written, interprets return
values of open(2) that are less than or equal to zero to indicate an
error. Only -1 indicates an error.
BUG: 789278
CID: 1124756
Change-Id: Ie77c25f1f557d5d5adcec464b49dc7df2e3dc7e5
Signed-off-by: Christopher R. Hertel <crh@redhat.com>
Reviewed-on: http://review.gluster.org/6884
Reviewed-by: Lalatendu Mohanty <lmohanty@redhat.com>
Reviewed-by: Shyamsundar Ranganathan <srangana@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'libglusterfs/src')
-rw-r--r-- | libglusterfs/src/store.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/libglusterfs/src/store.c b/libglusterfs/src/store.c index 5af23592b84..66a5906a327 100644 --- a/libglusterfs/src/store.c +++ b/libglusterfs/src/store.c @@ -362,12 +362,11 @@ gf_store_handle_new (char *path, gf_store_handle_t **handle) goto out; spath = gf_strdup (path); - if (!spath) goto out; fd = open (path, O_RDWR | O_CREAT | O_APPEND, 0600); - if (fd <= 0) { + if (fd < 0) { gf_log ("", GF_LOG_ERROR, "Failed to open file: %s, error: %s", path, strerror (errno)); goto out; @@ -383,7 +382,7 @@ gf_store_handle_new (char *path, gf_store_handle_t **handle) ret = 0; out: - if (fd > 0) + if (fd >= 0) close (fd); if (ret == -1) { |