Make some casts explicit

This commit is contained in:
Kimmo Kulovesi
2014-02-04 18:34:34 +02:00
parent f6f9f1829d
commit 17fe2bca5f
4 changed files with 8 additions and 8 deletions

View File

@@ -103,7 +103,7 @@ argument_error:
}
ihex.flags |= IHEX_FLAG_ADDRESS_OVERFLOW;
}
while ((count = fread(buf, 1, sizeof(buf), infile))) {
while ((count = (unsigned int) fread(buf, 1, sizeof(buf), infile))) {
ihex_write_bytes(&ihex, buf, count);
}
ihex_end_write(&ihex);

View File

@@ -107,7 +107,7 @@ argument_error:
ihex_read_at_address(&ihex, (ihex_address_t) address_offset);
while (fgets(buf, sizeof(buf), infile)) {
count = strlen(buf);
count = (unsigned int) strlen(buf);
ihex_read_bytes(&ihex, buf, count);
line_number += (count && buf[count - 1] == '\n') ? 1 : 0;
}
@@ -154,7 +154,7 @@ ihex_data_read (struct ihex_state *ihex, enum ihex_record_type type,
"Seeking from 0x%lx to 0x%lx on line %lu\n",
file_position, address, line_number);
}
if (outfile == stdout || fseek(outfile, address, SEEK_SET)) {
if (outfile == stdout || fseek(outfile, (long) address, SEEK_SET)) {
if (file_position < address) {
// "seek" forward in stdout by writing NUL bytes
do {

View File

@@ -3,7 +3,7 @@
*
* See the header `kk_ihex.h` for instructions.
*
* Copyright (c) 2013 Kimmo Kulovesi, http://arkku.com/
* Copyright (c) 2013-2014 Kimmo Kulovesi, http://arkku.com/
* Provided with absolutely no warranty, use at your own risk only.
* Use and distribute freely, mark modified copies as such.
*/
@@ -82,7 +82,7 @@ ihex_end_read (struct ihex_state * const ihex) {
ihex->address |= ((ihex_address_t) ihex->data[1]) << 16;
#ifndef IHEX_DISABLE_SEGMENTS
} else if (type == IHEX_EXTENDED_SEGMENT_ADDRESS_RECORD) {
ihex->segment = (ihex->data[0] << 8) | ihex->data[1];
ihex->segment = (ihex_segment_t) ((ihex->data[0] << 8) | ihex->data[1]);
#endif
}
}
@@ -138,7 +138,7 @@ ihex_read_byte (struct ihex_state *ihex, int b) {
b <<= 8;
case (READ_ADDRESS_LSB_LOW >> 1):
// low byte of 16-bit address
ihex->address |= b;
ihex->address |= (unsigned) b;
break;
case (READ_RECORD_TYPE_LOW >> 1):
// record type

View File

@@ -3,7 +3,7 @@
*
* See the header `kk_ihex.h` for instructions.
*
* Copyright (c) 2013 Kimmo Kulovesi, http://arkku.com/
* Copyright (c) 2013-2014 Kimmo Kulovesi, http://arkku.com/
* Provided with absolutely no warranty, use at your own risk only.
* Use and distribute freely, mark modified copies as such.
*/
@@ -80,7 +80,7 @@ ihex_write_end_of_file (struct ihex_state * const ihex) {
w = ihex_buffer_byte(w, 0); // address msb
w = ihex_buffer_byte(w, 0); // address lsb
w = ihex_buffer_byte(w, IHEX_END_OF_FILE_RECORD); // record type
w = ihex_buffer_byte(w, ~IHEX_END_OF_FILE_RECORD + 1); // checksum
w = ihex_buffer_byte(w, ~((unsigned int)IHEX_END_OF_FILE_RECORD) + 1U); // checksum
#endif
w = ihex_buffer_newline(w);
ihex_flush_buffer(ihex, line_buffer, w);