Skip to content

all: return value signature changes#24

Draft
amarts wants to merge 1 commit into
gmasterfrom
issue_280_v1
Draft

all: return value signature changes#24
amarts wants to merge 1 commit into
gmasterfrom
issue_280_v1

Conversation

@amarts
Copy link
Copy Markdown
Owner

@amarts amarts commented Sep 22, 2020

  • return signature of all 'fops' callback changed to gf_return_t.

  • provide IS_ERROR()/IS_SUCCESS() macros to check only this type of argument.

  • provide 2 global variables gf_success and gf_error introduced, which
    can used instead of -1 and 0 return used largely today.

Change-Id: Ib91216afaa89d7e4509757b50dd8a7d60a6bf0a9
Updates: #280
Signed-off-by: Amar Tumballi amar@kadalu.io

Comment thread libglusterfs/src/gen-defaults.py Outdated
return 0;
gf_return_t ret;
ret.op_ret = -1;
STACK_UNWIND_STRICT (@NAME@, frame, ret, op_errno, @ERROR_ARGS@);
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just use gf_error

Comment thread libglusterfs/src/glusterfs/glusterfs.h Outdated
#define IS_ERROR(ret) (((ret).op_ret) < 0)
#define IS_SUCCESS(ret) (((ret).op_ret) >= 0)
#define GET_RET(ret) ((ret).op_ret)
#define SET_RET(ret, val) ((ret).op_ret = val)
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(val) is recommened.

Comment thread libglusterfs/src/glusterfs/syncop.h Outdated
\
if (!frame) { \
stb->op_ret = -1; \
stb->op_ret.op_ret = -1; \
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

set to gf_error

GF_XLATOR_BACKEND = 125,
GF_XLATOR_EXTERNAL = 126,
GF_XLATOR_MAXVALUE = 127,
};
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not a complete list!

Comment thread libglusterfs/src/inode.c Outdated
op_ret = inode_ctx_get(inode, this, &need_lookup);
if (op_ret == -1) {
op_ret.op_ret = inode_ctx_get(inode, this, &need_lookup);
if (IS_ERROR(op_ret)) {
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use some other type.

*/
AFR_STACK_UNWIND(setxattr, frame, 0, 0, NULL);
gf_return_t op_ret = {0};
AFR_STACK_UNWIND(setxattr, frame, op_ret, 0, NULL);
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gf_success

Comment thread xlators/cluster/afr/src/afr-lk-common.c Outdated
gf_msg_debug(this->name, 0, "we're done locking");

int_lock->lock_op_ret = 0;
SET_RET(int_lock->lock_op_ret, 0);
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gf_success

&local->stbuf, &local->preparent,
&local->postparent, local->xattr);
SET_RET(op_ret, 0);
dht_lookup_linkfile_create_cbk(
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gf_success

Comment thread xlators/cluster/dht/src/dht-common.c Outdated
@@ -8760,17 +8801,19 @@ dht_create_finish(call_frame_t *frame, xlator_t *this, int op_ret,
DHT_STACK_DESTROY(lock_frame);
}

if (op_ret == 0)
if (ret >= 0)
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ret == 0

Comment thread xlators/cluster/dht/src/dht-rename.c Outdated
}
}
if (local->ret_cache[conf->subvolume_cnt]) {
if (IS_SUCCESS(local->ret_cache[conf->subvolume_cnt])) {
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IS_ERROR()

* return signature of all 'fops' callback changed to `gf_return_t`.

* provide IS_ERROR()/IS_SUCCESS() macros to check only this type of argument.

* provide 2 global variables `gf_success` and `gf_error` introduced, which
  can used instead of -1 and 0 return used largely today.

Change-Id: Ib91216afaa89d7e4509757b50dd8a7d60a6bf0a9
Updates: #280
Signed-off-by: Amar Tumballi <amar@kadalu.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant