]> sigrok.org Git - libsigrok.git/commitdiff
serial: move sr_serial_extract_options() out of "have serial comm" condition
authorGerhard Sittig <redacted>
Wed, 22 Dec 2021 11:50:19 +0000 (12:50 +0100)
committerGerhard Sittig <redacted>
Wed, 22 Dec 2021 19:04:28 +0000 (20:04 +0100)
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
src/libsigrok-internal.h
src/serial.c

index 94cbbe02bebbbd874b3a59e9b5514f98355be2b7..67b73b5df00c55dfc99aa08ac72ec95cb9189196 100644 (file)
@@ -143,6 +143,9 @@ libsigrok_la_SOURCES += \
        src/serial_hid_victor.c \
        src/serial_libsp.c \
        src/scpi/scpi_serial.c
        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 += \
 endif
 if NEED_USB
 libsigrok_la_SOURCES += \
index 7a5b717d6d4c7482534a185fbb30ab67e48e2cb4..7b64c71463ef793b8e17c5a83832a6225f4cac30 100644 (file)
@@ -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);
                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);
 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
 
 #endif
 #endif
 
+SR_PRIV int sr_serial_extract_options(GSList *options,
+       const char **serial_device, const char **serial_options);
+
 /*--- bt/ API ---------------------------------------------------------------*/
 
 #ifdef HAVE_BLUETOOTH
 /*--- bt/ API ---------------------------------------------------------------*/
 
 #ifdef HAVE_BLUETOOTH
index 97bd3159b094f673e0db8070d87eadb960e1cab8..353b7ae14899f12d49cac0a3761469488faa971d 100644 (file)
@@ -925,6 +925,8 @@ SR_PRIV int serial_stream_detect(struct sr_serial_dev_inst *serial,
        return SR_ERR;
 }
 
        return SR_ERR;
 }
 
+#endif
+
 /**
  * Extract the serial device and options from the options linked list.
  *
 /**
  * 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;
 }
 
        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,
 /** @private */
 SR_PRIV int serial_source_add(struct sr_session *session,
        struct sr_serial_dev_inst *serial, int events, int timeout,