]> sigrok.org Git - libsigrok.git/blobdiff - src/serial_hid.c
hameg-hmo: Add SR_CONF_HIGH_RESOLUTION and SR_CONF_PEAK_DETECTION.
[libsigrok.git] / src / serial_hid.c
index d2776fc7d79cf2f789d3d62939c3b7892e764132..4a5f9bb98995324fa82c9c16158a8a7d0d68cc78 100644 (file)
@@ -199,14 +199,14 @@ static GSList *ser_hid_hidapi_list(GSList *list, sr_ser_list_append_t append)
                pid = curdev->product_id;
                desc = g_string_sized_new(128);
                g_string_append_printf(desc, "HID");
-               if (manuf)
+               if (manuf && wcslen(manuf) != 0)
                        g_string_append_printf(desc, " %ls", manuf);
-               if (prod)
+               if (prod && wcslen(prod) != 0)
                        g_string_append_printf(desc, " %ls", prod);
-               if (serno)
+               if (serno && wcslen(serno) != 0)
                        g_string_append_printf(desc, " %ls", serno);
                if (vid && pid)
-                       g_string_append_printf(desc, " %04hx:%04hx", vid, pid);
+                       g_string_append_printf(desc, " [%04hx.%04hx]", vid, pid);
                list = append(list, name, desc->str);
                g_string_free(desc, TRUE);
                g_free(name);
@@ -591,9 +591,9 @@ static int ser_hid_setup_funcs(struct sr_serial_dev_inst *serial)
  * returns the chip index and advances the spec pointer upon match,
  * returns SER_HID_CHIP_UNKNOWN upon mismatch.
  */
-static enum ser_hid_chip_t ser_hid_chip_find_enum(char **spec_p)
+static enum ser_hid_chip_t ser_hid_chip_find_enum(const char **spec_p)
 {
-       gchar *spec;
+       const gchar *spec;
        enum ser_hid_chip_t idx;
        struct ser_hid_chip_functions *desc;
 
@@ -635,9 +635,8 @@ SR_PRIV const char *ser_hid_chip_find_name_vid_pid(uint16_t vid, uint16_t pid)
                if (!vid_pids)
                        continue;
                while (vid_pids->vid) {
-                       if (vid_pids->vid == vid && vid_pids->pid == pid) {
+                       if (vid_pids->vid == vid && vid_pids->pid == pid)
                                return desc->chipname;
-                       }
                        vid_pids++;
                }
        }
@@ -775,7 +774,8 @@ static int ser_hid_parse_conn_spec(
                        serno = g_strdup(p);
                        p += strlen(p);
                } else if (!chip) {
-                       char *copy, *endptr;
+                       char *copy;
+                       const char *endptr;
                        const char *name;
                        copy = g_strdup(p);
                        endptr = copy;
@@ -961,7 +961,7 @@ static int ser_hid_chip_search(enum ser_hid_chip_t *chip_ref,
                sr_dbg("DBG: %s(), name %s", __func__, name);
                if (!name || !*name)
                        return SR_ERR_NA;
-               chip = ser_hid_chip_find_enum((char **)&name);
+               chip = ser_hid_chip_find_enum(&name);
                sr_dbg("DBG: %s(), chip %d", __func__, chip);
                if (chip == SER_HID_CHIP_UNKNOWN)
                        return SR_ERR_NA;
@@ -1059,7 +1059,7 @@ static int ser_hid_chip_search(enum ser_hid_chip_t *chip_ref,
                sr_dbg("DBG: %s(), name %s", __func__, name);
                if (!name || !*name)
                        return SR_ERR_NA;
-               chip = ser_hid_chip_find_enum((char **)&name);
+               chip = ser_hid_chip_find_enum(&name);
                sr_dbg("DBG: %s(), chip %d", __func__, chip);
                if (chip == SER_HID_CHIP_UNKNOWN)
                        return SR_ERR_NA;
@@ -1298,10 +1298,8 @@ static int ser_hid_read(struct sr_serial_dev_inst *serial,
         * Immediately satisfy the caller's request from the RX buffer
         * if the requested amount of data is available already.
         */
-       if (sr_ser_has_queued_data(serial) >= count) {
-               rc = sr_ser_unqueue_rx_data(serial, buf, count);
-               return rc;
-       }
+       if (sr_ser_has_queued_data(serial) >= count)
+               return sr_ser_unqueue_rx_data(serial, buf, count);
 
        /*
         * When a timeout was specified, then determine the deadline
@@ -1387,9 +1385,8 @@ static int ser_hid_read(struct sr_serial_dev_inst *serial,
        if (got > count)
                got = count;
        sr_dbg("DBG: %s() passing %d bytes.", __func__, got);
-       rc = sr_ser_unqueue_rx_data(serial, buf, count);
 
-       return rc;
+       return sr_ser_unqueue_rx_data(serial, buf, count);
 }
 
 static struct ser_lib_functions serlib_hid = {