The above function must always return an 'enum sp_transport'. So, add a 'NONE' type and return it if no port ist present.
Fixes bug #1531. Signed-off-by: Wolfram Sang <w...@the-dreams.de> --- I added this also to Bugzilla, but I prefer discussions via mail :) I think this is a viable fix. Build tested only with gcc-8.3. libserialport.h | 4 +++- serialport.c | 5 +---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/libserialport.h b/libserialport.h index 7467f74..9f09023 100644 --- a/libserialport.h +++ b/libserialport.h @@ -450,7 +450,9 @@ enum sp_transport { /** USB serial port adapter. @since 0.1.1 */ SP_TRANSPORT_USB, /** Bluetooth serial port adapter. @since 0.1.1 */ - SP_TRANSPORT_BLUETOOTH + SP_TRANSPORT_BLUETOOTH, + /** could not determine port. @since 0.1.1 */ + SP_TRANSPORT_NONE, }; /** diff --git a/serialport.c b/serialport.c index 51fe078..eddd028 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_NONE); } SP_API enum sp_return sp_get_port_usb_bus_address(const struct sp_port *port, -- 2.20.1 _______________________________________________ sigrok-devel mailing list sigrok-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sigrok-devel