]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/sysclk-lwla/lwla.c
Fix a few "value never read" scan-build warnings.
[libsigrok.git] / src / hardware / sysclk-lwla / lwla.c
index e0e1c87b713b2a26b6212f5bead0ee4ebc35481c..ab9fece8df1a41614d126124f6e90c34c2095875 100644 (file)
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include <config.h>
 #include <errno.h>
+#include <sys/stat.h>
 #include <glib/gstdio.h>
-#include "libsigrok.h"
+#include <libsigrok/libsigrok.h>
 #include "libsigrok-internal.h"
 #include "protocol.h"
 #include "lwla.h"
  */
 static unsigned char *load_bitstream_file(const char *filename, int *length_p)
 {
-       GStatBuf statbuf;
+       struct stat statbuf;
        FILE *file;
        unsigned char *stream;
        size_t length, count;
 
        /* Retrieve and validate the file size. */
-       if (g_stat(filename, &statbuf) < 0) {
+       if (stat(filename, &statbuf) < 0) {
                sr_err("Failed to access bitstream file: %s.",
                       g_strerror(errno));
                return NULL;
@@ -193,12 +195,12 @@ SR_PRIV int lwla_read_reg(const struct sr_usb_dev_inst *usb,
        command[0] = LWLA_WORD(CMD_READ_REG);
        command[1] = LWLA_WORD(reg);
 
-       ret = lwla_send_command(usb, command, G_N_ELEMENTS(command));
+       ret = lwla_send_command(usb, command, ARRAY_SIZE(command));
 
        if (ret != SR_OK)
                return ret;
 
-       ret = lwla_receive_reply(usb, reply, G_N_ELEMENTS(reply), 1);
+       ret = lwla_receive_reply(usb, reply, ARRAY_SIZE(reply), 1);
 
        if (ret == SR_OK)
                *value = LWLA_TO_UINT32(reply[0]);
@@ -216,7 +218,7 @@ SR_PRIV int lwla_write_reg(const struct sr_usb_dev_inst *usb,
        command[2] = LWLA_WORD_0(value);
        command[3] = LWLA_WORD_1(value);
 
-       return lwla_send_command(usb, command, G_N_ELEMENTS(command));
+       return lwla_send_command(usb, command, ARRAY_SIZE(command));
 }
 
 SR_PRIV int lwla_write_regs(const struct sr_usb_dev_inst *usb,