Skip to content

Commit a4e54b3

Browse files
committed
Fix build warnings seen on Windows
1 parent 5b68d3b commit a4e54b3

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

host/xscope_io_host.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
// Copyright (c) 2020-2022, XMOS Ltd, All rights reserved
2+
3+
// Suppress some unwanted warnings in the Windows build
4+
#ifdef _WIN32
5+
#define _CRT_SECURE_NO_WARNINGS
6+
#endif
7+
28
#include <assert.h>
39
#include <limits.h>
410
#include <stdio.h>
@@ -40,7 +46,7 @@ void xscope_print(
4046
printf("[DEVICE] ");
4147
device_print_newline = 0;
4248
}
43-
for (int i = 0; i < length; i++){
49+
for (unsigned i = 0; i < length; i++){
4450
char character = *(&data[i]);
4551
printf("%c", character);
4652
if (character == '\n'){
@@ -174,15 +180,15 @@ void xscope_record(
174180
case XSCOPE_ID_WRITE_BYTES:
175181
{
176182
if(VERBOSE) printf("[HOST] write idx: %u bytes transfer length: %u\n", write_file_idx, length);
183+
if(length > write_size){
184+
printf("[HOST] Error - write will overrun by %d bytes.", length - write_size);
185+
assert(0);
186+
}
177187
fwrite(databytes, 1, length, host_files[write_file_idx].fp);
178188
write_size -= length;
179189
if(write_size == 0){
180190
if(VERBOSE) printf("[HOST] Normal end of write transfer\n");
181191
}
182-
else if(write_size < 0){
183-
printf("[HOST] Error - write overran by %d bytes.", -write_size);
184-
assert(0);
185-
}
186192
else{
187193
//Still going
188194
}

0 commit comments

Comments
 (0)