]> sigrok.org Git - libsigrok.git/commitdiff
fx2lafw, sysclk-lwla: Avoid g_stat()
authorDaniel Elstner <redacted>
Wed, 16 Sep 2015 21:33:45 +0000 (23:33 +0200)
committerDaniel Elstner <redacted>
Wed, 16 Sep 2015 21:33:45 +0000 (23:33 +0200)
It turns out that g_stat() breaks apart when using 64 bit stat on
32-bit systems. Since the actual type of GStatBuf is decided when
glib/gstdio.h is included, it is thus possible for GLib itself to
be compiled with a different type than user code.

Ouch. Unfortunately going back to plain stat() also means that we
lose Unicode filename support on Windows.

src/hardware/fx2lafw/dslogic.c
src/hardware/sysclk-lwla/lwla.c

index 84d210b3d83132a99a53bbb6c5911ea9a1a9c213..7363faacf2b38ab328420417a098ab7afbf7b462 100644 (file)
@@ -39,7 +39,7 @@ int dslogic_fpga_firmware_upload(const struct sr_dev_inst *sdi,
                const char *filename)
 {
        FILE *fw;
-       GStatBuf st;
+       struct stat st;
        struct sr_usb_dev_inst *usb;
        int chunksize, result, ret;
        unsigned char *buf;
@@ -49,7 +49,7 @@ int dslogic_fpga_firmware_upload(const struct sr_dev_inst *sdi,
        sr_dbg("Uploading FPGA firmware at %s.", filename);
 
        usb = sdi->conn;
-       if (g_stat(filename, &st) < 0) {
+       if (stat(filename, &st) < 0) {
                sr_err("Unable to upload FPGA firmware: %s", g_strerror(errno));
                return SR_ERR;
        }
index 39dccbd2abb45a9e60684d0652415b3e9bf04fac..ab9fece8df1a41614d126124f6e90c34c2095875 100644 (file)
@@ -19,6 +19,7 @@
 
 #include <config.h>
 #include <errno.h>
+#include <sys/stat.h>
 #include <glib/gstdio.h>
 #include <libsigrok/libsigrok.h>
 #include "libsigrok-internal.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;