From e3162ed7e91510185316eae36f5c2c25bde53a68 Mon Sep 17 00:00:00 2001 From: "Christopher R. Hertel" Date: Fri, 31 Jan 2014 15:11:37 -0600 Subject: 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 Reviewed-on: http://review.gluster.org/6884 Reviewed-by: Lalatendu Mohanty Reviewed-by: Shyamsundar Ranganathan Tested-by: Gluster Build System Reviewed-by: Vijay Bellur --- libglusterfs/src/store.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'libglusterfs') 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) { -- cgit