From 8f207feb260bc6112d5085859b43efc8378a4c5f Mon Sep 17 00:00:00 2001 From: Vijay Bellur Date: Mon, 24 Sep 2018 13:21:58 -0700 Subject: features/marker: Avoid passing structures as parameters to functions Fixes CIDs: 1388779,1390242,1390057 The patch does the following: 1. Changes the prototype of mq_inspect_file_xattr() and mq_xattr_state() to have a parameter of struct iatt * instead of struct iatt. 2. Remove unneeded struct iatt parameter from mq_inspect_directory_xattr() Change-Id: I1f6eabda042f0fe56d8c9bca010302f5e518dbe4 updates: bz#789278 Signed-off-by: Vijay Bellur --- xlators/features/marker/src/marker-quota.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'xlators/features/marker/src/marker-quota.c') diff --git a/xlators/features/marker/src/marker-quota.c b/xlators/features/marker/src/marker-quota.c index c680bc9a475..28da33849a0 100644 --- a/xlators/features/marker/src/marker-quota.c +++ b/xlators/features/marker/src/marker-quota.c @@ -2054,7 +2054,7 @@ out: int32_t mq_inspect_directory_xattr(xlator_t *this, quota_inode_ctx_t *ctx, inode_contribution_t *contribution, loc_t *loc, - dict_t *dict, struct iatt buf) + dict_t *dict) { int32_t ret = -1; int8_t dirty = -1; @@ -2151,7 +2151,7 @@ out: int32_t mq_inspect_file_xattr(xlator_t *this, quota_inode_ctx_t *ctx, inode_contribution_t *contribution, loc_t *loc, - dict_t *dict, struct iatt buf) + dict_t *dict, struct iatt *buf) { int32_t ret = -1; quota_meta_t size = { @@ -2168,9 +2168,12 @@ mq_inspect_file_xattr(xlator_t *this, quota_inode_ctx_t *ctx, }; gf_boolean_t status = _gf_false; + if (!buf || !contribution || !ctx) + goto out; + LOCK(&ctx->lock); { - ctx->size = 512 * buf.ia_blocks; + ctx->size = 512 * buf->ia_blocks; ctx->file_count = 1; ctx->dir_count = 0; @@ -2215,7 +2218,8 @@ out: } int32_t -mq_xattr_state(xlator_t *this, loc_t *origin_loc, dict_t *dict, struct iatt buf) +mq_xattr_state(xlator_t *this, loc_t *origin_loc, dict_t *dict, + struct iatt *buf) { int32_t ret = -1; quota_inode_ctx_t *ctx = NULL; @@ -2224,7 +2228,7 @@ mq_xattr_state(xlator_t *this, loc_t *origin_loc, dict_t *dict, struct iatt buf) }; inode_contribution_t *contribution = NULL; - ret = mq_prevalidate_txn(this, origin_loc, &loc, &ctx, &buf); + ret = mq_prevalidate_txn(this, origin_loc, &loc, &ctx, buf); if (ret < 0 || loc.parent == NULL) goto out; @@ -2239,13 +2243,12 @@ mq_xattr_state(xlator_t *this, loc_t *origin_loc, dict_t *dict, struct iatt buf) ret = -1; goto out; } - if (buf.ia_type == IA_IFDIR) - mq_inspect_directory_xattr(this, ctx, contribution, &loc, dict, - buf); + if (buf->ia_type == IA_IFDIR) + mq_inspect_directory_xattr(this, ctx, contribution, &loc, dict); else mq_inspect_file_xattr(this, ctx, contribution, &loc, dict, buf); } else { - mq_inspect_directory_xattr(this, ctx, 0, &loc, dict, buf); + mq_inspect_directory_xattr(this, ctx, 0, &loc, dict); } out: -- cgit