From 086a4181459ff5723d71a1604ddef058030155dd Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Sun, 5 Apr 2020 23:24:50 +0200 Subject: [PATCH] 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 --- serialport.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/serialport.c b/serialport.c index 51fe078..1daba1c 100644 --- a/serialport.c +++ b/serialport.c @@ -155,10 +155,7 @@ SP_API enum sp_transport sp_get_port_transport(const struct sp_port *port) { TRACE("%p", port); - if (!port) - RETURN_ERROR(SP_ERR_ARG, "Null port"); - - RETURN_INT(port->transport); + RETURN_INT(port ? port->transport : SP_TRANSPORT_NATIVE); } SP_API enum sp_return sp_get_port_usb_bus_address(const struct sp_port *port,