]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/hameg-hmo/protocol.c
drivers: Use std_*idx*() helpers in some more places.
[libsigrok.git] / src / hardware / hameg-hmo / protocol.c
index 6d2ad3c413a92466e36ba88297dfbfa5725bf386..0c4d57f3f6cf465ba34ff17b590a2924192e944c 100644 (file)
@@ -329,27 +329,22 @@ static int scope_state_get_array_option(struct sr_scpi_dev_inst *scpi,
                const char *command, const char *(*array)[], unsigned int n, int *result)
 {
        char *tmp;
-       unsigned int i;
+       int idx;
 
        if (sr_scpi_get_string(scpi, command, &tmp) != SR_OK) {
                g_free(tmp);
                return SR_ERR;
        }
 
-       for (i = 0; i < n; i++) {
-               if (!g_strcmp0(tmp, (*array)[i])) {
-                       *result = i;
-                       g_free(tmp);
-                       tmp = NULL;
-                       break;
-               }
-       }
-
-       if (tmp) {
+       if ((idx = std_str_idx_s(tmp, *array, n)) < 0) {
                g_free(tmp);
-               return SR_ERR;
+               return SR_ERR_ARG;
        }
 
+       *result = idx;
+
+       g_free(tmp);
+
        return SR_OK;
 }