summaryrefslogtreecommitdiff
path: root/util/stm32mon.c
diff options
context:
space:
mode:
Diffstat (limited to 'util/stm32mon.c')
-rw-r--r--util/stm32mon.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/util/stm32mon.c b/util/stm32mon.c
index 665c4b28b2..c0807ce9d8 100644
--- a/util/stm32mon.c
+++ b/util/stm32mon.c
@@ -412,7 +412,10 @@ int send_command(int fd, uint8_t cmd, payload_t *loads, int cnt,
int res, i, c;
payload_t *p;
int readcnt = 0;
- uint8_t cmd_frame[] = { SOF, cmd, 0xff ^ cmd }; /* XOR checksum */
+
+ uint8_t cmd_frame[] = { SOF, cmd,
+ /* XOR checksum */
+ (uint8_t)(0xff ^ cmd) };
/* only the SPI mode needs the Start Of Frame byte */
int cmd_off = mode == MODE_SPI ? 0 : 1;
@@ -434,7 +437,7 @@ int send_command(int fd, uint8_t cmd, payload_t *loads, int cnt,
for (p = loads, c = 0; c < cnt; c++, p++) {
uint8_t crc = 0;
int size = p->size;
- uint8_t *data = malloc(size + 1), *data_ptr;
+ uint8_t *data = (uint8_t *)(malloc(size + 1)), *data_ptr;
if (data == NULL) {
fprintf(stderr,
@@ -710,7 +713,7 @@ int command_ext_erase(int fd, uint16_t count, uint16_t start)
int i;
/* not a special value : build a list of pages */
load.size = 2 * (count + 1);
- pages = malloc(load.size);
+ pages = (uint16_t *)(malloc(load.size));
if (!pages)
return -ENOMEM;
load.data = (uint8_t *)pages;
@@ -754,7 +757,7 @@ int command_erase_i2c(int fd, uint16_t count, uint16_t start)
*/
load_cnt = 2;
load[1].size = 2 * count;
- pages = malloc(load[1].size);
+ pages = (uint16_t *)(malloc(load[1].size));
if (!pages)
return -ENOMEM;
load[1].data = (uint8_t *)pages;
@@ -789,7 +792,7 @@ int command_erase(int fd, uint16_t count, uint16_t start)
int i;
/* not a special value : build a list of pages */
load.size = count + 1;
- pages = malloc(load.size);
+ pages = (uint8_t *)(malloc(load.size));
if (!pages)
return -ENOMEM;
load.data = (uint8_t *)pages;
@@ -906,7 +909,7 @@ int read_flash(int fd, struct stm32_def *chip, const char *filename,
if (!size)
size = chip->flash_size;
- buffer = malloc(size);
+ buffer = (uint8_t *)(malloc(size));
if (!buffer) {
fprintf(stderr, "Cannot allocate %d bytes\n", size);
return -ENOMEM;
@@ -939,7 +942,7 @@ int write_flash(int fd, struct stm32_def *chip, const char *filename,
int res, written;
FILE *hnd;
int size = chip->flash_size;
- uint8_t *buffer = malloc(size);
+ uint8_t *buffer = (uint8_t *)(malloc(size));
if (!buffer) {
fprintf(stderr, "Cannot allocate %d bytes\n", size);