From 2a09aac26862e8b8c88baa74634f6cb8f62352fc Mon Sep 17 00:00:00 2001 From: Daniel Elstner Date: Wed, 16 Sep 2015 23:33:45 +0200 Subject: [PATCH] fx2lafw, sysclk-lwla: Avoid g_stat() 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 | 4 ++-- src/hardware/sysclk-lwla/lwla.c | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/hardware/fx2lafw/dslogic.c b/src/hardware/fx2lafw/dslogic.c index 84d210b3..7363faac 100644 --- a/src/hardware/fx2lafw/dslogic.c +++ b/src/hardware/fx2lafw/dslogic.c @@ -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; } diff --git a/src/hardware/sysclk-lwla/lwla.c b/src/hardware/sysclk-lwla/lwla.c index 39dccbd2..ab9fece8 100644 --- a/src/hardware/sysclk-lwla/lwla.c +++ b/src/hardware/sysclk-lwla/lwla.c @@ -19,6 +19,7 @@ #include #include +#include #include #include #include "libsigrok-internal.h" @@ -33,13 +34,13 @@ */ 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;