From: Gerhard Sittig Date: Sun, 23 Jan 2022 20:19:38 +0000 (+0100) Subject: kingst-la2016: style nits in FPGA code path and threshold selection X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=5eb1b63dfc159144ce64c03eab54ca4d4ec9f594;p=libsigrok.git kingst-la2016: style nits in FPGA code path and threshold selection 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. --- diff --git a/src/hardware/kingst-la2016/protocol.c b/src/hardware/kingst-la2016/protocol.c index 067ab4ad..3ef10f6e 100644 --- a/src/hardware/kingst-la2016/protocol.c +++ b/src/hardware/kingst-la2016/protocol.c @@ -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); } diff --git a/src/hardware/kingst-la2016/protocol.h b/src/hardware/kingst-la2016/protocol.h index 0d61fa71..d5c967ad 100644 --- a/src/hardware/kingst-la2016/protocol.h +++ b/src/hardware/kingst-la2016/protocol.h @@ -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;