From: Vladimir Davydov <vdavydov.dev@gmail.com>
To: Olga Arkhangelskaia <arkholga@tarantool.org>
Cc: tarantool-patches@freelists.org
Subject: Re: [tarantool-patches] [PATCH v2 1/2] Refactoring in string validation of log parameters
Date: Thu, 19 Jul 2018 15:24:37 +0300 [thread overview]
Message-ID: <20180719122437.3x3s2e6jkbrzjvme@esperanza> (raw)
In-Reply-To: <20180719105449.49710-1-arkholga@tarantool.org>
On Thu, Jul 19, 2018 at 01:54:48PM +0300, Olga Arkhangelskaia wrote:
> Removed unnecessary double check of log configuration string.
> Instead all log configuration checks were moved to separate function.
> ---
> Branch: https://github.com/tarantool/tarantool/tree/OKriw/refactor-log-cfg
>
> v1:
> https://www.freelists.org/post/tarantool-patches/PATCH-Refactoring-in-string-validation-of-log-parametrs
>
> Changes in v2:
> - exceptions transfered to box.cc
> - say_parse_logger_type traansfered to say_ckeck_cfg
>
>
> src/box/box.cc | 40 ++++++++--------------------------------
> src/say.c | 34 +++++++++++++++++++++++++---------
> src/say.h | 8 ++++----
> 3 files changed, 37 insertions(+), 45 deletions(-)
>
> diff --git a/src/box/box.cc b/src/box/box.cc
> index 7c6312d78..db598957a 100644
> --- a/src/box/box.cc
> +++ b/src/box/box.cc
> @@ -356,41 +356,17 @@ box_check_say()
> const char *log = cfg_gets("log");
> if (log == NULL)
> return;
> - enum say_logger_type type;
> - if (say_parse_logger_type(&log, &type) < 0) {
> - tnt_raise(ClientError, ER_CFG, "log",
> - diag_last_error(diag_get())->errmsg);
> - }
> -
> - if (say_check_init_str(log) == -1) {
> -
> - diag_raise();
> - }
> -
> - if (type == SAY_LOGGER_SYSLOG) {
> - struct say_syslog_opts opts;
> - if (say_parse_syslog_opts(log, &opts) < 0) {
> - if (diag_last_error(diag_get())->type ==
> - &type_IllegalParams) {
> - tnt_raise(ClientError, ER_CFG, "log",
> - diag_last_error(diag_get())->errmsg);
> - }
> - }
> - say_free_syslog_opts(&opts);
> - diag_raise();
> - }
>
> const char *log_format = cfg_gets("log_format");
> - enum say_format format = say_format_by_name(log_format);
> - if (format == say_format_MAX)
> - diag_set(ClientError, ER_CFG, "log_format",
> - "expected 'plain' or 'json'");
> - if (type == SAY_LOGGER_SYSLOG && format == SF_JSON) {
> - tnt_raise(ClientError, ER_ILLEGAL_PARAMS, "log, log_format");
> - }
> int log_nonblock = cfg_getb("log_nonblock");
> - if (log_nonblock == 1 && type == SAY_LOGGER_FILE) {
> - tnt_raise(ClientError, ER_ILLEGAL_PARAMS, "log, log_nonblock");
> + if (say_check_cfg(log, log_format, log_nonblock) < 0) {
> + if (diag_last_error(diag_get())->type ==
> + &type_IllegalParams) {
> + tnt_raise(ClientError, ER_CFG,
> + "log, log_format or log_nonblock",
> + diag_last_error(diag_get())->errmsg);
Hmm, no - an error message produced by this code doesn't look neat,
nor informative:
Incorrect value for option 'log, log_format or log_nonblock': Illegal parametrs log, log_nonblock
I guess, I see now why all these checks sit in box.cc instead of being
isolated in say.c - for the sake of error reporting. Sorry I confused
you :-( If you don't have a better idea in mind, let's return to where
we started, i.e. to removal of say_check_init_str(). Since it's not
going to be used after you remove the call to it from box_check_say(),
please remove it from say.[hc] as well.
prev parent reply other threads:[~2018-07-19 12:24 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-19 10:54 Olga Arkhangelskaia
2018-07-19 10:54 ` [tarantool-patches] [PATCH v2 2/2] Added strdup fail checks in say Olga Arkhangelskaia
2018-07-19 12:26 ` Vladimir Davydov
2018-07-19 13:12 ` Vladimir Davydov
2018-07-19 12:24 ` Vladimir Davydov [this message]
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=20180719122437.3x3s2e6jkbrzjvme@esperanza \
--to=vdavydov.dev@gmail.com \
--cc=arkholga@tarantool.org \
--cc=tarantool-patches@freelists.org \
--subject='Re: [tarantool-patches] [PATCH v2 1/2] Refactoring in string validation of log parameters' \
/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