From: Vladimir Davydov <vdavydov.dev@gmail.com> To: kostja@tarantool.org Cc: tarantool-patches@freelists.org Subject: [PATCH 2/6] xrow: fix ret code on decode failure Date: Wed, 13 Jun 2018 19:10:34 +0300 [thread overview] Message-ID: <729e7394915597be33b8d4157d6e52e8b990520d.1528906027.git.vdavydov.dev@gmail.com> (raw) In-Reply-To: <cover.1528906027.git.vdavydov.dev@gmail.com> In-Reply-To: <cover.1528906027.git.vdavydov.dev@gmail.com> Throughout the code, we return -1 on error, but decode methods return 1 for some reason, although according to comments they are supposed to return -1. This doesn't result in any errors, because we use != 0 to check for errors. Nevertheless, let's fix it to avoid confusion. --- src/box/xrow.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/box/xrow.c b/src/box/xrow.c index 746913a4..48fbff27 100644 --- a/src/box/xrow.c +++ b/src/box/xrow.c @@ -408,7 +408,7 @@ xrow_decode_dml(struct xrow_header *row, struct request *request, if (row->bodycnt == 0) { diag_set(ClientError, ER_INVALID_MSGPACK, "missing request body"); - return 1; + return -1; } assert(row->bodycnt == 1); @@ -601,7 +601,7 @@ xrow_decode_call(const struct xrow_header *row, struct call_request *request) if (row->bodycnt == 0) { diag_set(ClientError, ER_INVALID_MSGPACK, "missing request body"); - return 1; + return -1; } assert(row->bodycnt == 1); @@ -612,7 +612,7 @@ xrow_decode_call(const struct xrow_header *row, struct call_request *request) if (mp_typeof(*data) != MP_MAP || mp_check_map(data, end) > 0) { error: diag_set(ClientError, ER_INVALID_MSGPACK, "packet body"); - return 1; + return -1; } memset(request, 0, sizeof(*request)); @@ -651,20 +651,20 @@ error: } if (data != end) { diag_set(ClientError, ER_INVALID_MSGPACK, "packet end"); - return 1; + return -1; } if (row->type == IPROTO_EVAL) { if (request->expr == NULL) { diag_set(ClientError, ER_MISSING_REQUEST_FIELD, iproto_key_name(IPROTO_EXPR)); - return 1; + return -1; } } else if (request->name == NULL) { assert(row->type == IPROTO_CALL_16 || row->type == IPROTO_CALL); diag_set(ClientError, ER_MISSING_REQUEST_FIELD, iproto_key_name(IPROTO_FUNCTION_NAME)); - return 1; + return -1; } if (request->args == NULL) { static const char empty_args[] = { (char)0x90 }; @@ -680,7 +680,7 @@ xrow_decode_auth(const struct xrow_header *row, struct auth_request *request) if (row->bodycnt == 0) { diag_set(ClientError, ER_INVALID_MSGPACK, "missing request body"); - return 1; + return -1; } assert(row->bodycnt == 1); @@ -691,7 +691,7 @@ xrow_decode_auth(const struct xrow_header *row, struct auth_request *request) if (mp_typeof(*data) != MP_MAP || mp_check_map(data, end) > 0) { error: diag_set(ClientError, ER_INVALID_MSGPACK, "packet body"); - return 1; + return -1; } memset(request, 0, sizeof(*request)); @@ -723,17 +723,17 @@ error: } if (data != end) { diag_set(ClientError, ER_INVALID_MSGPACK, "packet end"); - return 1; + return -1; } if (request->user_name == NULL) { diag_set(ClientError, ER_MISSING_REQUEST_FIELD, iproto_key_name(IPROTO_USER_NAME)); - return 1; + return -1; } if (request->scramble == NULL) { diag_set(ClientError, ER_MISSING_REQUEST_FIELD, iproto_key_name(IPROTO_TUPLE)); - return 1; + return -1; } return 0; } -- 2.11.0
next prev parent reply other threads:[~2018-06-13 16:10 UTC|newest] Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-06-13 16:10 [PATCH 0/6] Introduce replica local spaces Vladimir Davydov 2018-06-13 16:10 ` [PATCH 1/6] txn: remove unused C++ wrappers Vladimir Davydov 2018-06-27 17:08 ` Konstantin Osipov 2018-06-13 16:10 ` Vladimir Davydov [this message] 2018-06-27 17:29 ` [PATCH 2/6] xrow: fix ret code on decode failure Konstantin Osipov 2018-06-13 16:10 ` [PATCH 3/6] iproto: fix IPROTO_SERVER_IS_RO key code Vladimir Davydov 2018-06-27 17:48 ` Konstantin Osipov 2018-06-13 16:10 ` [PATCH 4/6] txn: do not require space id for nop requests Vladimir Davydov 2018-06-27 17:45 ` Konstantin Osipov 2018-06-28 9:13 ` Vladimir Davydov 2018-06-28 10:23 ` Konstantin Osipov 2018-06-28 10:35 ` Vladimir Davydov 2018-06-28 10:54 ` Konstantin Osipov 2018-06-28 11:10 ` Vladimir Davydov 2018-06-13 16:10 ` [PATCH 5/6] xrow: make NOP requests bodiless Vladimir Davydov 2018-06-27 17:49 ` Konstantin Osipov 2018-06-13 16:10 ` [PATCH 6/6] Introduce replica local spaces Vladimir Davydov 2018-06-13 21:26 ` [tarantool-patches] " Vladislav Shpilevoy 2018-06-27 18:24 ` Konstantin Osipov 2018-06-27 18:27 ` Konstantin Osipov
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=729e7394915597be33b8d4157d6e52e8b990520d.1528906027.git.vdavydov.dev@gmail.com \ --to=vdavydov.dev@gmail.com \ --cc=kostja@tarantool.org \ --cc=tarantool-patches@freelists.org \ --subject='Re: [PATCH 2/6] xrow: fix ret code on decode failure' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox