Return proper type when sp_get_port_transport() fails

The above function must always return an 'enum sp_transport'. So, return
NATIVE if no port is present because its effective meaning within the
API is "you shouldn't call any transport-specific functions for this
port handle".

Fixes bug #1531.

Signed-off-by: Wolfram Sang <wsa@kernel.org>
This commit is contained in:
Wolfram Sang 2020-04-05 23:24:50 +02:00 committed by Wolfram Sang
parent ffbfc5c76b
commit 086a418145
1 changed files with 1 additions and 4 deletions

View File

@ -155,10 +155,7 @@ SP_API enum sp_transport sp_get_port_transport(const struct sp_port *port)
{ {
TRACE("%p", port); TRACE("%p", port);
if (!port) RETURN_INT(port ? port->transport : SP_TRANSPORT_NATIVE);
RETURN_ERROR(SP_ERR_ARG, "Null port");
RETURN_INT(port->transport);
} }
SP_API enum sp_return sp_get_port_usb_bus_address(const struct sp_port *port, SP_API enum sp_return sp_get_port_usb_bus_address(const struct sp_port *port,