From 7fd8a8f7e9f8a82e732e19abff86433e0364724b Mon Sep 17 00:00:00 2001 From: Gerhard Sittig Date: Wed, 22 Dec 2021 12:50:19 +0100 Subject: [PATCH] serial: move sr_serial_extract_options() out of "have serial comm" condition The sr_serial_extract_options() routine strictly operates on variables and is applicable to any driver which accepts conn= specs. No physical serial communication is involved, the HAVE_SERIAL_COMM condition check is too strict a constraint. This silences warnings in build configurations where serial communication is not available: ../src/scpi/scpi.c: In function 'sr_scpi_scan': src/scpi/scpi.c:325 col 2: warning: implicit declaration of function 'sr_serial_extract_options' [-Wimplicit-function-declaration] (void)sr_serial_extract_options(options, &resource, &serialcomm); ^ Implementation detail: List the serial.c source file two times in the Makefile to avoid confusion when the file is "missing" in the list of related source files in the "serial comm supported" case. All serial.c content already was under the HAVE_SERIAL_COMM condition, so compiling that file in all build configurations is not an issue. --- Makefile.am | 3 +++ src/libsigrok-internal.h | 5 +++-- src/serial.c | 4 ++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Makefile.am b/Makefile.am index 94cbbe02..67b73b5d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -143,6 +143,9 @@ libsigrok_la_SOURCES += \ src/serial_hid_victor.c \ src/serial_libsp.c \ src/scpi/scpi_serial.c +else +libsigrok_la_SOURCES += \ + src/serial.c endif if NEED_USB libsigrok_la_SOURCES += \ diff --git a/src/libsigrok-internal.h b/src/libsigrok-internal.h index 7a5b717d..7b64c714 100644 --- a/src/libsigrok-internal.h +++ b/src/libsigrok-internal.h @@ -1916,8 +1916,6 @@ SR_PRIV int serial_stream_detect(struct sr_serial_dev_inst *serial, size_t packet_size, packet_valid_callback is_valid, packet_valid_len_callback is_valid_len, size_t *return_size, uint64_t timeout_ms); -SR_PRIV int sr_serial_extract_options(GSList *options, const char **serial_device, - const char **serial_options); SR_PRIV int serial_source_add(struct sr_session *session, struct sr_serial_dev_inst *serial, int events, int timeout, sr_receive_data_callback cb, void *cb_data); @@ -1996,6 +1994,9 @@ SR_PRIV const char *ser_hid_chip_find_name_vid_pid(uint16_t vid, uint16_t pid); #endif #endif +SR_PRIV int sr_serial_extract_options(GSList *options, + const char **serial_device, const char **serial_options); + /*--- bt/ API ---------------------------------------------------------------*/ #ifdef HAVE_BLUETOOTH diff --git a/src/serial.c b/src/serial.c index 97bd3159..353b7ae1 100644 --- a/src/serial.c +++ b/src/serial.c @@ -925,6 +925,8 @@ SR_PRIV int serial_stream_detect(struct sr_serial_dev_inst *serial, return SR_ERR; } +#endif + /** * Extract the serial device and options from the options linked list. * @@ -977,6 +979,8 @@ SR_PRIV int sr_serial_extract_options(GSList *options, return SR_OK; } +#ifdef HAVE_SERIAL_COMM + /** @private */ SR_PRIV int serial_source_add(struct sr_session *session, struct sr_serial_dev_inst *serial, int events, int timeout, -- 2.30.2