Skip to content

Commit

Permalink
fix few -Wformat warnings (#582)
Browse files Browse the repository at this point in the history
* fix wrong libusb extract command
* update libusb to 1.0.21 under windows

* fix few -Wformat warnings
* add usleep realisation for win32 under mingw
  • Loading branch information
slyshykO authored and xor-gate committed Apr 3, 2017
1 parent 78ced6a commit 6902f47
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -1753,7 +1753,7 @@ int stlink_write_flash(stlink_t *sl, stm32_addr_t addr, uint8_t* base, uint32_t
return -1;
}
fprintf(stdout,"\rFlash page at addr: 0x%08lx erased",
(unsigned long)addr + off);
(unsigned long)(addr + off));
fflush(stdout);
page_count++;
}
Expand Down Expand Up @@ -1934,7 +1934,7 @@ int stlink_write_flash(stlink_t *sl, stm32_addr_t addr, uint8_t* base, uint32_t
if (sl->verbose >= 1) {
/* show progress. writing procedure is slow
and previous errors are misleading */
fprintf(stdout, "\r%3u/%lu pages written", write_block_count++, (unsigned long)len/sl->flash_pgsz);
fprintf(stdout, "\r%3u/%lu pages written", write_block_count++, (unsigned long)(len/sl->flash_pgsz));
fflush(stdout);
}
}
Expand Down
12 changes: 12 additions & 0 deletions src/mingw/mingw.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,18 @@ char *win32_strsep (char **stringp, const char *delim)
/* NOTREACHED */
}

void usleep(DWORD waitTime)
{
LARGE_INTEGER perf_cnt, start, now;

QueryPerformanceFrequency(&perf_cnt);
QueryPerformanceCounter(&start);

do {
QueryPerformanceCounter((LARGE_INTEGER*) &now);
} while ((now.QuadPart - start.QuadPart) / (float)perf_cnt.QuadPart * 1000 * 1000 < waitTime);
}

#endif


1 change: 1 addition & 0 deletions src/mingw/mingw.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,6 @@ ssize_t win32_read_socket(SOCKET fd, void *buf, int n);
ssize_t win32_write_socket(SOCKET fd, void *buf, int n);

static inline void sleep(unsigned ms) { Sleep(ms); }
void usleep(DWORD waitTime);

#endif
2 changes: 1 addition & 1 deletion src/tools/flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ int main(int ac, char** av)

if ( o.flash_size != 0u && o.flash_size != sl->flash_size ) {
sl->flash_size = o.flash_size;
printf("Forcing flash size: --flash=0x%08zX\n",sl->flash_size);
printf("Forcing flash size: --flash=0x%08X\n",(unsigned int)sl->flash_size);
}

sl->verbose = o.log_level;
Expand Down

0 comments on commit 6902f47

Please sign in to comment.