]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/asix-sigma/asix-sigma.c
Build: Set local include directories in Makefile.am
[libsigrok.git] / src / hardware / asix-sigma / asix-sigma.c
index 957b1d1ac7c7a2098a979be701006fdf392dd80f..eaade4bf8077ea9081c619867c1092fdfffba575 100644 (file)
@@ -28,7 +28,7 @@
 #include <ftdi.h>
 #include <string.h>
 #include <unistd.h>
-#include "libsigrok.h"
+#include <libsigrok/libsigrok.h>
 #include "libsigrok-internal.h"
 #include "asix-sigma.h"
 
@@ -130,13 +130,23 @@ static int sigma_write(void *buf, size_t size, struct dev_context *devc)
        return ret;
 }
 
+/*
+ * NOTE: We chose the buffer size to be large enough to hold any write to the
+ * device. We still print a message just in case.
+ */
 static int sigma_write_register(uint8_t reg, uint8_t *data, size_t len,
                                struct dev_context *devc)
 {
        size_t i;
-       uint8_t buf[len + 2];
+       uint8_t buf[80];
        int idx = 0;
 
+       if ((len + 2) > sizeof(buf)) {
+               sr_err("Attempted to write %zu bytes, but buffer is too small.",
+                      len + 2);
+               return SR_ERR_BUG;
+       }
+
        buf[idx++] = REG_ADDR_LOW | (reg & 0xf);
        buf[idx++] = REG_ADDR_HIGH | (reg >> 4);
 
@@ -335,7 +345,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
 
        (void)options;
 
-       drvc = di->priv;
+       drvc = di->context;
 
        devices = NULL;
 
@@ -401,7 +411,7 @@ free:
 
 static GSList *dev_list(const struct sr_dev_driver *di)
 {
-       return ((struct drv_context *)(di->priv))->instances;
+       return ((struct drv_context *)(di->context))->instances;
 }
 
 /*
@@ -1544,5 +1554,5 @@ SR_PRIV struct sr_dev_driver asix_sigma_driver_info = {
        .dev_close = dev_close,
        .dev_acquisition_start = dev_acquisition_start,
        .dev_acquisition_stop = dev_acquisition_stop,
-       .priv = NULL,
+       .context = NULL,
 };