Separated waiting for message from acting on message.

Necessary refactoring of parameter types propagated through source.
This commit is contained in:
2019-08-21 15:55:33 +01:00
parent 2f8e417d00
commit 2987cbe26e
12 changed files with 51 additions and 45 deletions

View File

@@ -24,11 +24,11 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
using namespace std;
shared_ptr<U2F_CMD> U2F_CMD::get(const shared_ptr<U2FMessage> uMsg)
shared_ptr<U2F_CMD> U2F_CMD::get(const U2FMessage& uMsg)
{
try
{
switch (uMsg->cmd)
switch (uMsg.cmd)
{
case U2FHID_PING:
return make_shared<U2F_Ping_CMD>(uMsg);
@@ -37,13 +37,13 @@ shared_ptr<U2F_CMD> U2F_CMD::get(const shared_ptr<U2FMessage> uMsg)
case U2FHID_INIT:
return make_shared<U2F_Init_CMD>(uMsg);
default:
U2FMessage::error(uMsg->cid, ERR_INVALID_CMD);
U2FMessage::error(uMsg.cid, ERR_INVALID_CMD);
return {};
}
}
catch (runtime_error& ignored)
{
U2FMessage::error(uMsg->cid, ERR_OTHER);
U2FMessage::error(uMsg.cid, ERR_OTHER);
return {};
}
}