diff options
author | Junaid <junaid@gluster.com> | 2011-04-12 05:06:03 +0000 |
---|---|---|
committer | Anand Avati <avati@gluster.com> | 2011-04-12 21:50:05 -0700 |
commit | 1fd570380ba5def514ff42e81008a7ddd588348f (patch) | |
tree | db72f86b960449968d88e723cff0fa51d05d32ed /xlators/features/marker/src/marker-quota-helper.c | |
parent | 9c26fbc70ab797eea7967bc77857e73eca9aeffe (diff) |
features/marker: Adding NULL checks.
Signed-off-by: Junaid <junaid@gluster.com>
Signed-off-by: Anand Avati <avati@gluster.com>
BUG: 2473 (Support for volume and directory level quota)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2473
Diffstat (limited to 'xlators/features/marker/src/marker-quota-helper.c')
-rw-r--r-- | xlators/features/marker/src/marker-quota-helper.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/xlators/features/marker/src/marker-quota-helper.c b/xlators/features/marker/src/marker-quota-helper.c index b6a87698eed..d7afd40a656 100644 --- a/xlators/features/marker/src/marker-quota-helper.c +++ b/xlators/features/marker/src/marker-quota-helper.c @@ -190,7 +190,7 @@ add_new_contribution_node (xlator_t *this, quota_inode_ctx_t *ctx, loc_t *loc) { inode_contribution_t *contribution = NULL; - if (ctx == NULL || loc == NULL) + if ((ctx == NULL) || (loc == NULL)) return NULL; if (strcmp (loc->path, "/") == 0) @@ -213,6 +213,10 @@ dict_set_contribution (xlator_t *this, dict_t *dict, int32_t ret = -1; char contri_key [512] = {0, }; + GF_VALIDATE_OR_GOTO ("marker", this, out); + GF_VALIDATE_OR_GOTO ("marker", dict, out); + GF_VALIDATE_OR_GOTO ("marker", loc, out); + GET_CONTRI_KEY (contri_key, loc->parent->gfid, ret); if (ret < 0) { ret = -1; @@ -222,7 +226,8 @@ dict_set_contribution (xlator_t *this, dict_t *dict, ret = dict_set_int64 (dict, contri_key, 0); if (ret < 0) { gf_log (this->name, GF_LOG_WARNING, - "unable to set dict value."); + "unable to set dict value on %s.", + loc->path); goto out; } @@ -251,7 +256,7 @@ quota_inode_ctx_get (inode_t *inode, xlator_t *this, goto out; } - mark_ctx = (marker_inode_ctx_t *) ctx_int; + mark_ctx = (marker_inode_ctx_t *) (unsigned long)ctx_int; if (mark_ctx->quota_ctx == NULL) { ret = -1; goto out; @@ -289,13 +294,14 @@ __quota_inode_ctx_new (inode_t *inode, xlator_t *this) goto unlock; } mark_ctx->quota_ctx = quota_ctx; - } else + } else { quota_ctx = mark_ctx->quota_ctx; + } ret = 0; } -unlock: UNLOCK (&inode->lock); - +unlock: + UNLOCK (&inode->lock); out: return quota_ctx; } |