Tarantool development patches archive
 help / color / mirror / Atom feed
From: "Timur Safin" <tsafin@tarantool.org>
To: 'Alexander Turenko' <alexander.turenko@tarantool.org>
Cc: tarantool-patches@dev.tarantool.org, v.shpilevoy@tarantool.org
Subject: Re: [Tarantool-patches] [PATCH 2.X v4 4/4] module api: box_ibuf_* wrappers
Date: Fri, 16 Oct 2020 00:35:05 +0300	[thread overview]
Message-ID: <053201d6a33b$0c1c2f60$24548e20$@tarantool.org> (raw)
In-Reply-To: <20201014033117.ipfnfm4bxfklhp4c@tkn_work_nb>

After our discussions within messenger, I've updated ibuf.c to
raise error if there is invalid argument passed, to follow
current box_* functions convention. E.g.

+void
+box_ibuf_read_range(box_ibuf_t *ibuf, char ***rpos, char ***wpos)
+{
+       if (ibuf == NULL) {
+               diag_set(ClientError, ER_ILLEGAL_PARAMS,
+                        "Invalid ibuf argument");
+               return;
+       }
+       if (rpos != NULL)
+               *rpos = &ibuf->rpos;
+       if (wpos != NULL)
+               *wpos = &ibuf->wpos;
+}
+
+void
+box_ibuf_write_range(box_ibuf_t *ibuf, char ***wpos, char ***end)
+{
+       if (ibuf == NULL) {
+               diag_set(ClientError, ER_ILLEGAL_PARAMS,
+                        "Invalid ibuf argument");
+               return;
+       }
+       if (wpos != NULL)
+               *wpos = &ibuf->wpos;
+       if (end != NULL)
+               *end = &ibuf->end;
+
+}

Code has been updated in the branch tsafin/gh-5273-expand-module-api-v4

Regards,
Timur

: -----Original Message-----
: From: Alexander Turenko <alexander.turenko@tarantool.org>
: Sent: Wednesday, October 14, 2020 6:31 AM
: To: Timur Safin <tsafin@tarantool.org>
: Cc: v.shpilevoy@tarantool.org; tarantool-patches@dev.tarantool.org
: Subject: Re: [PATCH 2.X v4 4/4] module api: box_ibuf_* wrappers
: 
: > +void
: > +box_ibuf_read_range(box_ibuf_t *ibuf, char ***rpos, char ***wpos)
: > +{
: > +	assert(ibuf != NULL);
: > +	if (ibuf == NULL)
: > +		return;
: 
: So it'll not (at least stochastically) fail on ibuf pointer
: dereferencing on RelWithDebInfo, but will just silently ignore the usage
: error. I guess it is the bad pattern. At least I don't see anything
: similar in our code: we either assert() or fail with setting an error to
: the diagnostics area and returning of -1 / NULL or kinda.
: 
: So I propose to jeave assert(), but remove the if (ibuf == NULL) {<...>}.
: 
: Don't forget to update box_ibuf_write_range() in sync (not it has no
: assert()).

  reply	other threads:[~2020-10-15 21:35 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-13 23:01 [Tarantool-patches] [PATCH 2.X v4 0/4] module api: extend for external merger Lua module Timur Safin
2020-10-13 23:01 ` [Tarantool-patches] [PATCH 2.X v4 1/4] module api: export box_tuple_validate Timur Safin
2020-10-15 21:38   ` Alexander Turenko
2020-10-15 21:47     ` Timur Safin
2020-10-15 22:03   ` Vladislav Shpilevoy
2020-10-13 23:01 ` [Tarantool-patches] [PATCH 2.X v4 2/4] module api: export box_key_def_dup Timur Safin
2020-10-13 23:01 ` [Tarantool-patches] [PATCH 2.X v4 3/4] module api: introduced luaT_toibuf instead of luaL_checkibuf Timur Safin
2020-10-14  3:50   ` Alexander Turenko
2020-10-15 21:07     ` Timur Safin
2020-10-15 22:04   ` Vladislav Shpilevoy
2020-10-13 23:01 ` [Tarantool-patches] [PATCH 2.X v4 4/4] module api: box_ibuf_* wrappers Timur Safin
2020-10-14  3:31   ` Alexander Turenko
2020-10-15 21:35     ` Timur Safin [this message]
2020-10-15 21:42       ` Alexander Turenko
2020-10-15 21:44         ` Timur Safin
2020-10-15 21:52         ` Alexander Turenko
2020-10-15 22:07   ` Vladislav Shpilevoy
2020-10-15 22:20     ` Alexander Turenko
2020-10-15 22:27     ` Timur Safin
2020-10-15 22:47       ` Alexander Turenko
2020-10-15 22:37   ` Alexander Turenko
2020-10-15 22:48   ` Alexander Turenko
2020-10-15 22:39 ` [Tarantool-patches] [PATCH 2.X v4.1] " Timur Safin
2020-10-16  6:10 ` [Tarantool-patches] [PATCH 2.X v4 0/4] module api: extend for external merger Lua module Alexander Turenko

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='053201d6a33b$0c1c2f60$24548e20$@tarantool.org' \
    --to=tsafin@tarantool.org \
    --cc=alexander.turenko@tarantool.org \
    --cc=tarantool-patches@dev.tarantool.org \
    --cc=v.shpilevoy@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH 2.X v4 4/4] module api: box_ibuf_* wrappers' \
    /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