diff --git a/src/platforms/hosted/bmp_libusb.c b/src/platforms/hosted/bmp_libusb.c index c0d060cbb13..60b4274f68d 100644 --- a/src/platforms/hosted/bmp_libusb.c +++ b/src/platforms/hosted/bmp_libusb.c @@ -245,6 +245,8 @@ void stlinkv2_read_serial(libusb_device_descriptor_s *device_descriptor, libusb_ } #if defined(_WIN32) || defined(__CYGWIN__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wcast-qual" static probe_info_s *process_ftdi_probe(void) { DWORD ftdi_dev_count = 0; @@ -285,7 +287,7 @@ static probe_info_s *process_ftdi_probe(void) if (probe_skip) { // Clean up any previous serial number to skip use_serial = true; - free((void *)probe_skip); + free((char*)probe_skip); probe_skip = NULL; } @@ -322,11 +324,14 @@ static probe_info_s *process_ftdi_probe(void) free(product); } } - if (probe_skip) - free((void *)probe_skip); + if (probe_skip) { + free((char*)probe_skip); + probe_skip = NULL; + } free(dev_info); return probe_list; } +#pragma GCC diagnostic pop #endif void orbtrace_read_version(libusb_device *device, libusb_device_handle *handle, char *version, size_t buffer_size) diff --git a/src/platforms/hosted/windows/ftdi.c b/src/platforms/hosted/windows/ftdi.c index 5254c3411df..60e5bae892a 100644 --- a/src/platforms/hosted/windows/ftdi.c +++ b/src/platforms/hosted/windows/ftdi.c @@ -149,11 +149,22 @@ int ftdi_read_data(struct ftdi_context *ftdi, unsigned char *buf, const int size int ftdi_write_data(struct ftdi_context *ftdi, const unsigned char *buf, int size) { - (void)ftdi; - DWORD bytes_written; - if (FT_Write(ftdi_handle, (unsigned char *)buf, size, &bytes_written) != FT_OK) - return 0; - return bytes_written; + (void)ftdi; + DWORD bytes_written; + + unsigned char *temp_buf = (unsigned char *)malloc(size); + if (temp_buf == NULL) { + return 0; + } + memcpy(temp_buf, buf, size); + + if (FT_Write(ftdi_handle, temp_buf, size, &bytes_written) != FT_OK) { + free(temp_buf); + return 0; + } + + free(temp_buf); + return bytes_written; } int ftdi_write_data_set_chunksize(struct ftdi_context *ftdi, unsigned int chunksize)