client/Process: refactor return statements

This commit is contained in:
Max Kellermann 2019-04-03 22:30:38 +02:00
parent 9711cee26d
commit 2142d070a3

View File

@ -65,8 +65,6 @@ Client::ProcessLine(char *line) noexcept
return CommandResult::CLOSE; return CommandResult::CLOSE;
} }
CommandResult ret;
if (StringIsEqual(line, "noidle")) { if (StringIsEqual(line, "noidle")) {
if (idle_waiting) { if (idle_waiting) {
/* send empty idle response and leave idle mode */ /* send empty idle response and leave idle mode */
@ -96,8 +94,8 @@ Client::ProcessLine(char *line) noexcept
auto &&list = cmd_list.Commit(); auto &&list = cmd_list.Commit();
ret = ProcessCommandList(cmd_list.IsOKMode(), auto ret = ProcessCommandList(cmd_list.IsOKMode(),
std::move(list)); std::move(list));
FormatDebug(client_domain, FormatDebug(client_domain,
"[%u] process command " "[%u] process command "
"list returned %i", num, int(ret)); "list returned %i", num, int(ret));
@ -110,6 +108,8 @@ Client::ProcessLine(char *line) noexcept
command_success(*this); command_success(*this);
cmd_list.Reset(); cmd_list.Reset();
return ret;
} else { } else {
if (!cmd_list.Add(line)) { if (!cmd_list.Add(line)) {
FormatWarning(client_domain, FormatWarning(client_domain,
@ -120,20 +120,20 @@ Client::ProcessLine(char *line) noexcept
return CommandResult::CLOSE; return CommandResult::CLOSE;
} }
ret = CommandResult::OK; return CommandResult::OK;
} }
} else { } else {
if (StringIsEqual(line, CLIENT_LIST_MODE_BEGIN)) { if (StringIsEqual(line, CLIENT_LIST_MODE_BEGIN)) {
cmd_list.Begin(false); cmd_list.Begin(false);
ret = CommandResult::OK; return CommandResult::OK;
} else if (StringIsEqual(line, CLIENT_LIST_OK_MODE_BEGIN)) { } else if (StringIsEqual(line, CLIENT_LIST_OK_MODE_BEGIN)) {
cmd_list.Begin(true); cmd_list.Begin(true);
ret = CommandResult::OK; return CommandResult::OK;
} else { } else {
FormatDebug(client_domain, FormatDebug(client_domain,
"[%u] process command \"%s\"", "[%u] process command \"%s\"",
num, line); num, line);
ret = command_process(*this, 0, line); auto ret = command_process(*this, 0, line);
FormatDebug(client_domain, FormatDebug(client_domain,
"[%u] command returned %i", "[%u] command returned %i",
num, int(ret)); num, int(ret));
@ -143,8 +143,8 @@ Client::ProcessLine(char *line) noexcept
if (ret == CommandResult::OK) if (ret == CommandResult::OK)
command_success(*this); command_success(*this);
return ret;
} }
} }
return ret;
} }