]> sigrok.org Git - libsigrok.git/commitdiff
gwinstek-gpd: Avoid some unnecessary assignments.
authorUwe Hermann <redacted>
Thu, 14 Jun 2018 20:20:57 +0000 (22:20 +0200)
committerUwe Hermann <redacted>
Thu, 14 Jun 2018 20:48:26 +0000 (22:48 +0200)
src/hardware/gwinstek-gpd/protocol.c

index ba69fed4a1fb052d22a3fab462bd24f64f25ee50..a054e91be962223a6ef58cde0c88eeeacdb300f7 100644 (file)
@@ -126,6 +126,9 @@ SR_PRIV int gpd_receive_data(int fd, int revents, void *cb_data)
                        g_free(reply_esc);
                } else {
                        for (i = 0; i < devc->model->num_channels; i++) {
+                               packet.type = SR_DF_ANALOG;
+                               packet.payload = &analog;
+
                                reply[0] = '\0';
                                gpd_receive_reply(serial, reply, sizeof(reply));
                                if (sscanf(reply, "%f", &devc->config[i].output_voltage_max) != 1) {
@@ -134,12 +137,8 @@ SR_PRIV int gpd_receive_data(int fd, int revents, void *cb_data)
                                        return TRUE;
                                }
 
-                               sr_analog_init(&analog, &encoding, &meaning, &spec, 0);
-
                                /* Send the value forward. */
-                               packet.type = SR_DF_ANALOG;
-                               packet.payload = &analog;
-
+                               sr_analog_init(&analog, &encoding, &meaning, &spec, 0);
                                analog.num_samples = 1;
                                ch = g_slist_nth_data(sdi->channels, i);
                                analog.meaning->channels =
@@ -160,12 +159,8 @@ SR_PRIV int gpd_receive_data(int fd, int revents, void *cb_data)
                                        return TRUE;
                                }
 
-                               sr_analog_init(&analog, &encoding, &meaning, &spec, 0);
-
                                /* Send the value forward. */
-                               packet.type = SR_DF_ANALOG;
-                               packet.payload = &analog;
-
+                               sr_analog_init(&analog, &encoding, &meaning, &spec, 0);
                                analog.num_samples = 1;
                                ch = g_slist_nth_data(sdi->channels, i);
                                analog.meaning->channels =