[cli] fix GetOwner function for console cli backend (#3486)

Current implementation of GetOwner function for single-instance CLI
assumed that `cli_uart` backend is used. This caused application
crash when different backend was used and `cli_uart` was not
initialized (and in result sUartServer static pointer was not set).

This commit fixes the issue by moving static CLI Server pointer and
the mInterpreter field to the to the base Server class and providing
getter method to obtain the Interpreter instance. With this approach,
any backend derived from the Server class will be able to initialize
the static pointer and will provide a valid reference to the
Interpreter class instance.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
This commit is contained in:
Robert Lubos
2019-01-23 01:07:46 +01:00
committed by Jonathan Hui
parent b1686c61f4
commit 9cb48245e5
20 changed files with 99 additions and 41 deletions
+1 -1
View File
@@ -3916,7 +3916,7 @@ Interpreter &Interpreter::GetOwner(OwnerLocator &aOwnerLocator)
#else
OT_UNUSED_VARIABLE(aOwnerLocator);
Interpreter &interpreter = Uart::sUartServer->GetInterpreter();
Interpreter &interpreter = Server::sServer->GetInterpreter();
#endif
return interpreter;
}