summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVijay Bellur <vijay@gluster.com>2010-08-13 07:03:47 +0000
committerAnand V. Avati <avati@dev.gluster.com>2010-08-13 11:25:24 -0700
commitbce6e99400713a4ece37996376d28146aeebc3d4 (patch)
tree1bbb8959b8f642e01bb3a3ff8d1ebe67da6ac849
parent752cb30f695963befd95e0db1d56113c6cce976e (diff)
glusterd: Check for DIR before readdir
Signed-off-by: Vijay Bellur <vijay@gluster.com> Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 1323 () URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1323
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-store.c4
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-store.h9
2 files changed, 8 insertions, 5 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c
index 317f65e7975..84fd42d06cc 100644
--- a/xlators/mgmt/glusterd/src/glusterd-store.c
+++ b/xlators/mgmt/glusterd/src/glusterd-store.c
@@ -199,7 +199,7 @@ out:
int32_t
glusterd_store_remove_bricks (glusterd_volinfo_t *volinfo)
{
- int32_t ret = -1;
+ int32_t ret = 0;
glusterd_brickinfo_t *tmp = NULL;
glusterd_conf_t *priv = NULL;
char brickdir [PATH_MAX] = {0,};
@@ -786,7 +786,7 @@ int32_t
glusterd_store_retrieve_bricks (glusterd_volinfo_t *volinfo)
{
- int32_t ret = -1;
+ int32_t ret = 0;
glusterd_brickinfo_t *brickinfo = NULL;
glusterd_store_iter_t *iter = NULL;
char *key = NULL;
diff --git a/xlators/mgmt/glusterd/src/glusterd-store.h b/xlators/mgmt/glusterd/src/glusterd-store.h
index 9d7a6436e3f..8234463e0c5 100644
--- a/xlators/mgmt/glusterd/src/glusterd-store.h
+++ b/xlators/mgmt/glusterd/src/glusterd-store.h
@@ -56,10 +56,13 @@
#define glusterd_for_each_entry(entry, dir) \
do {\
- entry = readdir (dir);\
- while (entry && (!strcmp (entry->d_name, ".") ||\
- !strcmp (entry->d_name, ".."))) {\
+ entry = NULL;\
+ if (dir) {\
entry = readdir (dir);\
+ while (entry && (!strcmp (entry->d_name, ".") ||\
+ !strcmp (entry->d_name, ".."))) {\
+ entry = readdir (dir);\
+ }\
}\
} while (0); \