]> sigrok.org Git - libsigrok.git/commitdiff
kingst-la2016: style nits in FPGA code path and threshold selection
authorGerhard Sittig <redacted>
Sun, 23 Jan 2022 20:19:38 +0000 (21:19 +0100)
committerGerhard Sittig <redacted>
Sun, 6 Feb 2022 17:53:53 +0000 (18:53 +0100)
Check sigrok routine return codes for SR_OK not zero. The snprintf(3)
routine does include the NUL termination in the length spec. Use size_t
for the threshold selection which in essence is an enumeration.

src/hardware/kingst-la2016/protocol.c
src/hardware/kingst-la2016/protocol.h

index 067ab4ada9df4fc795dd4ff6795cbae5ee1024a3..3ef10f6ef77fbe60f827282fe75b75b41ace61ac 100644 (file)
@@ -304,7 +304,7 @@ static int upload_fpga_bitstream(const struct sr_dev_inst *sdi,
                pos += len;
        }
        sr_resource_close(drvc->sr_ctx, &bitstream);
-       if (ret != 0)
+       if (ret != SR_OK)
                return ret;
        sr_info("FPGA bitstream upload (%" PRIu64 " bytes) done.",
                bitstream.size);
@@ -831,7 +831,7 @@ SR_PRIV int la2016_upload_firmware(struct sr_context *sr_ctx,
        libusb_device *dev, uint16_t product_id)
 {
        char fw_file[1024];
-       snprintf(fw_file, sizeof(fw_file) - 1, UC_FIRMWARE, product_id);
+       snprintf(fw_file, sizeof(fw_file), UC_FIRMWARE, product_id);
        return ezusb_upload_firmware(sr_ctx, dev, USB_CONFIGURATION, fw_file);
 }
 
index 0d61fa71fbef5a63055138eae271bb81e29528c6..d5c967ad053c69889601b79bf973f6d7c850746b 100644 (file)
@@ -108,7 +108,7 @@ struct dev_context {
 
        /* User specified parameters. */
        struct pwm_setting pwm_setting[LA2016_NUM_PWMCH_MAX];
-       unsigned int threshold_voltage_idx;
+       size_t threshold_voltage_idx;
        float threshold_voltage;
        uint64_t max_samplerate;
        uint64_t cur_samplerate;