Tarantool development patches archive
 help / color / mirror / Atom feed
From: Cyrill Gorcunov <gorcunov@gmail.com>
To: tml <tarantool-patches@freelists.org>
Cc: Alexander Turenko <alexander.turenko@tarantool.org>,
	Konstantin Osipov <kostja@tarantool.org>,
	Cyrill Gorcunov <gorcunov@gmail.com>
Subject: [tarantool-patches] [PATCH 2/3] box/console: Drop redundant status parameter from return
Date: Sat, 27 Jul 2019 01:17:11 +0300	[thread overview]
Message-ID: <20190726221712.11191-3-gorcunov@gmail.com> (raw)
In-Reply-To: <20190726221712.11191-1-gorcunov@gmail.com>

In output_verify_opts and output_parse we return status variable
to point if function processed without error. This is redundant
we can simply return either error or nil, which is enough.

Part-of #3834
---
 src/box/lua/console.lua | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/src/box/lua/console.lua b/src/box/lua/console.lua
index 9258e7bbb..0c521b44a 100644
--- a/src/box/lua/console.lua
+++ b/src/box/lua/console.lua
@@ -72,15 +72,15 @@ end
 
 local function output_verify_opts(fmt, opts)
     if opts == nil then
-        return true, nil
+        return nil
     end
     if fmt == "lua" then
         if opts ~= "line" and opts ~= "block" then
             local msg = 'Wrong option "%s", expecting: line or block.'
-            return false, msg:format(opts)
+            return msg:format(opts)
         end
     end
-    return true, nil
+    return nil
 end
 
 local function output_parse(value)
@@ -92,23 +92,23 @@ local function output_parse(value)
     end
     for k, _ in pairs(output_handlers) do
         if k == fmt then
-            local status, err = output_verify_opts(fmt, opts)
-            if status ~= true then
-                return false, err
+            local err = output_verify_opts(fmt, opts)
+            if err then
+                return err
             end
-            return true, nil, fmt, opts
+            return nil, fmt, opts
         end
     end
     local msg = 'Invalid format "%s", supported languages: lua and yaml.'
-    return false, msg:format(value)
+    return msg:format(value)
 end
 
 local function set_default_output(value)
     if value == nil then
         error("Nil output value passed")
     end
-    local status, err, fmt, opts = output_parse(value)
-    if status ~= true then
+    local err, fmt, opts = output_parse(value)
+    if err then
         error(err)
     end
     default_output_format["fmt"] = fmt
@@ -180,8 +180,8 @@ local function set_language(storage, value)
 end
 
 local function set_output(storage, value)
-    local status, err, fmt, opts = output_parse(value)
-    if status ~= true then
+    local err, fmt, opts = output_parse(value)
+    if err then
         return error(err)
     end
     output_save(fmt, opts)
-- 
2.20.1

  parent reply	other threads:[~2019-07-26 22:17 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-26 22:17 [tarantool-patches] [PATCH 0/3] box/console: Cleanup and bug fix Cyrill Gorcunov
2019-07-26 22:17 ` [tarantool-patches] [PATCH 1/3] box/console: Don't allow arguments in get_default_output Cyrill Gorcunov
2019-07-28 18:44   ` [tarantool-patches] " Konstantin Osipov
2019-07-28 21:43     ` Cyrill Gorcunov
2019-07-26 22:17 ` Cyrill Gorcunov [this message]
2019-07-28 18:44   ` [tarantool-patches] Re: [PATCH 2/3] box/console: Drop redundant status parameter from return Konstantin Osipov
2019-07-26 22:17 ` [tarantool-patches] [PATCH 3/3] box/console: Test for nil value in args directly Cyrill Gorcunov
2019-07-28 18:46   ` [tarantool-patches] " Konstantin Osipov
2019-07-28 18:47   ` Konstantin Osipov
2019-07-28 21:42     ` Cyrill Gorcunov
2019-08-02 12:59 ` [tarantool-patches] Re: [PATCH 0/3] box/console: Cleanup and bug fix Kirill Yukhin
2019-08-02 13:26   ` Cyrill Gorcunov

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=20190726221712.11191-3-gorcunov@gmail.com \
    --to=gorcunov@gmail.com \
    --cc=alexander.turenko@tarantool.org \
    --cc=kostja@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='Re: [tarantool-patches] [PATCH 2/3] box/console: Drop redundant status parameter from return' \
    /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