diff --git a/.gitignore b/.gitignore index c341a283..ce34ff16 100644 --- a/.gitignore +++ b/.gitignore @@ -78,3 +78,6 @@ m4/lt~obsolete.m4 # CMake /build + +# clangd +.cache/* diff --git a/srec_cat/main.cc b/srec_cat/main.cc index 215afe93..3ab17e57 100644 --- a/srec_cat/main.cc +++ b/srec_cat/main.cc @@ -43,7 +43,7 @@ main(int argc, char **argv) int address_length = 0; std::string header; bool header_set = false; - unsigned long execution_start_address = 0; + uint32_t execution_start_address = 0; bool execution_start_address_set = false; int output_block_size = 0; bool output_block_packing = false; diff --git a/srecord/adler16.cc b/srecord/adler16.cc index ca003570..f6624d4a 100644 --- a/srecord/adler16.cc +++ b/srecord/adler16.cc @@ -18,16 +18,13 @@ #include -unsigned short -srecord::adler16::get() - const +uint16_t srecord::adler16::get() const { - return ((((unsigned short)sum_b) << 8) | sum_a); + return ((((uint16_t)sum_b) << 8) | sum_a); } -void -srecord::adler16::next(unsigned char c) +void srecord::adler16::next(uint8_t c) { // This is not portable to int=16-bit machines sum_a = (sum_a + c) % 251; @@ -35,10 +32,9 @@ srecord::adler16::next(unsigned char c) } -void -srecord::adler16::nextbuf(const void *data, size_t nbytes) +void srecord::adler16::nextbuf(const void *data, size_t nbytes) { - const auto *dp = (const unsigned char *)data; + const auto *dp = (const uint8_t *)data; while (nbytes > 0) { next(*dp); diff --git a/srecord/adler16.h b/srecord/adler16.h index e670fe0a..4ef9eca5 100644 --- a/srecord/adler16.h +++ b/srecord/adler16.h @@ -20,6 +20,7 @@ #define SRECORD_ADLER16_H #include +#include namespace srecord { @@ -35,12 +36,12 @@ class adler16 /** * The get method is used to obtain the running value of the checksum. */ - unsigned short get() const; + uint16_t get() const; /** * The next method is used to advance the state by one byte. */ - void next(unsigned char); + void next(uint8_t); /** * The nextbuf method is used to advance the state by a series of bytes. @@ -52,15 +53,15 @@ class adler16 * The sum_a instance variable is used to remember the sum of bytes * scanned. */ - unsigned char sum_a{1}; + uint8_t sum_a{1}; /** * The sum_b instance variable is used to remember the sum of the * sum of bytes scanned. */ - unsigned char sum_b{0}; + uint8_t sum_b{0}; }; -}; +} // namespace srecord #endif // SRECORD_ADLER16_H diff --git a/srecord/adler32.cc b/srecord/adler32.cc index 137d1537..9e5c9716 100644 --- a/srecord/adler32.cc +++ b/srecord/adler32.cc @@ -18,16 +18,14 @@ #include -unsigned long -srecord::adler32::get() - const +uint32_t srecord::adler32::get() const { - return ((((unsigned long)sum_b) << 16) | sum_a); + return ((((uint32_t)sum_b) << 16) | sum_a); } void -srecord::adler32::next(unsigned char c) +srecord::adler32::next(uint8_t c) { // This is not portable to int=16-bit machines sum_a = (sum_a + c) % 65521; @@ -38,7 +36,7 @@ srecord::adler32::next(unsigned char c) void srecord::adler32::nextbuf(const void *data, size_t nbytes) { - const auto *dp = (const unsigned char *)data; + const auto *dp = (const uint8_t *)(data); while (nbytes > 0) { next(*dp); diff --git a/srecord/adler32.h b/srecord/adler32.h index 62846d60..b472428e 100644 --- a/srecord/adler32.h +++ b/srecord/adler32.h @@ -20,6 +20,7 @@ #define SRECORD_ADLER32_H #include +#include namespace srecord { @@ -38,12 +39,12 @@ class adler32 * The get method is used to obtain the running value of the * checksum. */ - unsigned long get() const; + uint32_t get() const; /** * The next method is used to advance the state by one byte. */ - void next(unsigned char); + void next(uint8_t); /** * The nextbuf method is used to advance the state by a series of bytes. @@ -55,13 +56,13 @@ class adler32 * The sum_a instance variable is used to remember the sum of bytes * scanned. */ - unsigned short sum_a{1}; + uint16_t sum_a{1}; /** * The sum_b instance variable is used to remember the sum of the * sum of bytes scanned. */ - unsigned short sum_b{0}; + uint16_t sum_b{0}; }; }; diff --git a/srecord/arglex.cc b/srecord/arglex.cc index beafcaee..9a2ad1f9 100644 --- a/srecord/arglex.cc +++ b/srecord/arglex.cc @@ -80,7 +80,7 @@ srecord::arglex::read_arguments_file(const char *filename) int sc = getc(fp); if (sc == EOF) break; - unsigned char c = sc; + uint8_t c = sc; // // Ignore white space between words. @@ -144,10 +144,10 @@ srecord::arglex::compare(const char *formal, const char *actual) { for (;;) { - unsigned char ac = *actual++; + uint8_t ac = *actual++; if (isupper(ac)) ac = tolower(ac); - unsigned char fc = *formal++; + uint8_t fc = *formal++; switch (fc) { case 0: diff --git a/srecord/arglex/abbreviate.cc b/srecord/arglex/abbreviate.cc index 4439b493..11441e90 100644 --- a/srecord/arglex/abbreviate.cc +++ b/srecord/arglex/abbreviate.cc @@ -25,7 +25,7 @@ srecord::arglex::abbreviate(const char *s) std::string result; for (;;) { - unsigned char c = *s++; + uint8_t c = *s++; switch (c) { case '\0': diff --git a/srecord/arglex/tool.cc b/srecord/arglex/tool.cc index bf4e7d2e..9ce069e9 100644 --- a/srecord/arglex/tool.cc +++ b/srecord/arglex/tool.cc @@ -270,7 +270,7 @@ srecord::arglex_tool::can_get_number() void -srecord::arglex_tool::get_address(const char *name, unsigned long &address) +srecord::arglex_tool::get_address(const char *name, uint32_t &address) { if (!can_get_number()) { @@ -283,7 +283,7 @@ srecord::arglex_tool::get_address(const char *name, unsigned long &address) void srecord::arglex_tool::get_address_and_nbytes(const char *name, - unsigned long &address, int &nbytes) + uint32_t &address, int &nbytes) { if (!can_get_number()) { @@ -300,7 +300,7 @@ srecord::arglex_tool::get_address_and_nbytes(const char *name, { fatal_error ( - "the %s address (0x%8.8lX) and byte count (%d) may not span the " + "the %s address (0x%8.8X) and byte count (%d) may not span the " "top of memory", name, address, @@ -313,7 +313,7 @@ srecord::arglex_tool::get_address_and_nbytes(const char *name, void srecord::arglex_tool::get_address_nbytes_width(const char *name, - unsigned long &address, int &nbytes, int &width) + uint32_t &address, int &nbytes, int &width) { address = get_number("address"); nbytes = 4; @@ -330,7 +330,7 @@ srecord::arglex_tool::get_address_nbytes_width(const char *name, { fatal_error ( - "the %s address (0x%8.8lX) and byte count (%d) may not span the " + "the %s address (0x%8.8X) and byte count (%d) may not span the " "top of memory", name, address, diff --git a/srecord/arglex/tool.h b/srecord/arglex/tool.h index ff3504e4..7a75a9b5 100644 --- a/srecord/arglex/tool.h +++ b/srecord/arglex/tool.h @@ -244,7 +244,7 @@ class arglex_tool: * The get_number method is used to parse a numeric value from the * command line. */ - unsigned long get_number(const char *caption); + uint32_t get_number(const char *caption); /** * The get_number method is used to parse a numeric value @@ -257,7 +257,7 @@ class arglex_tool: * @param max * The maximum acceptable value (inclusive) */ - unsigned long get_number(const char *caption, long min, long max); + uint32_t get_number(const char *caption, long min, long max); /** * The can_get_number method is used to determine if it is possible @@ -345,7 +345,7 @@ class arglex_tool: * line) a fatal error will be issued and the method call will * not return. */ - void get_address(const char *err_msg_caption, unsigned long &addr); + void get_address(const char *err_msg_caption, uint32_t &addr); /** * The get_address_and_nbytes method is used to parse an address @@ -356,7 +356,7 @@ class arglex_tool: * not return. */ void get_address_and_nbytes(const char *err_msg_caption, - unsigned long &addr, int &nbytes); + uint32_t &addr, int &nbytes); /** * The get_address_nbytes_width method is used to parse an address @@ -367,7 +367,7 @@ class arglex_tool: * not return. */ void get_address_nbytes_width(const char *err_msg_caption, - unsigned long &addr, int &nbytes, int &width); + uint32_t &addr, int &nbytes, int &width); /** * The stdin_used instance variable is used to remember whether diff --git a/srecord/arglex/tool/get_interval.cc b/srecord/arglex/tool/get_interval.cc index 5adb92eb..58a4d660 100644 --- a/srecord/arglex/tool/get_interval.cc +++ b/srecord/arglex/tool/get_interval.cc @@ -74,8 +74,8 @@ srecord::arglex_tool::get_interval_factor(const char *name) ); // NOTREACHED } - unsigned long n1 = get_number("address range minimum"); - unsigned long n2 = 0; + uint32_t n1 = get_number("address range minimum"); + uint32_t n2 = 0; if (can_get_number()) { n2 = get_number("address range maximum"); @@ -84,7 +84,7 @@ srecord::arglex_tool::get_interval_factor(const char *name) { fatal_error ( - "the %s range %lu..%lu is invalid", + "the %s range %u..%u is invalid", name, n1, n2 diff --git a/srecord/arglex/tool/get_number.cc b/srecord/arglex/tool/get_number.cc index 66f9db34..f4475050 100644 --- a/srecord/arglex/tool/get_number.cc +++ b/srecord/arglex/tool/get_number.cc @@ -23,11 +23,11 @@ #include -unsigned long +uint32_t srecord::arglex_tool::get_number(const char *caption) { - unsigned long value = 0; - unsigned long multiple; + uint32_t value = 0; + uint32_t multiple; interval over; switch (token_cur()) @@ -132,7 +132,7 @@ srecord::arglex_tool::get_number(const char *caption) } -unsigned long +uint32_t srecord::arglex_tool::get_number(const char *caption, long minimum, long maximum) { diff --git a/srecord/arglex/tool/input.cc b/srecord/arglex/tool/input.cc index 2bb18a94..41a940a7 100644 --- a/srecord/arglex/tool/input.cc +++ b/srecord/arglex/tool/input.cc @@ -531,7 +531,7 @@ srecord::arglex_tool::get_input() const char *name = token_name(); endian_t end = get_endian_by_token(); token_next(); - unsigned long address; + uint32_t address; get_address(name, address); ifp = input_filter_message_adler16::create @@ -549,7 +549,7 @@ srecord::arglex_tool::get_input() const char *name = token_name(); endian_t end = get_endian_by_token(); token_next(); - unsigned long address; + uint32_t address; get_address(name, address); ifp = input_filter_message_adler32::create @@ -596,7 +596,7 @@ srecord::arglex_tool::get_input() const char *name = token_name(); endian_t end = get_endian_by_token(); token_next(); - unsigned long address; + uint32_t address; int nbytes; int width; get_address_nbytes_width(name, address, nbytes, width); @@ -618,7 +618,7 @@ srecord::arglex_tool::get_input() const char *name = token_name(); endian_t end = get_endian_by_token(); token_next(); - unsigned long address; + uint32_t address; int nbytes; int width; get_address_nbytes_width(name, address, nbytes, width); @@ -640,7 +640,7 @@ srecord::arglex_tool::get_input() const char *name = token_name(); endian_t end = get_endian_by_token(); token_next(); - unsigned long address; + uint32_t address; int nbytes; int width; get_address_nbytes_width(name, address, nbytes, width); @@ -662,7 +662,7 @@ srecord::arglex_tool::get_input() endian_t end = get_endian_by_token(); const char *name = token_name(); token_next(); - unsigned long address; + uint32_t address; get_address(name, address); ifp = input_filter_message_crc16::create(ifp, address, end); @@ -675,7 +675,7 @@ srecord::arglex_tool::get_input() const char *name = token_name(); endian_t end = get_endian_by_token(); token_next(); - unsigned long address; + uint32_t address; get_address(name, address); ifp = input_filter_message_crc32::create(ifp, address, end); } @@ -730,7 +730,7 @@ srecord::arglex_tool::get_input() const char *name = token_name(); endian_t end = get_endian_by_token(); token_next(); - unsigned long address; + uint32_t address; get_address(name, address); ifp = input_filter_message_fletcher16::create @@ -748,7 +748,7 @@ srecord::arglex_tool::get_input() const char *name = token_name(); endian_t end = get_endian_by_token(); token_next(); - unsigned long address; + uint32_t address; get_address(name, address); ifp = input_filter_message_fletcher32::create @@ -765,7 +765,7 @@ srecord::arglex_tool::get_input() // Undocumented, no gcrypt implementation, yet. const char *name = token_name(); token_next(); - unsigned long address = 0; + uint32_t address = 0; get_address(name, address); ifp = input_filter_message_gcrypt::create_haval @@ -781,7 +781,7 @@ srecord::arglex_tool::get_input() const char *name = token_name(); token_next(); std::string algo = get_string(name); - unsigned long address = 0; + uint32_t address = 0; get_address(name, address); bool hmac = false; ifp = @@ -808,7 +808,7 @@ srecord::arglex_tool::get_input() endian_t end = get_endian_by_token(); bool inclusive = get_inclusive_by_token(); token_next(); - unsigned long address; + uint32_t address; int nbytes; int width; get_address_nbytes_width(name, address, nbytes, width); @@ -834,7 +834,7 @@ srecord::arglex_tool::get_input() endian_t end = get_endian_by_token(); bool inclusive = get_inclusive_by_token(); token_next(); - unsigned long address; + uint32_t address; int nbytes; get_address_and_nbytes(name, address, nbytes); ifp = @@ -858,7 +858,7 @@ srecord::arglex_tool::get_input() endian_t end = get_endian_by_token(); bool inclusive = get_inclusive_by_token(); token_next(); - unsigned long address; + uint32_t address; int nbytes; get_address_and_nbytes(name, address, nbytes); ifp = @@ -878,7 +878,7 @@ srecord::arglex_tool::get_input() // Undocumented, no gcrypt implementation, yet. const char *name = token_name(); token_next(); - unsigned long address = 0; + uint32_t address = 0; get_address(name, address); ifp = input_filter_message_gcrypt::create_md2(ifp, address); } @@ -888,7 +888,7 @@ srecord::arglex_tool::get_input() { const char *name = token_name(); token_next(); - unsigned long address = 0; + uint32_t address = 0; get_address(name, address); ifp = input_filter_message_gcrypt::create_md5(ifp, address); } @@ -902,7 +902,7 @@ srecord::arglex_tool::get_input() case token_offset: { token_next(); - unsigned long amount = get_number("--offset"); + uint32_t amount = get_number("--offset"); ifp = input_filter_offset::create(ifp, amount); } break; @@ -927,7 +927,7 @@ srecord::arglex_tool::get_input() { const char *name = token_name(); token_next(); - unsigned long address = 0; + uint32_t address = 0; get_address(name, address); ifp = input_filter_message_gcrypt::create_rmd160 @@ -942,7 +942,7 @@ srecord::arglex_tool::get_input() { const char *name = token_name(); token_next(); - unsigned long address = 0; + uint32_t address = 0; get_address(name, address); ifp = input_filter_message_gcrypt::create_sha1(ifp, address); } @@ -952,7 +952,7 @@ srecord::arglex_tool::get_input() { const char *name = token_name(); token_next(); - unsigned long address = 0; + uint32_t address = 0; get_address(name, address); ifp = input_filter_message_gcrypt::create_sha224 @@ -967,7 +967,7 @@ srecord::arglex_tool::get_input() { const char *name = token_name(); token_next(); - unsigned long address = 0; + uint32_t address = 0; get_address(name, address); ifp = input_filter_message_gcrypt::create_sha256 @@ -982,7 +982,7 @@ srecord::arglex_tool::get_input() { const char *name = token_name(); token_next(); - unsigned long address = 0; + uint32_t address = 0; get_address(name, address); ifp = input_filter_message_gcrypt::create_sha384 @@ -997,7 +997,7 @@ srecord::arglex_tool::get_input() { const char *name = token_name(); token_next(); - unsigned long address = 0; + uint32_t address = 0; get_address(name, address); ifp = input_filter_message_gcrypt::create_sha512 @@ -1046,7 +1046,7 @@ srecord::arglex_tool::get_input() const char *name = token_name(); endian_t endian = get_endian_by_token(); token_next(); - unsigned long address = 0; + uint32_t address = 0; get_address(name, address); ifp = input_filter_message_stm32::create(ifp, address, endian); } @@ -1056,7 +1056,7 @@ srecord::arglex_tool::get_input() { const char *name = token_name(); token_next(); - unsigned long address = 0; + uint32_t address = 0; get_address(name, address); ifp = input_filter_message_gcrypt::create_tiger @@ -1122,7 +1122,7 @@ srecord::arglex_tool::get_input() { const char *name = token_name(); token_next(); - unsigned long address = 0; + uint32_t address = 0; get_address(name, address); ifp = input_filter_message_gcrypt::create_whirlpool diff --git a/srecord/bitrev.cc b/srecord/bitrev.cc index 0539d34b..5bdcf795 100644 --- a/srecord/bitrev.cc +++ b/srecord/bitrev.cc @@ -19,7 +19,7 @@ #include -static unsigned char table[256] = +static uint8_t table[256] = { 0x00, 0x80, 0x40, 0xC0, 0x20, 0xA0, 0x60, 0xE0, 0x10, 0x90, 0x50, 0xD0, 0x30, 0xB0, 0x70, 0xF0, @@ -56,94 +56,94 @@ static unsigned char table[256] = }; -unsigned char -srecord::bitrev8(unsigned char value) +uint8_t +srecord::bitrev8(uint8_t value) { return table[value]; } -unsigned short -srecord::bitrev16(unsigned short value) +uint16_t +srecord::bitrev16(uint16_t value) { // could make this faster with a table, // but is it worth it? - unsigned char hi1(value >> 8); - unsigned char lo1(value); - unsigned short hi2(bitrev8(lo1)); - unsigned char lo2(bitrev8(hi1)); + uint8_t hi1(value >> 8); + uint8_t lo1(value); + uint16_t hi2(bitrev8(lo1)); + uint8_t lo2(bitrev8(hi1)); // hi2 must have same type as return return ((hi2 << 8) | lo2); } -unsigned long -srecord::bitrev24(unsigned long value) +uint32_t +srecord::bitrev24(uint32_t value) { - unsigned char hi1(value >> 16); - unsigned short lo1(value); - unsigned long hi2(bitrev16(lo1)); - unsigned char lo2(bitrev8(hi1)); + uint8_t hi1(value >> 16); + uint16_t lo1(value); + uint32_t hi2(bitrev16(lo1)); + uint8_t lo2(bitrev8(hi1)); // hi2 must have same type as return return ((hi2 << 8) | lo2); } -unsigned long -srecord::bitrev32(unsigned long value) +uint32_t +srecord::bitrev32(uint32_t value) { - unsigned short hi1(value >> 16); - unsigned short lo1(value); - unsigned long hi2(bitrev16(lo1)); - unsigned short lo2(bitrev16(hi1)); + uint16_t hi1(value >> 16); + uint16_t lo1(value); + uint32_t hi2(bitrev16(lo1)); + uint16_t lo2(bitrev16(hi1)); // hi2 must have same type as return return ((hi2 << 16) | lo2); } -unsigned long long -srecord::bitrev40(unsigned long long value) +uint64_t +srecord::bitrev40(uint64_t value) { - unsigned char hi1(value >> 32); - unsigned long lo1(value); - unsigned long long hi2(bitrev32(lo1)); - unsigned char lo2(bitrev8(hi1)); + uint8_t hi1(value >> 32); + uint32_t lo1(value); + uint64_t hi2(bitrev32(lo1)); + uint8_t lo2(bitrev8(hi1)); // hi2 must have same type as return return ((hi2 << 8) | lo2); } -unsigned long long -srecord::bitrev48(unsigned long long value) +uint64_t +srecord::bitrev48(uint64_t value) { - unsigned short hi1(value >> 32); - unsigned long lo1(value); - unsigned long long hi2(bitrev32(lo1)); - unsigned short lo2(bitrev16(hi1)); + uint16_t hi1(value >> 32); + uint32_t lo1(value); + uint64_t hi2(bitrev32(lo1)); + uint16_t lo2(bitrev16(hi1)); // hi2 must have same type as return return ((hi2 << 16) | lo2); } -unsigned long long -srecord::bitrev56(unsigned long long value) +uint64_t +srecord::bitrev56(uint64_t value) { - unsigned long hi1(value >> 32); - unsigned long lo1(value); - unsigned long long hi2(bitrev32(lo1)); - unsigned long lo2(bitrev24(hi1)); + uint32_t hi1(value >> 32); + uint32_t lo1(value); + uint64_t hi2(bitrev32(lo1)); + uint32_t lo2(bitrev24(hi1)); // hi2 must have same type as return return ((hi2 << 24) | lo2); } -unsigned long long -srecord::bitrev64(unsigned long long value) +uint64_t +srecord::bitrev64(uint64_t value) { - unsigned long hi1(value >> 32); - unsigned long lo1(value); - unsigned long long hi2 = bitrev32(lo1); - unsigned long lo2 = bitrev32(hi1); + uint32_t hi1(value >> 32); + uint32_t lo1(value); + uint64_t hi2 = bitrev32(lo1); + uint32_t lo2 = bitrev32(hi1); // hi2 must have same type as return return ((hi2 << 32) | lo2); } diff --git a/srecord/bitrev.h b/srecord/bitrev.h index 9eea9083..4db67810 100644 --- a/srecord/bitrev.h +++ b/srecord/bitrev.h @@ -19,6 +19,8 @@ #ifndef SRECORD_BITREV_H #define SRECORD_BITREV_H +#include + namespace srecord { @@ -29,7 +31,7 @@ namespace srecord * @param value * The value to be reversed. */ -unsigned char bitrev8(unsigned char value); +uint8_t bitrev8(uint8_t value); /** * The bitrev16 function is used to reverse the order of the bits in an @@ -38,7 +40,7 @@ unsigned char bitrev8(unsigned char value); * @param value * The value to be reversed. */ -unsigned short bitrev16(unsigned short value); +uint16_t bitrev16(uint16_t value); /** * The bitrev24 function is used to reverse the order of the bits in an @@ -47,7 +49,7 @@ unsigned short bitrev16(unsigned short value); * @param value * The value to be reversed. */ -unsigned long bitrev24(unsigned long value); +uint32_t bitrev24(uint32_t value); /** * The bitrev32 function is used to reverse the order of the bits in an @@ -56,7 +58,7 @@ unsigned long bitrev24(unsigned long value); * @param value * The value to be reversed. */ -unsigned long bitrev32(unsigned long value); +uint32_t bitrev32(uint32_t value); /** * The bitrev40 function is used to reverse the order of the bits in an @@ -65,7 +67,7 @@ unsigned long bitrev32(unsigned long value); * @param value * The value to be reversed. */ -unsigned long long bitrev40(unsigned long long value); +uint64_t bitrev40(uint64_t value); /** * The bitrev48 function is used to reverse the order of the bits in an @@ -74,7 +76,7 @@ unsigned long long bitrev40(unsigned long long value); * @param value * The value to be reversed. */ -unsigned long long bitrev48(unsigned long long value); +uint64_t bitrev48(uint64_t value); /** * The bitrev56 function is used to reverse the order of the bits in an @@ -83,7 +85,7 @@ unsigned long long bitrev48(unsigned long long value); * @param value * The value to be reversed. */ -unsigned long long bitrev56(unsigned long long value); +uint64_t bitrev56(uint64_t value); /** * The bitrev64 function is used to reverse the order of the bits in an @@ -92,7 +94,7 @@ unsigned long long bitrev56(unsigned long long value); * @param value * The value to be reversed. */ -unsigned long long bitrev64(unsigned long long value); +uint64_t bitrev64(uint64_t value); }; diff --git a/srecord/crc16.cc b/srecord/crc16.cc index 4961f77a..a7aef9f8 100644 --- a/srecord/crc16.cc +++ b/srecord/crc16.cc @@ -61,9 +61,9 @@ // updcrc function: // updcrc(0, updcrc(0, 0xFFFF)) // -static unsigned short const ccitt_seed = 0xFFFF; -static unsigned short const broken_seed = 0x84CF; -static unsigned short const xmodem_seed = 0; +static uint16_t const ccitt_seed = 0xFFFF; +static uint16_t const broken_seed = 0x84CF; +static uint16_t const xmodem_seed = 0; void @@ -75,7 +75,7 @@ srecord::crc16::calculate_table() { for (unsigned b = 0; b < 256; ++b) { - unsigned short v = b << 8; + uint16_t v = b << 8; for (unsigned j = 0; j < 8; ++j) v = (v & 0x8000) ? ((v << 1) ^ polynomial) : (v << 1); table[b] = v; @@ -86,7 +86,7 @@ srecord::crc16::calculate_table() polynomial = bitrev16(polynomial); for (unsigned b = 0; b < 256; ++b) { - unsigned short v = b; + uint16_t v = b; for (unsigned j = 0; j < 8; ++j) v = (v & 1) ? ((v >> 1) ^ polynomial) : (v >> 1); table[b] = v; @@ -116,7 +116,7 @@ state_from_seed_mode(srecord::crc16::seed_mode_t seed_mode) srecord::crc16::crc16( seed_mode_t seed_mode, bool a_augment, - unsigned short a_polynomial, + uint16_t a_polynomial, bit_direction_t a_bitdir ) : state(state_from_seed_mode(seed_mode)), @@ -176,8 +176,8 @@ srecord::crc16::operator=(const crc16 &rhs) // 'A Straightforward CRC Implementation', for an explanation. // -inline unsigned short -srecord::crc16::updcrc(unsigned char c, unsigned short state) +inline uint16_t +srecord::crc16::updcrc(uint8_t c, uint16_t state) const { if (bitdir == bit_direction_most_to_least) @@ -223,8 +223,8 @@ srecord::crc16::updcrc(unsigned char c, unsigned short state) // 'A Table-Driven Implementation', for an explanation. // -inline unsigned short -srecord::crc16::updcrc(unsigned char c, unsigned short state) +inline uint16_t +srecord::crc16::updcrc(uint8_t c, uint16_t state) const { if (bitdir == bit_direction_least_to_most) @@ -251,8 +251,8 @@ srecord::crc16::updcrc(unsigned char c, unsigned short state) // 'A Slightly Mangled Table-Driven Implementation', for an explanation. // -inline unsigned short -srecord::crc16::updcrc(unsigned char c, unsigned short state) +inline uint16_t +srecord::crc16::updcrc(uint8_t c, uint16_t state) const { if (bitdir == bit_direction_least_to_most) @@ -265,7 +265,7 @@ srecord::crc16::updcrc(unsigned char c, unsigned short state) void -srecord::crc16::next(unsigned char ch) +srecord::crc16::next(uint8_t ch) { state = updcrc(ch, state); } @@ -274,7 +274,7 @@ srecord::crc16::next(unsigned char ch) void srecord::crc16::nextbuf(const void *data, size_t nbytes) { - auto *dp = (unsigned char *)data; + auto *dp = (uint8_t *)data; while (nbytes > 0) { state = updcrc(*dp++, state); @@ -283,7 +283,7 @@ srecord::crc16::nextbuf(const void *data, size_t nbytes) } -unsigned short +uint16_t srecord::crc16::get() const { @@ -323,7 +323,7 @@ srecord::crc16::print_table() else printf("%04X", bitrev16(polynomial)); printf("\n */\n"); - printf("const unsigned short table[256] =\n{\n"); + printf("const uint16_t table[256] =\n{\n"); for (size_t j = 0; j < 256; ++j) { if ((j & 7) == 0) diff --git a/srecord/crc16.h b/srecord/crc16.h index eb1e98a6..7e9f4176 100644 --- a/srecord/crc16.h +++ b/srecord/crc16.h @@ -24,6 +24,7 @@ #define SRECORD_CRC16_H #include +#include namespace srecord { @@ -112,7 +113,7 @@ class crc16 * the algorithm. */ crc16(seed_mode_t seed_mode = seed_mode_ccitt, bool augment = true, - unsigned short polynomial = polynomial_ccitt, + uint16_t polynomial = polynomial_ccitt, bit_direction_t bitdir = bit_direction_most_to_least); /** @@ -129,12 +130,12 @@ class crc16 * The get method is used to obtain the running value of the cyclic * redundancy check. */ - unsigned short get() const; + uint16_t get() const; /** * The next method is used to advance the state by one byte. */ - void next(unsigned char); + void next(uint8_t); /** * The nextbuf method is used to advance the state by a series of bytes. @@ -152,7 +153,7 @@ class crc16 * The state instance variable is used to remember the running * value of the 16-bit cyclic redundancy check. */ - unsigned short state; + uint16_t state; /** * The augment instance variable is used to remember whether or @@ -166,7 +167,7 @@ class crc16 * polynomial being calculated with. Note that if the bitdir is * low-to-high then the bits in the polynomial will be reversed. */ - unsigned short polynomial; + uint16_t polynomial; /** * The bitdir instance variable is sued to remember the direction @@ -180,7 +181,7 @@ class crc16 * to improve efficiency. It is filled in the the #calculate_table * method, called from the constructor. */ - unsigned short table[256]{}; + uint16_t table[256]{}; /** * The calculate_table method is called by the constructor to fill @@ -192,7 +193,7 @@ class crc16 * The updcrc method is to add another byte of data to the running * CRC state. It is called by the #next and next_buf methods. */ - inline unsigned short updcrc(unsigned char c, unsigned short state) const; + inline uint16_t updcrc(uint8_t c, uint16_t state) const; }; }; diff --git a/srecord/crc32.cc b/srecord/crc32.cc index 985e4dcd..8385e5ae 100644 --- a/srecord/crc32.cc +++ b/srecord/crc32.cc @@ -41,8 +41,8 @@ #include -static unsigned long ccitt_seed = 0xFFFFFFFF; -static unsigned long xmodem_seed = 0; +static uint32_t ccitt_seed = 0xFFFFFFFF; +static uint32_t xmodem_seed = 0; // @@ -79,7 +79,7 @@ static unsigned long xmodem_seed = 0; // logic; the shift must be unsigned (bring in zeroes). // -static unsigned long table[256]; +static uint32_t table[256]; static void @@ -87,7 +87,7 @@ calculate_table() { for (unsigned b = 0; b < 256; ++b) { - unsigned long v = b; + uint32_t v = b; int i = 8; for (; --i >= 0; ) v = (v & 1) ? ((v >> 1) ^ POLYNOMIAL) : (v >> 1); @@ -96,7 +96,7 @@ calculate_table() } -static unsigned long +static uint32_t initial_state_from_seed_mode(srecord::crc32::seed_mode_t seed_mode) { switch (seed_mode) @@ -129,8 +129,8 @@ srecord::crc32::operator=(const crc32 &arg) return *this; } -static inline unsigned long -UPDC32(unsigned char octet, unsigned long crc) +static inline uint32_t +UPDC32(uint8_t octet, uint32_t crc) { // The original code had this as a #define return table[(crc ^ octet) & 0xFF] ^ (crc >> 8); @@ -138,7 +138,7 @@ UPDC32(unsigned char octet, unsigned long crc) void -srecord::crc32::next(unsigned char x) +srecord::crc32::next(uint8_t x) { state = UPDC32(x, state); } @@ -147,7 +147,7 @@ srecord::crc32::next(unsigned char x) void srecord::crc32::nextbuf(const void *data, size_t nbytes) { - const auto *dp = (const unsigned char *)data; + const auto *dp = (const uint8_t *)data; while (nbytes > 0) { state = UPDC32(*dp, state); @@ -157,7 +157,7 @@ srecord::crc32::nextbuf(const void *data, size_t nbytes) } -unsigned long +uint32_t srecord::crc32::get() const { @@ -176,7 +176,7 @@ srecord::crc32::get() // To simulate this (or something very much like it) try // srecord::cat -lecrc32 -lecrc32 // - unsigned long temp = state; + uint32_t temp = state; temp = UPDC32( ~state & 0xFF, temp); temp = UPDC32((~state >> 8) & 0xFF, temp); temp = UPDC32((~state >> 16) & 0xFF, temp); diff --git a/srecord/crc32.h b/srecord/crc32.h index 8e955698..4fa32981 100644 --- a/srecord/crc32.h +++ b/srecord/crc32.h @@ -21,6 +21,7 @@ #define SRECORD_CRC32_H #include +#include namespace srecord { @@ -62,12 +63,12 @@ class crc32 * The get method is used to obtain the running value of the cyclic * redundancy check. */ - unsigned long get() const; + uint32_t get() const; /** * The next method is used to advance the state by one byte. */ - void next(unsigned char); + void next(uint8_t); /** * The nextbuf method is used to advance the state by a series of bytes. @@ -79,7 +80,7 @@ class crc32 * The state instance variable is used to remember the running * value of the 32-bit cyclic redundancy check. */ - unsigned long state; + uint32_t state; }; }; diff --git a/srecord/endian.h b/srecord/endian.h index e1dc5644..2acdea75 100644 --- a/srecord/endian.h +++ b/srecord/endian.h @@ -20,6 +20,8 @@ #ifndef SRECORD_ENDIAN_H #define SRECORD_ENDIAN_H +#include + namespace srecord { @@ -42,32 +44,32 @@ const char *endian_to_string(endian_t x); /** * The decode_word_be function is used to decode a big-endian 2-byte - * data buffer into an unsigned short value. + * data buffer into an uint16_t value. * * @param data * The data to be decoded */ -unsigned short decode_word_be(const unsigned char *data); +uint16_t decode_word_be(const uint8_t *data); /** * The decode_word_le function is used to decode a little-endian 2-byte - * data buffer into an unsigned short value. + * data buffer into an uint16_t value. * * @param data * The data to be decoded */ -unsigned short decode_word_le(const unsigned char *data); +uint16_t decode_word_le(const uint8_t *data); /** * The decode_word_le function is used to decode a little-endian 2-byte - * data buffer into an unsigned short value. + * data buffer into an uint16_t value. * * @param data * The data to be decoded * @param order * The order of the bytes to be decoded. */ -unsigned short endian_decode_word(const unsigned char *data, endian_t order); +uint16_t endian_decode_word(const uint8_t *data, endian_t order); }; diff --git a/srecord/endian/decode_word.cc b/srecord/endian/decode_word.cc index 14884921..6629d683 100644 --- a/srecord/endian/decode_word.cc +++ b/srecord/endian/decode_word.cc @@ -19,22 +19,22 @@ #include -unsigned short -srecord::decode_word_le(const unsigned char *data) +uint16_t +srecord::decode_word_le(const uint8_t *data) { return (data[0] | (data[1] << 8)); } -unsigned short -srecord::decode_word_be(const unsigned char *data) +uint16_t +srecord::decode_word_be(const uint8_t *data) { return ((data[0] << 8) | data[1]); } -unsigned short -srecord::endian_decode_word(const unsigned char *data, endian_t order) +uint16_t +srecord::endian_decode_word(const uint8_t *data, endian_t order) { return ( diff --git a/srecord/fletcher16.cc b/srecord/fletcher16.cc index f8cd3d7a..ec6e61bb 100644 --- a/srecord/fletcher16.cc +++ b/srecord/fletcher16.cc @@ -27,8 +27,8 @@ // srecord::fletcher16::fletcher16( - unsigned char a_sum1, - unsigned char a_sum2, + uint8_t a_sum1, + uint8_t a_sum2, int a_answer, endian_t a_end ) : @@ -52,7 +52,7 @@ srecord::fletcher16::fletcher16( } void -srecord::fletcher16::next(unsigned char ch) +srecord::fletcher16::next(uint8_t ch) { // reduction step to reduce sums to 8 bits sum1 += ch; @@ -88,7 +88,7 @@ srecord::fletcher16::nextbuf(const void *vdata, size_t nbytes) // overflow in 16 bits. Any smaller value is also permissible; 16 // may be convenient in many cases. // - const auto *data = (const unsigned char *)vdata; + const auto *data = (const uint8_t *)vdata; size_t len = nbytes; while (len) { @@ -111,7 +111,7 @@ srecord::fletcher16::nextbuf(const void *vdata, size_t nbytes) } -unsigned short +uint16_t srecord::fletcher16::get() const { @@ -129,8 +129,8 @@ srecord::fletcher16::get() // bytes of eeprom. (Note: 0xFF in final byte (f1 or f2) is // equivalent to 0x00 due to modulo 255 arithmetic.) // - unsigned char f2; - unsigned char f1; + uint8_t f2; + uint8_t f1; if (end == endian_big) { f1 = answer >> 8; @@ -144,10 +144,10 @@ srecord::fletcher16::get() #if 1 // The following code assumes sum1a and sum2a are 16-bits, or - // more. If you make them char or unsigned char, you will get + // more. If you make them char or uint8_t, you will get // the wrong answer. - unsigned short sum1a = sum1; - unsigned short sum2a = sum2; + uint16_t sum1a = sum1; + uint16_t sum2a = sum2; int tmp = int(f2) - int(f1) - int(sum2a) - int(sum1a); tmp = (tmp & 0xff) + (tmp >> 8); @@ -158,18 +158,18 @@ srecord::fletcher16::get() return (((sum1a & 0xFF) << 8) | (sum2a & 0xFF)); #else // exhaustive search - for (unsigned short c1 = 0; c1 < 256; ++c1) + for (uint16_t c1 = 0; c1 < 256; ++c1) { - unsigned short sum1a = sum1 + c1; - unsigned short sum2a = sum2 + sum1a; + uint16_t sum1a = sum1 + c1; + uint16_t sum2a = sum2 + sum1a; sum1a = (sum1a & 0xFF) + (sum1a >> 8); sum2a = (sum2a & 0xFF) + (sum2a >> 8); - for (unsigned short c2 = 0; c2 < 256; ++c2) + for (uint16_t c2 = 0; c2 < 256; ++c2) { - unsigned short sum1b = sum1a + c2; - unsigned short sum2b = sum2a + sum1b; + uint16_t sum1b = sum1a + c2; + uint16_t sum2b = sum2a + sum1b; sum1b = (sum1b & 0xFF) + (sum1b >> 8); sum2b = (sum2b & 0xFF) + (sum2b >> 8); diff --git a/srecord/fletcher16.h b/srecord/fletcher16.h index d35c87c6..66712f85 100644 --- a/srecord/fletcher16.h +++ b/srecord/fletcher16.h @@ -22,6 +22,7 @@ #include #include +#include namespace srecord { @@ -75,19 +76,19 @@ class fletcher16 * The endian-ness of the checksum. This is needed to * manipulate the answer. Ignored if @p answer is ignored. */ - fletcher16(unsigned char sum1 = 0, unsigned char sum2 = 0, + fletcher16(uint8_t sum1 = 0, uint8_t sum2 = 0, int answer = -1, endian_t end = endian_little); /** * The get method is used to obtain the running value of the cyclic * redundancy check. */ - unsigned short get() const; + uint16_t get() const; /** * The next method is used to advance the state by one byte. */ - void next(unsigned char); + void next(uint8_t); /** * The nextbuf method is used to advance the state by a series of bytes. @@ -106,7 +107,7 @@ class fletcher16 * an 8-bit value for convenience, see #nextbuf implementation for * details. */ - unsigned short sum1; + uint16_t sum1; /** * The sum2 instance variable is used to remember the running @@ -114,7 +115,7 @@ class fletcher16 * value rather than an 8-bit value for convenience, see #nextbuf * implementation for details. */ - unsigned short sum2; + uint16_t sum2; /** * The answer instance variable is used to remember the desired diff --git a/srecord/fletcher32.cc b/srecord/fletcher32.cc index 8c493c4e..0ba4524c 100644 --- a/srecord/fletcher32.cc +++ b/srecord/fletcher32.cc @@ -32,7 +32,7 @@ srecord::fletcher32::operator=(const fletcher32 &rhs) void -srecord::fletcher32::next(unsigned char x) +srecord::fletcher32::next(uint8_t x) { sum1 += x; sum2 += sum1; @@ -68,7 +68,7 @@ srecord::fletcher32::nextbuf(const void *vdata, size_t nbytes) // overflow. Any smaller value is also permissible; 256 may be // convenient in many cases. // - const auto *data = (const unsigned char *)vdata; + const auto *data = (const uint8_t *)vdata; size_t len = nbytes; while (len) { @@ -91,7 +91,7 @@ srecord::fletcher32::nextbuf(const void *vdata, size_t nbytes) } -unsigned long +uint32_t srecord::fletcher32::get() const { diff --git a/srecord/fletcher32.h b/srecord/fletcher32.h index dad1f472..e0717135 100644 --- a/srecord/fletcher32.h +++ b/srecord/fletcher32.h @@ -20,6 +20,7 @@ #define SRECORD_FLETCHER32_H #include +#include namespace srecord { @@ -80,12 +81,12 @@ class fletcher32 * The get method is used to obtain the running value of the cyclic * redundancy check. */ - unsigned long get() const; + uint32_t get() const; /** * The next method is used to advance the state by one byte. */ - void next(unsigned char); + void next(uint8_t); /** * The nextbuf method is used to advance the state by a series of bytes. @@ -96,13 +97,13 @@ class fletcher32 /** * The sum1 instance variable is used to remember the sum of the bytes. */ - unsigned long sum1{0xFFFF}; + uint32_t sum1{0xFFFF}; /** * The sum2 instance variable is used to remember the sum of the * sum of the bytes. */ - unsigned long sum2{0xFFFF}; + uint32_t sum2{0xFFFF}; }; }; diff --git a/srecord/input/file.cc b/srecord/input/file.cc index 315f9f2d..40880c6b 100644 --- a/srecord/input/file.cc +++ b/srecord/input/file.cc @@ -243,44 +243,44 @@ srecord::input_file::get_word_le() } -unsigned long +uint32_t srecord::input_file::get_3bytes_be() { - unsigned long b1 = get_byte(); - unsigned long b2 = get_byte(); - unsigned long b3 = get_byte(); + uint32_t b1 = get_byte(); + uint32_t b2 = get_byte(); + uint32_t b3 = get_byte(); return ((((b1 << 8) | b2) << 8) | b3); } -unsigned long +uint32_t srecord::input_file::get_3bytes_le() { - unsigned long b1 = get_byte(); - unsigned long b2 = get_byte(); - unsigned long b3 = get_byte(); + uint32_t b1 = get_byte(); + uint32_t b2 = get_byte(); + uint32_t b3 = get_byte(); return ((((b3 << 8) | b2) << 8) | b1); } -unsigned long +uint32_t srecord::input_file::get_4bytes_be() { - unsigned long b1 = get_byte(); - unsigned long b2 = get_byte(); - unsigned long b3 = get_byte(); - unsigned long b4 = get_byte(); + uint32_t b1 = get_byte(); + uint32_t b2 = get_byte(); + uint32_t b3 = get_byte(); + uint32_t b4 = get_byte(); return ((((((b1 << 8) | b2) << 8) | b3) << 8) | b4); } -unsigned long +uint32_t srecord::input_file::get_4bytes_le() { - unsigned long b1 = get_byte(); - unsigned long b2 = get_byte(); - unsigned long b3 = get_byte(); - unsigned long b4 = get_byte(); + uint32_t b1 = get_byte(); + uint32_t b2 = get_byte(); + uint32_t b3 = get_byte(); + uint32_t b4 = get_byte(); return ((((((b4 << 8) | b3) << 8) | b2) << 8) | b1); } @@ -309,7 +309,7 @@ srecord::input_file::checksum_reset() void -srecord::input_file::checksum_add(unsigned char n) +srecord::input_file::checksum_add(uint8_t n) { checksum += n; } diff --git a/srecord/input/file.h b/srecord/input/file.h index 0fe32ff1..5cbb629b 100644 --- a/srecord/input/file.h +++ b/srecord/input/file.h @@ -172,7 +172,7 @@ class input_file: * and the three byte values are assembles big-endian (most * significant byte first). */ - unsigned long get_3bytes_be(); + uint32_t get_3bytes_be(); /** * The get_3bytes_le method is used to fetch a 24-bit value from @@ -180,7 +180,7 @@ class input_file: * three byte values are assembled little-endian (least significant * byte first). */ - unsigned long get_3bytes_le(); + uint32_t get_3bytes_le(); /** * The get_4bytes_be method is used to fetch a 32-bit value from @@ -188,7 +188,7 @@ class input_file: * and the four byte values are assembled big-endian (most * significant byte first). */ - unsigned long get_4bytes_be(); + uint32_t get_4bytes_be(); /** * The get_4bytes_le method is used to fetch a 32-bit value from @@ -196,7 +196,7 @@ class input_file: * four byte values are assembled little-endian (least significant * byte first). */ - unsigned long get_4bytes_le(); + uint32_t get_4bytes_le(); /** * The checksum_get method is used to get the current value of @@ -218,7 +218,7 @@ class input_file: * The checksum_add method is used to add another 8-bit value * to the running checksum. */ - virtual void checksum_add(unsigned char n); + virtual void checksum_add(uint8_t n); /** * The checksum_rest method is used to set the running checksum diff --git a/srecord/input/file/aomf.cc b/srecord/input/file/aomf.cc index b7701ee4..08675f28 100644 --- a/srecord/input/file/aomf.cc +++ b/srecord/input/file/aomf.cc @@ -163,7 +163,7 @@ srecord::input_file_aomf::slurp() delete [] current_buffer; while (current_maximum < length) current_maximum = current_maximum * 2 + 64; - current_buffer = new unsigned char [current_maximum]; + current_buffer = new uint8_t [current_maximum]; } current_length = length; for (size_t j = 0; j < length; ++j) @@ -180,7 +180,7 @@ srecord::input_file_aomf::read(srecord::record &record) { for (;;) { - unsigned char c; + uint8_t c; switch (state) { case expecting_header: @@ -246,12 +246,12 @@ srecord::input_file_aomf::read(srecord::record &record) current_address = ( // strictly speaking, this byte should be ignored - ((unsigned long)current_buffer[0] << 16) + ((uint32_t)current_buffer[0] << 16) | // length is little-endian - ((unsigned long)current_buffer[2] << 8) + ((uint32_t)current_buffer[2] << 8) | - ((unsigned long)current_buffer[1]) + ((uint32_t)current_buffer[1]) ); current_pos = 3; break; diff --git a/srecord/input/file/aomf.h b/srecord/input/file/aomf.h index fae9ce60..6b41eb6f 100644 --- a/srecord/input/file/aomf.h +++ b/srecord/input/file/aomf.h @@ -84,7 +84,7 @@ class input_file_aomf: * The current_buffer instance variable is used to remember the * base of an array which buffers the current input record. */ - unsigned char *current_buffer{nullptr}; + uint8_t *current_buffer{nullptr}; /** * The current_length instance variable is used to remember @@ -112,7 +112,7 @@ class input_file_aomf: * we return a partial block, so that we always return the * correct load address. */ - unsigned long current_address{0}; + uint32_t current_address{0}; enum state_t { diff --git a/srecord/input/file/ascii_hex.cc b/srecord/input/file/ascii_hex.cc index b0a74e31..c55509cd 100644 --- a/srecord/input/file/ascii_hex.cc +++ b/srecord/input/file/ascii_hex.cc @@ -75,10 +75,10 @@ srecord::input_file_ascii_hex::read_inner(record &result) } if (isxdigit(c)) { - unsigned char c = get_byte(); + uint8_t c = get_byte(); result = record(record::type_data, address, &c, 1); int sep = get_char(); - if (sep >= 0 && !isspace((unsigned char)sep)) + if (sep >= 0 && !isspace((uint8_t)sep)) fatal_error("not execution character"); ++address; switch (peek_char()) @@ -113,7 +113,7 @@ srecord::input_file_ascii_hex::read_inner(record &result) case '$': int command = get_char(); - unsigned long value = 0; + uint32_t value = 0; for (;;) { value = (value << 4) + get_nibble(); @@ -134,8 +134,8 @@ srecord::input_file_ascii_hex::read_inner(record &result) case 'S': if (use_checksums()) { - unsigned short chk1 = checksum_get16(); - unsigned short chk2 = value & 0xFFFF; + uint16_t chk1 = checksum_get16(); + uint16_t chk2 = value & 0xFFFF; if (chk1 != chk2) { fatal_error diff --git a/srecord/input/file/ascii_hex.h b/srecord/input/file/ascii_hex.h index ce0e40e1..4335f2d6 100644 --- a/srecord/input/file/ascii_hex.h +++ b/srecord/input/file/ascii_hex.h @@ -88,7 +88,7 @@ class input_file_ascii_hex: * The address instance variable is used to remember where we are * up to in the input file, so it may be associated with data bytes. */ - unsigned long address{0}; + uint32_t address{0}; /** * The state instance variable is used to remember what state the diff --git a/srecord/input/file/atmel_generic.cc b/srecord/input/file/atmel_generic.cc index 9a695d66..e925063e 100644 --- a/srecord/input/file/atmel_generic.cc +++ b/srecord/input/file/atmel_generic.cc @@ -55,7 +55,7 @@ srecord::input_file_atmel_generic::read_inner(srecord::record &record) int address = get_3bytes_be(); if (get_char() != ':') fatal_error("colon expected"); - unsigned char data[2]; + uint8_t data[2]; if (end == endian_big) { data[1] = get_byte(); diff --git a/srecord/input/file/binary.cc b/srecord/input/file/binary.cc index b4705f1a..d9322899 100644 --- a/srecord/input/file/binary.cc +++ b/srecord/input/file/binary.cc @@ -55,7 +55,7 @@ srecord::input_file_binary::read(srecord::record &record) if (c < 0) return false; int length = 0; - unsigned char data[srecord::record::max_data_length]; + uint8_t data[srecord::record::max_data_length]; for (;;) { data[length++] = c; diff --git a/srecord/input/file/binary.h b/srecord/input/file/binary.h index 60029fb3..bd31dd53 100644 --- a/srecord/input/file/binary.h +++ b/srecord/input/file/binary.h @@ -70,7 +70,7 @@ class input_file_binary: * The address instance variable is used to remember where we are * up to in the file. */ - unsigned long address{0}; + uint32_t address{0}; // See base class for documentation. bool is_binary() const override; diff --git a/srecord/input/file/brecord.cc b/srecord/input/file/brecord.cc index d118ad73..bdbd137b 100644 --- a/srecord/input/file/brecord.cc +++ b/srecord/input/file/brecord.cc @@ -41,12 +41,12 @@ srecord::input_file_brecord::read_inner(record &result) if (peek_char() < 0) return false; - unsigned long address = get_4bytes_be(); - unsigned char length = get_byte(); + uint32_t address = get_4bytes_be(); + uint8_t length = get_byte(); if (length & 0x20) fatal_error("read mode not supported"); length &= 0x1F; - unsigned char data[32]; + uint8_t data[32]; for (unsigned j = 0; j < length; ++j) data[j] = get_byte(); if (get_char() != '\n') diff --git a/srecord/input/file/cosmac.cc b/srecord/input/file/cosmac.cc index 31b9cd95..bfbdd3ca 100644 --- a/srecord/input/file/cosmac.cc +++ b/srecord/input/file/cosmac.cc @@ -121,7 +121,7 @@ srecord::input_file_cosmac::read(record &result) continue; } get_char_undo(c); - unsigned char data = get_byte(); + uint8_t data = get_byte(); result = record(record::type_data, address, &data, 1); ++address; seen_some_input = true; diff --git a/srecord/input/file/cosmac.h b/srecord/input/file/cosmac.h index 3f47c9ba..2abef235 100644 --- a/srecord/input/file/cosmac.h +++ b/srecord/input/file/cosmac.h @@ -83,7 +83,7 @@ class input_file_cosmac: * The address instance variable is used to remember what address * we are up to in the input. */ - unsigned long address{0}; + uint32_t address{0}; /** * The seen_some_input instance variable is used to remember whether diff --git a/srecord/input/file/dec_binary.cc b/srecord/input/file/dec_binary.cc index 36992167..c8c7fbfb 100644 --- a/srecord/input/file/dec_binary.cc +++ b/srecord/input/file/dec_binary.cc @@ -121,7 +121,7 @@ srecord::input_file_dec_binary::read(srecord::record &record) // // Read as many bytes as possible into the buffer. // - unsigned char buffer[srecord::record::max_data_length]; + uint8_t buffer[srecord::record::max_data_length]; int nbytes = srecord::record::max_data_length; if (current_pos + nbytes > current_length) nbytes = current_length - current_pos; diff --git a/srecord/input/file/dec_binary.h b/srecord/input/file/dec_binary.h index 7976a9d1..b97a96dc 100644 --- a/srecord/input/file/dec_binary.h +++ b/srecord/input/file/dec_binary.h @@ -92,14 +92,14 @@ class input_file_dec_binary: * because DEC Binary records can be significantly longer than * other formats. */ - unsigned long current_pos{0}; + uint32_t current_pos{0}; /** * The current_length instance variable is used to remember * the length of the current record. It is zero if there is no * "current" record. */ - unsigned long current_length{0}; + uint32_t current_length{0}; /** * The current_address instance variable is used to track the @@ -107,7 +107,7 @@ class input_file_dec_binary: * we return a partial block, so that we always return the * correct load address. */ - unsigned long current_address{0}; + uint32_t current_address{0}; public: /** diff --git a/srecord/input/file/emon52.cc b/srecord/input/file/emon52.cc index afc4067c..2c148ecd 100644 --- a/srecord/input/file/emon52.cc +++ b/srecord/input/file/emon52.cc @@ -65,11 +65,11 @@ srecord::input_file_emon52::read(srecord::record &record) if (length == 0) fatal_error("data length of zero is not valid"); skip_white_space(); - unsigned long address = get_word_be(); + uint32_t address = get_word_be(); if (get_char() != ':') fatal_error("colon expected"); checksum_reset(); - unsigned char buffer[256]; + uint8_t buffer[256]; for (int j = 0; j < length; ++j) { skip_white_space(); diff --git a/srecord/input/file/fairchild.cc b/srecord/input/file/fairchild.cc index 9c08fe50..4fae863b 100644 --- a/srecord/input/file/fairchild.cc +++ b/srecord/input/file/fairchild.cc @@ -100,7 +100,7 @@ srecord::input_file_fairchild::read(record &result) case 'X': { checksum_reset(); - unsigned char data[8]; + uint8_t data[8]; for (int j = 0; j < 8; ++j) data[j] = get_byte(); result = record(record::type_data, address, data, 8); diff --git a/srecord/input/file/fairchild.h b/srecord/input/file/fairchild.h index 0d775d22..625474ea 100644 --- a/srecord/input/file/fairchild.h +++ b/srecord/input/file/fairchild.h @@ -90,7 +90,7 @@ class input_file_fairchild: * The address instance variable is used to member the address at * the current point in the input file. */ - unsigned long address{0}; + uint32_t address{0}; /** * The file_contains_data instance variable is used to member diff --git a/srecord/input/file/fastload.cc b/srecord/input/file/fastload.cc index fbc0d568..6f967396 100644 --- a/srecord/input/file/fastload.cc +++ b/srecord/input/file/fastload.cc @@ -114,10 +114,10 @@ srecord::input_file_fastload::get_digit() } -unsigned long +uint32_t srecord::input_file_fastload::get_number(int min_digits, int max_digits) { - unsigned long result = 0; + uint32_t result = 0; for (int ndigits = 0; ndigits < max_digits; ++ndigits) { int c = get_digit(); @@ -158,12 +158,12 @@ srecord::input_file_fastload::expect_white_space() bool srecord::input_file_fastload::read_inner(srecord::record &record) { - unsigned long n; - unsigned char data[srecord::record::max_data_length]; - unsigned long data_address = address; + uint32_t n; + uint8_t data[srecord::record::max_data_length]; + uint32_t data_address = address; srecord::record::type_t type; int data_length = 0; - unsigned char the_byte; + uint8_t the_byte; for (;;) { switch (peek_char()) @@ -255,7 +255,7 @@ srecord::input_file_fastload::read_inner(srecord::record &record) n = get_number(1, 6); expect_white_space(); if (n >= srecord::record::max_data_length) - fatal_error("clearing too many bytes (%lu)", n); + fatal_error("clearing too many bytes (%u)", n); memset(data, 0, n); type = srecord::record::type_data; record = srecord::record(type, address, data, n); diff --git a/srecord/input/file/fastload.h b/srecord/input/file/fastload.h index 0e50e053..b9c2d71f 100644 --- a/srecord/input/file/fastload.h +++ b/srecord/input/file/fastload.h @@ -83,7 +83,7 @@ class input_file_fastload: * The ordering is big-endian, but like ordinary decimal numbers. * Four digits is 24 bits. */ - unsigned long get_number(int min_digits, int max_digits); + uint32_t get_number(int min_digits, int max_digits); /** * The seen_some_input instance variable is used to @@ -96,7 +96,7 @@ class input_file_fastload: * current address within the file. It is set by the /A command, * and advanced by the data, /B and /Z commands. */ - unsigned long address{0}; + uint32_t address{0}; /** * The expect_white_space method is used to ensure that while diff --git a/srecord/input/file/formatted_binary.cc b/srecord/input/file/formatted_binary.cc index 8bd711b0..09b25403 100644 --- a/srecord/input/file/formatted_binary.cc +++ b/srecord/input/file/formatted_binary.cc @@ -142,7 +142,7 @@ srecord::input_file_formatted_binary::read(record &result) long datalen = upper_bound - address; if (datalen > record::max_data_length) datalen = record::max_data_length; - unsigned char data[record::max_data_length]; + uint8_t data[record::max_data_length]; for (long j = 0; j < datalen; ++j) { int c = get_char(); diff --git a/srecord/input/file/formatted_binary.h b/srecord/input/file/formatted_binary.h index 76e5e923..68027af6 100644 --- a/srecord/input/file/formatted_binary.h +++ b/srecord/input/file/formatted_binary.h @@ -79,13 +79,13 @@ class input_file_formatted_binary: * The upper_bound instance variable is used to remember how long * the header said the file was going to be. */ - unsigned long upper_bound; + uint32_t upper_bound; /** * The address instance variable is used to remember where we are * up to in extracting the data from the file. */ - unsigned long address; + uint32_t address; /** * The trailer_seen instance variable is used to remember whether @@ -97,7 +97,7 @@ class input_file_formatted_binary: * The check_sum instance variable is used to remember the simple * sum of the data bytes in the file. */ - unsigned short check_sum; + uint16_t check_sum; public: /** diff --git a/srecord/input/file/four_packed_code.cc b/srecord/input/file/four_packed_code.cc index b4d3cff3..887dc84e 100644 --- a/srecord/input/file/four_packed_code.cc +++ b/srecord/input/file/four_packed_code.cc @@ -144,7 +144,7 @@ srecord::input_file_four_packed_code::get_byte() get_byte_value = (((get_digit() * 85 + get_digit()) * 85 + get_digit()) * 85 + get_digit()) * 85 + get_digit(); } - unsigned char c = get_byte_value >> ((3 - get_byte_pos++) * 8); + uint8_t c = get_byte_value >> ((3 - get_byte_pos++) * 8); checksum_add(c); return c; } @@ -203,7 +203,7 @@ srecord::input_file_four_packed_code::read_inner(srecord::record &record) break; } - unsigned long address = get_4bytes_be(); + uint32_t address = get_4bytes_be(); switch (format_code) { case 0: @@ -223,7 +223,7 @@ srecord::input_file_four_packed_code::read_inner(srecord::record &record) fatal_error("format code %d unknown", format_code); } - unsigned char buffer[256]; + uint8_t buffer[256]; for (int j = 0; j < length; ++j) buffer[j] = get_byte(); if (use_checksums() && checksum_get() != 0) diff --git a/srecord/input/file/four_packed_code.h b/srecord/input/file/four_packed_code.h index 23f9457e..26eb3263 100644 --- a/srecord/input/file/four_packed_code.h +++ b/srecord/input/file/four_packed_code.h @@ -103,7 +103,7 @@ class input_file_four_packed_code: * input multiple. (Only the get_byte method may use this * instance variable.) */ - unsigned long get_byte_value{}; + uint32_t get_byte_value{}; /** * The garbage_warning instance variable is used by the read @@ -124,7 +124,7 @@ class input_file_four_packed_code: * read_inner method to record the current address. This is * so that record types 1 and 2 can be processed accurately. */ - unsigned long running_address{0}; + uint32_t running_address{0}; public: /** diff --git a/srecord/input/file/hexdump.cc b/srecord/input/file/hexdump.cc index a2cd3110..ea34513a 100644 --- a/srecord/input/file/hexdump.cc +++ b/srecord/input/file/hexdump.cc @@ -41,7 +41,7 @@ srecord::input_file_hexdump::get_next_token() int sc = get_char(); if (sc < 0) return token_eof; - unsigned char c = sc; + uint8_t c = sc; switch (c) { case '\n': @@ -133,7 +133,7 @@ srecord::input_file_hexdump::read(record &result) break; } - unsigned char data[16]; + uint8_t data[16]; unsigned nbytes = 0; bool could_be_an_address = true; for (;;) diff --git a/srecord/input/file/hexdump.h b/srecord/input/file/hexdump.h index cee0b2ed..da48a7a4 100644 --- a/srecord/input/file/hexdump.h +++ b/srecord/input/file/hexdump.h @@ -92,7 +92,7 @@ class input_file_hexdump: * address of the next data record. This is set and advanced by * the #read method. */ - unsigned long address{0}; + uint32_t address{0}; /** * The data_seen instance variable is used to remember whether or diff --git a/srecord/input/file/hp64k.h b/srecord/input/file/hp64k.h index 6d792885..747f7abc 100644 --- a/srecord/input/file/hp64k.h +++ b/srecord/input/file/hp64k.h @@ -76,7 +76,7 @@ class input_file_hp64k: /** * Number of parsed data records */ - unsigned long rec_count{0}; + uint32_t rec_count{0}; /** Helper function: read two bytes, big-endian. Ret 1 if ok */ bool read_u16be(uint16_t *dest); diff --git a/srecord/input/file/idt.cc b/srecord/input/file/idt.cc index c3e870e0..d2199777 100644 --- a/srecord/input/file/idt.cc +++ b/srecord/input/file/idt.cc @@ -54,7 +54,7 @@ srecord::input_file_idt::read_inner(record &result) int tag = get_nibble(); if (tag < 0) record_format_error(); - unsigned char csum = 0; + uint8_t csum = 0; int line_length = get_char(); if (line_length < 0) record_format_error(); diff --git a/srecord/input/file/idt.h b/srecord/input/file/idt.h index 5e38a011..0e06d4be 100644 --- a/srecord/input/file/idt.h +++ b/srecord/input/file/idt.h @@ -73,7 +73,7 @@ class input_file_idt: * The data_count instance variable is used to remember the number * of data lines has occurred so far in the input file. */ - unsigned long data_count{0}; + uint32_t data_count{0}; /** * The read_inner method is used to read a record of input. diff --git a/srecord/input/file/intel.cc b/srecord/input/file/intel.cc index 2cd297f7..221c5773 100644 --- a/srecord/input/file/intel.cc +++ b/srecord/input/file/intel.cc @@ -98,7 +98,7 @@ srecord::input_file_intel::read_inner(srecord::record &record) // // Looks like a real Intel-hex line. // - unsigned char buffer[255+5]; + uint8_t buffer[255+5]; checksum_reset(); buffer[0] = get_byte(); buffer[1] = get_byte(); diff --git a/srecord/input/file/intel.h b/srecord/input/file/intel.h index fdccff40..5fd7fbb7 100644 --- a/srecord/input/file/intel.h +++ b/srecord/input/file/intel.h @@ -114,7 +114,7 @@ class input_file_intel: * The address_base instance variable is used to remember the * segment base address when in segmented addressing mode. */ - unsigned long address_base{0}; + uint32_t address_base{0}; /** * The pushback instance variable is used to remember the previous diff --git a/srecord/input/file/intel16.cc b/srecord/input/file/intel16.cc index 9722c74c..6d4c74db 100644 --- a/srecord/input/file/intel16.cc +++ b/srecord/input/file/intel16.cc @@ -100,7 +100,7 @@ srecord::input_file_intel16::read_inner(record &result) // // Looks like a real Intel-hex line. // - unsigned char buffer[255*2+5]; + uint8_t buffer[255*2+5]; checksum_reset(); buffer[0] = get_byte(); unsigned nbytes = buffer[0] << 1; diff --git a/srecord/input/file/intel16.h b/srecord/input/file/intel16.h index a6ee8120..b77d94a6 100644 --- a/srecord/input/file/intel16.h +++ b/srecord/input/file/intel16.h @@ -108,7 +108,7 @@ class input_file_intel16: * The address_base instance variable is used to remember the * segment base address when in segmented addressing mode. */ - unsigned long address_base{0}; + uint32_t address_base{0}; /** * The pushback instance variable is used to remember the previous diff --git a/srecord/input/file/logisim.cc b/srecord/input/file/logisim.cc index 4d3079a7..74f249c7 100644 --- a/srecord/input/file/logisim.cc +++ b/srecord/input/file/logisim.cc @@ -201,7 +201,7 @@ srecord::input_file_logisim::read_inner_job() // 1-byte vs 2-byte or 4-byte items. Also it // doesn't specify endian-ness. ep = 0; - unsigned long value = strtoul(seen_star, &ep, 16); + uint32_t value = strtoul(seen_star, &ep, 16); if (seen_star == ep || *ep != '\0') fatal_error("malformed datum"); datum_t job(address, count, value); diff --git a/srecord/input/file/mif.cc b/srecord/input/file/mif.cc index 50dcacaa..7438537b 100644 --- a/srecord/input/file/mif.cc +++ b/srecord/input/file/mif.cc @@ -277,7 +277,7 @@ srecord::input_file_mif::get_radix() bool srecord::input_file_mif::read(srecord::record &record) { - unsigned char buffer[srecord::record::max_data_length]; + uint8_t buffer[srecord::record::max_data_length]; size_t bufpos = 0; unsigned address_range = 0; @@ -351,12 +351,12 @@ srecord::input_file_mif::read(srecord::record &record) { if (lex_addr() != token_number) syntax_error("start of address range expected"); - unsigned long address_lo = token_value; + uint32_t address_lo = token_value; if (lex_addr() != token_dotdot) syntax_error("dot dot (..) expected"); if (lex_addr() != token_number) syntax_error("end of address range expected"); - unsigned long address_hi = token_value; + uint32_t address_hi = token_value; if (address_hi < address_lo) syntax_error("address range backwards"); address_range = address_hi + 1 - address_lo; @@ -417,9 +417,9 @@ srecord::input_file_mif::read(srecord::record &record) // deliberately memcpy onto self // to repeat the data in the buffer size_t nbytes = address_range - bufpos; - const unsigned char *end = buffer + address_range; - const unsigned char *in = buffer; - unsigned char *out = buffer + bufpos; + const uint8_t *end = buffer + address_range; + const uint8_t *in = buffer; + uint8_t *out = buffer + bufpos; while (out < end) *out++ = *in++; bufpos += nbytes; diff --git a/srecord/input/file/mif.h b/srecord/input/file/mif.h index a2251061..4de3b5e6 100644 --- a/srecord/input/file/mif.h +++ b/srecord/input/file/mif.h @@ -85,7 +85,7 @@ class input_file_mif: * The address instance variable is used to remember where we are * up to in the input file, so it may be associated with data bytes. */ - unsigned long address{0}; + uint32_t address{0}; /** * The lex_radix instance variable is used to remember the numeric diff --git a/srecord/input/file/mips_flash.cc b/srecord/input/file/mips_flash.cc index e210ee5c..f703c67f 100644 --- a/srecord/input/file/mips_flash.cc +++ b/srecord/input/file/mips_flash.cc @@ -146,7 +146,7 @@ srecord::input_file_mips_flash::read_inner(record &result) case token_number: if (endian == endian_big) { - unsigned char data[4]; + uint8_t data[4]; data[0] = token_value >> 24; data[1] = token_value >> 16; data[2] = token_value >> 8; @@ -155,7 +155,7 @@ srecord::input_file_mips_flash::read_inner(record &result) } else { - unsigned char data[4]; + uint8_t data[4]; data[0] = token_value; data[1] = token_value >> 8; data[2] = token_value >> 16; diff --git a/srecord/input/file/mips_flash.h b/srecord/input/file/mips_flash.h index 394ead12..4b27abda 100644 --- a/srecord/input/file/mips_flash.h +++ b/srecord/input/file/mips_flash.h @@ -104,7 +104,7 @@ class input_file_mips_flash: * The address instance variable is used to remember where we are * up to in the input file, for when we build the next data record. */ - unsigned long address{0}; + uint32_t address{0}; /** * The tokenizer method is used to determine the next token in the @@ -136,7 +136,7 @@ class input_file_mips_flash: * of the number, if the preceding #tokenizer call saw a number. * Otherwise, its value is undefined. */ - unsigned long token_value{0}; + uint32_t token_value{0}; /** * The seen_reset instance variable is used to remember diff --git a/srecord/input/file/mos_tech.cc b/srecord/input/file/mos_tech.cc index 6086d852..2eb82002 100644 --- a/srecord/input/file/mos_tech.cc +++ b/srecord/input/file/mos_tech.cc @@ -109,8 +109,8 @@ srecord::input_file_mos_tech::read_inner(srecord::record &record) return false; } - unsigned long address = get_word_be(); - unsigned char buffer[256]; + uint32_t address = get_word_be(); + uint8_t buffer[256]; for (int j = 0; j < length; ++j) buffer[j] = get_byte(); int csumX = checksum_get16(); diff --git a/srecord/input/file/motorola.cc b/srecord/input/file/motorola.cc index b4c77cc9..a0ecde01 100644 --- a/srecord/input/file/motorola.cc +++ b/srecord/input/file/motorola.cc @@ -116,7 +116,7 @@ srecord::input_file_motorola::read_inner(record &result) int line_length = get_byte(); if (line_length < 1) fatal_error("line length invalid"); - unsigned char buffer[256]; + uint8_t buffer[256]; for (int j = 0; j < line_length; ++j) buffer[j] = get_byte(); if (use_checksums()) diff --git a/srecord/input/file/motorola.h b/srecord/input/file/motorola.h index 388cb53e..43e69c48 100644 --- a/srecord/input/file/motorola.h +++ b/srecord/input/file/motorola.h @@ -73,7 +73,7 @@ class input_file_motorola: * The data_count instance variable is used to remember the number * of data lines has occurred so far in the input file. */ - unsigned long data_count{0}; + uint32_t data_count{0}; /** * The read_inner method is used to read a record of input. diff --git a/srecord/input/file/msbin.cc b/srecord/input/file/msbin.cc index 25a58857..b636c765 100644 --- a/srecord/input/file/msbin.cc +++ b/srecord/input/file/msbin.cc @@ -37,20 +37,20 @@ srecord::input_file_msbin::~input_file_msbin() { warning ( - "image address header field is wrong (header = 0x%08lX, " - "actual = 0x%08lX)", - (unsigned long)image_start, - (unsigned long)lowest_address + "image address header field is wrong (header = 0x%08X, " + "actual = 0x%08X)", + (uint32_t)image_start, + (uint32_t)lowest_address ); } if (highest_address - lowest_address + 1 != image_length) { warning ( - "image length header field is wrong (header = 0x%08lX, " - "actual = 0x%08lX)", - (unsigned long)image_length, - (unsigned long)(highest_address - lowest_address + 1) + "image length header field is wrong (header = 0x%08X, " + "actual = 0x%08X)", + (uint32_t)image_length, + (uint32_t)(highest_address - lowest_address + 1) ); } } @@ -73,7 +73,7 @@ srecord::input_file_msbin::create(const std::string &a_file_name) uint32_t srecord::input_file_msbin::read_dword_le() { - unsigned char c[sizeof(uint32_t)]; + uint8_t c[sizeof(uint32_t)]; for (size_t i = 0; i < sizeof(c); ++i) { @@ -81,8 +81,8 @@ srecord::input_file_msbin::read_dword_le() if (j < 0) fatal_error("short input file"); - assert(j <= std::numeric_limits::max()); - c[i] = (unsigned char)j; + assert(j <= std::numeric_limits::max()); + c[i] = (uint8_t)j; } return record::decode_little_endian(c, sizeof(c)); @@ -93,18 +93,18 @@ void srecord::input_file_msbin::read_file_header() { // Optional magic - static const unsigned char Magic[7] = + static const uint8_t Magic[7] = { 'B', '0', '0', '0', 'F', 'F', '\n' }; // +1 so that buff can be reused for two dwords in case the magic is missing - unsigned char buff[sizeof(Magic) + 1]; + uint8_t buff[sizeof(Magic) + 1]; for (size_t i = 0; i < sizeof(Magic); ++i) { int j = get_char(); if (j < 0) fatal_error("short input file"); - assert(j <= std::numeric_limits::max()); + assert(j <= std::numeric_limits::max()); buff[i] = j; } @@ -147,7 +147,7 @@ srecord::input_file_msbin::read_file_header() uint32_t -srecord::input_file_msbin::checksum(const unsigned char *data, size_t len) +srecord::input_file_msbin::checksum(const uint8_t *data, size_t len) { uint32_t sum = 0; @@ -228,8 +228,8 @@ srecord::input_file_msbin::read(record &result) fatal_error ( "checksum of the execution start record is not 0, as " - "required by specification (0x%08lX != 0x00000000)", - (unsigned long)record_checksum + "required by specification (0x%08X != 0x00000000)", + (uint32_t)record_checksum ); } @@ -244,7 +244,7 @@ srecord::input_file_msbin::read(record &result) // Data record // Read (part) of the record - unsigned char data[record::max_data_length]; + uint8_t data[record::max_data_length]; const size_t to_read = std::min(remaining, (uint32_t)record::max_data_length); @@ -258,7 +258,7 @@ srecord::input_file_msbin::read(record &result) size_t read = 0; while (read < to_read) { - assert(c <= std::numeric_limits::max()); + assert(c <= std::numeric_limits::max()); data[read++] = c; if (read >= to_read) break; @@ -284,9 +284,9 @@ srecord::input_file_msbin::read(record &result) { fatal_error ( - "wrong record checksum (0x%08lX != 0x%08lX)", - (unsigned long)running_checksum, - (unsigned long)record_checksum + "wrong record checksum (0x%08X != 0x%08X)", + (uint32_t)running_checksum, + (uint32_t)record_checksum ); } } diff --git a/srecord/input/file/msbin.h b/srecord/input/file/msbin.h index 496da2d6..5f11ac42 100644 --- a/srecord/input/file/msbin.h +++ b/srecord/input/file/msbin.h @@ -179,7 +179,7 @@ class input_file_msbin: * @param len * The length in bytes of the data to be check-summed. */ - static uint32_t checksum(const unsigned char *data, size_t len); + static uint32_t checksum(const uint8_t *data, size_t len); // See base class for documentation. bool is_binary() const override; diff --git a/srecord/input/file/needham.cc b/srecord/input/file/needham.cc index b0e344ec..9533500b 100644 --- a/srecord/input/file/needham.cc +++ b/srecord/input/file/needham.cc @@ -52,7 +52,7 @@ srecord::input_file_needham::read(srecord::record &record) } if (isxdigit(c)) { - unsigned char c = get_byte(); + uint8_t c = get_byte(); record = srecord::record ( diff --git a/srecord/input/file/needham.h b/srecord/input/file/needham.h index fae3a97c..a710ba6b 100644 --- a/srecord/input/file/needham.h +++ b/srecord/input/file/needham.h @@ -69,7 +69,7 @@ class input_file_needham: bool read_inner(record &); bool garbage_warning{}; bool seen_some_input{false}; - unsigned long address{0}; + uint32_t address{0}; public: /** diff --git a/srecord/input/file/os65v.cc b/srecord/input/file/os65v.cc index d7128c8c..8264a133 100644 --- a/srecord/input/file/os65v.cc +++ b/srecord/input/file/os65v.cc @@ -60,7 +60,7 @@ srecord::input_file_os65v::read_inner(srecord::record &record) // It could be an address or a data byte. // get_char_undo(c); - unsigned long n = 0; + uint32_t n = 0; for (;;) { n = (n << 4) | get_nibble(); @@ -91,7 +91,7 @@ srecord::input_file_os65v::read_inner(srecord::record &record) ignore_the_rest = true; return false; } - unsigned char buf[1]; + uint8_t buf[1]; buf[0] = n; record = srecord::record diff --git a/srecord/input/file/os65v.h b/srecord/input/file/os65v.h index bd66c64a..3ceaf114 100644 --- a/srecord/input/file/os65v.h +++ b/srecord/input/file/os65v.h @@ -98,7 +98,7 @@ class input_file_os65v: * The address instance variable is used to remember the current * address. It is advanced for every byte read. */ - unsigned long address{0}; + uint32_t address{0}; /** * The state instance variable is used to member the current input diff --git a/srecord/input/file/ppb.cc b/srecord/input/file/ppb.cc index 0dfd2811..e909ee61 100644 --- a/srecord/input/file/ppb.cc +++ b/srecord/input/file/ppb.cc @@ -56,8 +56,8 @@ srecord::input_file_ppb::get_packet() if (c != SOH) packet_format_error(); - unsigned char hdr[8]; - unsigned char csum = 0; + uint8_t hdr[8]; + uint8_t csum = 0; for (int n = 0; n < 8; ++n) { c = get_char(); @@ -90,12 +90,12 @@ srecord::input_file_ppb::get_packet() c = get_char(); if (c < 0) packet_format_error(); - if (c != (unsigned char)-csum && use_checksums()) + if (c != (uint8_t)-csum && use_checksums()) { fatal_error ( "intermediate checksum mismatch (expected %d, read %d)", - (unsigned char)-csum, + (uint8_t)-csum, c ); } @@ -109,12 +109,12 @@ srecord::input_file_ppb::get_packet() c = get_char(); if (c < 0) packet_format_error(); - if (c != (unsigned char)-csum && use_checksums()) + if (c != (uint8_t)-csum && use_checksums()) { fatal_error ( "packet checksum mismatch (expected %d, read %d)", - (unsigned char)-csum, + (uint8_t)-csum, c ); } diff --git a/srecord/input/file/ppb.h b/srecord/input/file/ppb.h index 29c45013..fe351ec4 100644 --- a/srecord/input/file/ppb.h +++ b/srecord/input/file/ppb.h @@ -72,7 +72,7 @@ class input_file_ppb: * The packet_address instance variable is used to remember the * address of the first byte in the most recently read packet. */ - unsigned long packet_address{-1UL}; + uint32_t packet_address{-1U}; /** * The packet instance variable is used to remember the most recent diff --git a/srecord/input/file/ppx.cc b/srecord/input/file/ppx.cc index 0f8f5a45..23a4589d 100644 --- a/srecord/input/file/ppx.cc +++ b/srecord/input/file/ppx.cc @@ -47,7 +47,7 @@ srecord::input_file_ppx::get_next_token() token = token_eof; return; } - unsigned char c = sc; + uint8_t c = sc; switch (c) { case '*': diff --git a/srecord/input/file/ppx.h b/srecord/input/file/ppx.h index 92bbb94b..276f1df6 100644 --- a/srecord/input/file/ppx.h +++ b/srecord/input/file/ppx.h @@ -129,7 +129,7 @@ class input_file_ppx: * The dsum instance variable is used to remember the simple sum of * the data bytes, and the data bytes alone. */ - unsigned short dsum{0}; + uint16_t dsum{0}; /** * The buffer instance variable is used to remember the most recent diff --git a/srecord/input/file/signetics.cc b/srecord/input/file/signetics.cc index 3ae188cd..e92cabfc 100644 --- a/srecord/input/file/signetics.cc +++ b/srecord/input/file/signetics.cc @@ -36,7 +36,7 @@ srecord::input_file_signetics::create(const std::string &a_file_name) void -srecord::input_file_signetics::checksum_add(unsigned char n) +srecord::input_file_signetics::checksum_add(uint8_t n) { checksum ^= n; checksum = (checksum << 1) | ((checksum >> 7) & 1); @@ -93,7 +93,7 @@ srecord::input_file_signetics::read_inner(srecord::record &record) } checksum_reset(); - unsigned char buffer[256]; + uint8_t buffer[256]; for (int j = 0; j < length; ++j) buffer[j] = get_byte(); diff --git a/srecord/input/file/signetics.h b/srecord/input/file/signetics.h index 209f3a0e..9c945347 100644 --- a/srecord/input/file/signetics.h +++ b/srecord/input/file/signetics.h @@ -61,7 +61,7 @@ class input_file_signetics: * See base class for documentation. We over-ride this method * because signetics uses its own XOR-ROL checksum algorithm. */ - void checksum_add(unsigned char) override; + void checksum_add(uint8_t) override; public: /** diff --git a/srecord/input/file/spasm.cc b/srecord/input/file/spasm.cc index 2372fb0e..40d9fc43 100644 --- a/srecord/input/file/spasm.cc +++ b/srecord/input/file/spasm.cc @@ -57,7 +57,7 @@ srecord::input_file_spasm::read_inner(record &result) int address = get_word_be(); if (get_char() != ' ') fatal_error("space expected"); - unsigned char data[2]; + uint8_t data[2]; if (end == endian_big) { data[1] = get_byte(); diff --git a/srecord/input/file/spectrum.cc b/srecord/input/file/spectrum.cc index 5338bc26..f3c5fafe 100644 --- a/srecord/input/file/spectrum.cc +++ b/srecord/input/file/spectrum.cc @@ -49,9 +49,9 @@ srecord::input_file_spectrum::get_decimal() format_error: fatal_error("decimal number expected"); } - if (isspace((unsigned char)c)) + if (isspace((uint8_t)c)) continue; - if (!isdigit((unsigned char)c)) + if (!isdigit((uint8_t)c)) goto format_error; break; } @@ -61,7 +61,7 @@ srecord::input_file_spectrum::get_decimal() c = get_char(); if (c < 0) break; - if (!isdigit((unsigned char)c)) + if (!isdigit((uint8_t)c)) { get_char_undo(c); break; @@ -91,9 +91,9 @@ srecord::input_file_spectrum::get_binary() format_error: fatal_error("binary number expected"); } - if (isspace((unsigned char)c)) + if (isspace((uint8_t)c)) continue; - if (!is_binary_digit((unsigned char)c)) + if (!is_binary_digit((uint8_t)c)) goto format_error; break; } @@ -154,14 +154,14 @@ srecord::input_file_spectrum::read(srecord::record &record) trailer_seen = true; return false; } - if (isspace((unsigned char)c)) + if (isspace((uint8_t)c)) continue; get_char_undo(c); break; } - unsigned long address = get_decimal(); - unsigned char data = get_binary(); + uint32_t address = get_decimal(); + uint8_t data = get_binary(); record = srecord::record(srecord::record::type_data, address, &data, 1); file_contains_data = true; return true; diff --git a/srecord/input/file/stewie.cc b/srecord/input/file/stewie.cc index 274d3a1c..5e2d3669 100644 --- a/srecord/input/file/stewie.cc +++ b/srecord/input/file/stewie.cc @@ -79,7 +79,7 @@ srecord::input_file_stewie::read_inner(record &result) int line_length = get_byte(); if (line_length < 1) fatal_error("record length invalid"); - unsigned char buffer[256]; + uint8_t buffer[256]; for (int j = 0; j < line_length; ++j) buffer[j] = get_byte(); if (use_checksums()) diff --git a/srecord/input/file/stewie.h b/srecord/input/file/stewie.h index 6ff095a3..e380da16 100644 --- a/srecord/input/file/stewie.h +++ b/srecord/input/file/stewie.h @@ -77,7 +77,7 @@ class input_file_stewie: * The data_count instance variable is used to remember the number * of data lines has occurred so far in the input file. */ - unsigned long data_count{0}; + uint32_t data_count{0}; /** * The read_inner method is used to read a record of input. diff --git a/srecord/input/file/tektronix.cc b/srecord/input/file/tektronix.cc index 52437d72..048a1bd8 100644 --- a/srecord/input/file/tektronix.cc +++ b/srecord/input/file/tektronix.cc @@ -91,7 +91,7 @@ srecord::input_file_tektronix::read_inner(srecord::record &record) return false; } - unsigned char buffer[255+5]; + uint8_t buffer[255+5]; checksum_reset(); buffer[0] = get_byte(); buffer[1] = get_byte(); diff --git a/srecord/input/file/tektronix_extended.cc b/srecord/input/file/tektronix_extended.cc index 97e20fef..b9b8497f 100644 --- a/srecord/input/file/tektronix_extended.cc +++ b/srecord/input/file/tektronix_extended.cc @@ -85,7 +85,7 @@ srecord::input_file_tektronix_extended::read_inner(srecord::record &record) int tag = get_nibble(); --length; - unsigned char csum_expected = get_byte(); + uint8_t csum_expected = get_byte(); // except the checksum itself nibble_sum -= ((csum_expected >> 4) & 15) + (csum_expected & 15); length -= 2; @@ -114,7 +114,7 @@ srecord::input_file_tektronix_extended::read_inner(srecord::record &record) ); } - unsigned long address = 0; + uint32_t address = 0; while (addr_len > 0) { int n = get_nibble(); @@ -125,7 +125,7 @@ srecord::input_file_tektronix_extended::read_inner(srecord::record &record) if (length & 1) fatal_error("data length invalid (%d is odd)", length); - unsigned char buffer[125]; + uint8_t buffer[125]; for (int j = 0; j * 2 < length; ++j) { int n = get_byte(); diff --git a/srecord/input/file/tektronix_extended.h b/srecord/input/file/tektronix_extended.h index 63309290..0323af82 100644 --- a/srecord/input/file/tektronix_extended.h +++ b/srecord/input/file/tektronix_extended.h @@ -107,7 +107,7 @@ class input_file_tektronix_extended: * The nibble_sum instance variable is usd to remember the running * checksum, of each nibble on the record line. */ - unsigned char nibble_sum{0}; + uint8_t nibble_sum{0}; public: /** diff --git a/srecord/input/file/ti_tagged.cc b/srecord/input/file/ti_tagged.cc index cde2e9d4..10e6f06d 100644 --- a/srecord/input/file/ti_tagged.cc +++ b/srecord/input/file/ti_tagged.cc @@ -71,7 +71,7 @@ srecord::input_file_ti_tagged::read(record &result) case '*': { // followed by 2 data characters (1 data byte) - unsigned char data[1]; + uint8_t data[1]; data[0] = get_byte(); result = record(record::type_data, address, data, 1); ++address; @@ -125,7 +125,7 @@ srecord::input_file_ti_tagged::read(record &result) case 'B': { - unsigned char data[2]; + uint8_t data[2]; data[0] = get_byte(); data[1] = get_byte(); result = record(record::type_data, address, data, 2); @@ -150,7 +150,7 @@ srecord::input_file_ti_tagged::read(record &result) } n -= 5; int max = 250; - auto *buffer = new unsigned char [max]; + auto *buffer = new uint8_t [max]; for (int j = 0; j < n; ++j) { c = get_char(); diff --git a/srecord/input/file/ti_tagged.h b/srecord/input/file/ti_tagged.h index 6c9ebb85..03276845 100644 --- a/srecord/input/file/ti_tagged.h +++ b/srecord/input/file/ti_tagged.h @@ -85,7 +85,7 @@ class input_file_ti_tagged: * The address instance variable is used to remember where we are * up to in the input file. */ - unsigned long address{0}; + uint32_t address{0}; /** * The csum instance variable is used to remember the running diff --git a/srecord/input/file/ti_tagged_16.cc b/srecord/input/file/ti_tagged_16.cc index dfce42aa..0aae2c60 100644 --- a/srecord/input/file/ti_tagged_16.cc +++ b/srecord/input/file/ti_tagged_16.cc @@ -70,7 +70,7 @@ srecord::input_file_ti_tagged_16::read(record &result) case '*': { // followed by 2 data characters (1 data byte) - unsigned char data[1]; + uint8_t data[1]; data[0] = get_byte(); result = record(record::type_data, address, data, 1); ++address; @@ -124,7 +124,7 @@ srecord::input_file_ti_tagged_16::read(record &result) case 'B': { - unsigned char data[2]; + uint8_t data[2]; data[0] = get_byte(); data[1] = get_byte(); result = record(record::type_data, address, data, 2); @@ -149,7 +149,7 @@ srecord::input_file_ti_tagged_16::read(record &result) } n -= 5; int max = 250; - auto *buffer = new unsigned char [max]; + auto *buffer = new uint8_t [max]; for (int j = 0; j < n; ++j) { c = get_char(); diff --git a/srecord/input/file/ti_tagged_16.h b/srecord/input/file/ti_tagged_16.h index 0d9b807d..7bd85f4b 100644 --- a/srecord/input/file/ti_tagged_16.h +++ b/srecord/input/file/ti_tagged_16.h @@ -85,7 +85,7 @@ class input_file_ti_tagged_16: * The address instance variable is used to remember where we are * up to in the input file. */ - unsigned long address{0}; + uint32_t address{0}; /** * The csum instance variable is used to remember the running diff --git a/srecord/input/file/ti_txt.cc b/srecord/input/file/ti_txt.cc index aac6f70a..cc1f97ef 100644 --- a/srecord/input/file/ti_txt.cc +++ b/srecord/input/file/ti_txt.cc @@ -136,7 +136,7 @@ srecord::input_file_ti_txt::read(record &result) #endif if (address >= (1 << 20) && !address_warning) { - warning("addresses (0x%08lX) too large", address); + warning("addresses (0x%08X) too large", address); address_warning = true; } get_next_token(); @@ -145,12 +145,12 @@ srecord::input_file_ti_txt::read(record &result) case token_number: { seen_some_input = true; - unsigned char buffer[record::max_data_length]; + uint8_t buffer[record::max_data_length]; size_t n = 0; for (;;) { if (token_value >= 256) - fatal_error("byte value (%ld) too large", token_value); + fatal_error("byte value (%d) too large", token_value); buffer[n++] = token_value; get_next_token(); if (n >= record::max_data_length) @@ -160,7 +160,7 @@ srecord::input_file_ti_txt::read(record &result) } if (address >= (1 << 20) && !address_warning) { - warning("addresses (0x%08lX) too large", address); + warning("addresses (0x%08X) too large", address); address_warning = true; } result = record(record::type_data, address, buffer, n); diff --git a/srecord/input/file/ti_txt.h b/srecord/input/file/ti_txt.h index 16261326..6167adaa 100644 --- a/srecord/input/file/ti_txt.h +++ b/srecord/input/file/ti_txt.h @@ -76,7 +76,7 @@ class input_file_ti_txt: * The address instance variable is used to remember where we are * up to in the input file, so it may be associated with data bytes. */ - unsigned long address{0}; + uint32_t address{0}; enum token_t { @@ -99,7 +99,7 @@ class input_file_ti_txt: * of the most recent token, as determined by the get_next_token * method. Only meaningful for token_number, zero otherwise. */ - unsigned long token_value{0}; + uint32_t token_value{0}; /** * The address_warning instance variable is used to remember diff --git a/srecord/input/file/trs80.cc b/srecord/input/file/trs80.cc index 7bfda345..cec4f4cc 100644 --- a/srecord/input/file/trs80.cc +++ b/srecord/input/file/trs80.cc @@ -89,7 +89,7 @@ srecord::input_file_trs80::read(srecord::record &result) unsigned payload_size = get_byte(); if (rec_type == 0x01 && payload_size <= 2) payload_size += 256; - unsigned char payload[258]; + uint8_t payload[258]; for (unsigned j = 0; j < payload_size; ++j) payload[j] = get_byte(); @@ -100,7 +100,7 @@ srecord::input_file_trs80::read(srecord::record &result) { assert(payload_size > 2); long address = decode_word_le(payload); - const unsigned char *data = payload + 2; + const uint8_t *data = payload + 2; unsigned data_size = payload_size - 2; record::type_t type = record::type_data; assert(data_size < 2 * record::max_data_length); @@ -155,9 +155,9 @@ srecord::input_file_trs80::read(srecord::record &result) // Get rid of unprintable characters (especially NUL) { - const unsigned char *ip = payload; - const unsigned char *end = ip + payload_size; - unsigned char *op = payload; + const uint8_t *ip = payload; + const uint8_t *end = ip + payload_size; + uint8_t *op = payload; while (ip < end) { if (isprint(*ip)) diff --git a/srecord/input/file/vmem.cc b/srecord/input/file/vmem.cc index 48609824..bc8784aa 100644 --- a/srecord/input/file/vmem.cc +++ b/srecord/input/file/vmem.cc @@ -56,12 +56,12 @@ srecord::input_file_vmem::read(srecord::record &record) { address = (address << 4) + get_nibble(); c = peek_char(); - if (c < 0 || !isxdigit((unsigned char)c)) + if (c < 0 || !isxdigit((uint8_t)c)) break; } continue; } - if (isspace((unsigned char)c)) + if (isspace((uint8_t)c)) continue; if (c == '/') @@ -110,13 +110,13 @@ srecord::input_file_vmem::read(srecord::record &record) // collect value get_char_undo(c); - unsigned char value[5]; + uint8_t value[5]; size_t nbytes = 0; while (nbytes < sizeof(value)) { value[nbytes++] = get_byte(); c = peek_char(); - if (c < 0 || !isxdigit((unsigned char)c)) + if (c < 0 || !isxdigit((uint8_t)c)) break; } switch (nbytes) diff --git a/srecord/input/file/vmem.h b/srecord/input/file/vmem.h index f1b39e12..75a03be0 100644 --- a/srecord/input/file/vmem.h +++ b/srecord/input/file/vmem.h @@ -76,7 +76,7 @@ class input_file_vmem: * The address instance variable is used to remember where we are * up to in the input file, so it may be associated with data bytes. */ - unsigned long address{0}; + uint32_t address{0}; public: /** diff --git a/srecord/input/file/wilson.cc b/srecord/input/file/wilson.cc index 027bc5a5..c57628f8 100644 --- a/srecord/input/file/wilson.cc +++ b/srecord/input/file/wilson.cc @@ -94,7 +94,7 @@ srecord::input_file_wilson::read_inner(record &result) int line_length = get_byte(); if (line_length < 1) fatal_error("line length invalid"); - unsigned char buffer[256]; + uint8_t buffer[256]; for (int j = 0; j < line_length; ++j) buffer[j] = get_byte(); if (use_checksums()) diff --git a/srecord/input/filter/byte_swap.cc b/srecord/input/filter/byte_swap.cc index b89bafad..02b3cc8a 100644 --- a/srecord/input/filter/byte_swap.cc +++ b/srecord/input/filter/byte_swap.cc @@ -59,8 +59,8 @@ srecord::input_filter_byte_swap::read(srecord::record &record) buffer_pos = 0; } - unsigned long addr = (buffer.get_address() + buffer_pos) ^ mask; - unsigned char c = buffer.get_data(buffer_pos++); + uint32_t addr = (buffer.get_address() + buffer_pos) ^ mask; + uint8_t c = buffer.get_data(buffer_pos++); record = srecord::record(srecord::record::type_data, addr, &c, 1); return true; } diff --git a/srecord/input/filter/checksum.cc b/srecord/input/filter/checksum.cc index 7303cd44..7e3c36ca 100644 --- a/srecord/input/filter/checksum.cc +++ b/srecord/input/filter/checksum.cc @@ -51,7 +51,7 @@ srecord::input_filter_checksum::generate(record &result) { if (length <= 0) return false; - unsigned char chunk[sizeof(sum_t)]; + uint8_t chunk[sizeof(sum_t)]; sum_t value = calculate(); record::encode(chunk, value, length, end); result = record(record::type_data, checksum_address, chunk, length); diff --git a/srecord/input/filter/checksum.h b/srecord/input/filter/checksum.h index 8b2bba2e..e26cb857 100644 --- a/srecord/input/filter/checksum.h +++ b/srecord/input/filter/checksum.h @@ -66,7 +66,7 @@ class input_filter_checksum: input_filter_checksum(input::pointer deeper, int address, int length, endian_t end, int width = 1); - typedef unsigned long sum_t; + typedef uint32_t sum_t; /** * The checksum_address instance variable is used to remember where diff --git a/srecord/input/filter/fill.cc b/srecord/input/filter/fill.cc index 6a02a516..5440b89e 100644 --- a/srecord/input/filter/fill.cc +++ b/srecord/input/filter/fill.cc @@ -64,7 +64,7 @@ srecord::input_filter_fill::generate(record &result) size_t fill_block_size = 256; if (!filler_block) { - filler_block = new unsigned char [fill_block_size]; + filler_block = new uint8_t [fill_block_size]; memset(filler_block, filler_value, fill_block_size); } rec_len = chunk.get_highest() - chunk.get_lowest(); diff --git a/srecord/input/filter/fill.h b/srecord/input/filter/fill.h index 175fcf9b..c097f286 100644 --- a/srecord/input/filter/fill.h +++ b/srecord/input/filter/fill.h @@ -84,7 +84,7 @@ class input_filter_fill: * of a dynamically allocated array of bytes, used to construct * filler block records. */ - unsigned char *filler_block{nullptr}; + uint8_t *filler_block{nullptr}; /** * The range instance variable is used to remember the range of diff --git a/srecord/input/filter/interval.cc b/srecord/input/filter/interval.cc index d0351b48..de1102fe 100644 --- a/srecord/input/filter/interval.cc +++ b/srecord/input/filter/interval.cc @@ -44,7 +44,7 @@ srecord::input_filter_interval::generate(record &result) if (length <= 0) return false; long value = calculate_result(); - unsigned char chunk[8]; + uint8_t chunk[8]; record::encode(chunk, value, length, end); result = record(record::type_data, address, chunk, length); length = 0; diff --git a/srecord/input/filter/message.cc b/srecord/input/filter/message.cc index a9aacfe8..ba810e38 100644 --- a/srecord/input/filter/message.cc +++ b/srecord/input/filter/message.cc @@ -113,8 +113,8 @@ srecord::input_filter_message::read(record &result) // if (!naked) { - unsigned long ret_address = buffer_pos; - unsigned char data[64]; + uint32_t ret_address = buffer_pos; + uint8_t data[64]; size_t nbytes = sizeof(data); if (buffer.find_next_data(ret_address, data, nbytes)) { diff --git a/srecord/input/filter/message.h b/srecord/input/filter/message.h index 64de9b85..defce74d 100644 --- a/srecord/input/filter/message.h +++ b/srecord/input/filter/message.h @@ -100,7 +100,7 @@ class input_filter_message: * The buffer_pos instance variable is used to remember where we * are up to in processing 'buffer'. */ - unsigned long buffer_pos{0}; + uint32_t buffer_pos{0}; /** * The have_forwarded_header instance variable is used to remember diff --git a/srecord/input/filter/message/adler16.cc b/srecord/input/filter/message/adler16.cc index cd9336fb..241d4302 100644 --- a/srecord/input/filter/message/adler16.cc +++ b/srecord/input/filter/message/adler16.cc @@ -25,7 +25,7 @@ srecord::input_filter_message_adler16::input_filter_message_adler16( const input::pointer &a_deeper, - unsigned long a_address, + uint32_t a_address, endian_t a_end ) : input_filter_message(a_deeper), @@ -37,7 +37,7 @@ srecord::input_filter_message_adler16::input_filter_message_adler16( srecord::input::pointer srecord::input_filter_message_adler16::create(const input::pointer &a_deeper, - unsigned long a_address, endian_t a_end) + uint32_t a_address, endian_t a_end) { return pointer @@ -58,12 +58,12 @@ srecord::input_filter_message_adler16::process(const memory &input, // memory_walker_adler16::pointer w = memory_walker_adler16::create(); input.walk(w); - unsigned short adler = w->get(); + uint16_t adler = w->get(); // // Turn the Adler-16 checksum into the first data record. // - unsigned char chunk[2]; + uint8_t chunk[2]; record::encode(chunk, adler, sizeof(chunk), end); output = record(record::type_data, address, chunk, sizeof(chunk)); } diff --git a/srecord/input/filter/message/adler16.h b/srecord/input/filter/message/adler16.h index 9272bdaa..0cab3095 100644 --- a/srecord/input/filter/message/adler16.h +++ b/srecord/input/filter/message/adler16.h @@ -52,7 +52,7 @@ class input_filter_message_adler16: * The byte order. */ input_filter_message_adler16(const input::pointer &deeper, - unsigned long address, endian_t end); + uint32_t address, endian_t end); public: /** @@ -66,7 +66,7 @@ class input_filter_message_adler16: * @param end * The byte order. */ - static pointer create(const input::pointer &deeper, unsigned long address, + static pointer create(const input::pointer &deeper, uint32_t address, endian_t end); protected: @@ -81,7 +81,7 @@ class input_filter_message_adler16: * The address instance variable is used to remember where to place * the Adler 16 checksum in memory. */ - unsigned long address; + uint32_t address; /** * The end instance variable is used to remember whether the byte diff --git a/srecord/input/filter/message/adler32.cc b/srecord/input/filter/message/adler32.cc index def2c85e..494c4bb5 100644 --- a/srecord/input/filter/message/adler32.cc +++ b/srecord/input/filter/message/adler32.cc @@ -25,7 +25,7 @@ srecord::input_filter_message_adler32::input_filter_message_adler32( const input::pointer &a_deeper, - unsigned long a_address, + uint32_t a_address, endian_t a_end ) : input_filter_message(a_deeper), @@ -37,7 +37,7 @@ srecord::input_filter_message_adler32::input_filter_message_adler32( srecord::input::pointer srecord::input_filter_message_adler32::create(const input::pointer &a_deeper, - unsigned long a_address, endian_t a_end) + uint32_t a_address, endian_t a_end) { return pointer @@ -59,12 +59,12 @@ srecord::input_filter_message_adler32::process(const memory &input, memory_walker_adler32::pointer w = memory_walker_adler32::create(); input.walk(w); - unsigned long adler = w->get(); + uint32_t adler = w->get(); // // Turn the CRC into the first data record. // - unsigned char chunk[4]; + uint8_t chunk[4]; record::encode(chunk, adler, sizeof(chunk), end); output = record(record::type_data, address, chunk, sizeof(chunk)); } diff --git a/srecord/input/filter/message/adler32.h b/srecord/input/filter/message/adler32.h index 22531fdb..0141d7dd 100644 --- a/srecord/input/filter/message/adler32.h +++ b/srecord/input/filter/message/adler32.h @@ -52,7 +52,7 @@ class input_filter_message_adler32: * The byte order. */ input_filter_message_adler32(const input::pointer &deeper, - unsigned long address, endian_t end); + uint32_t address, endian_t end); public: /** @@ -67,7 +67,7 @@ class input_filter_message_adler32: * The byte order. */ static pointer create(const input::pointer &deeper, - unsigned long address, endian_t end); + uint32_t address, endian_t end); protected: // See base class for documentation. @@ -81,7 +81,7 @@ class input_filter_message_adler32: * The address instance variable is used to remember where to place * the Adler 32 checksum in memory. */ - unsigned long address; + uint32_t address; /** * The end instance variable is used to remember whether the byte diff --git a/srecord/input/filter/message/crc16.cc b/srecord/input/filter/message/crc16.cc index 874b92bd..d3590e78 100644 --- a/srecord/input/filter/message/crc16.cc +++ b/srecord/input/filter/message/crc16.cc @@ -25,7 +25,7 @@ srecord::input_filter_message_crc16::input_filter_message_crc16( - const input::pointer &deeper_arg, unsigned long address_arg, + const input::pointer &deeper_arg, uint32_t address_arg, endian_t a_end) : input_filter_message(deeper_arg), address(address_arg), @@ -36,7 +36,7 @@ srecord::input_filter_message_crc16::input_filter_message_crc16( srecord::input::pointer srecord::input_filter_message_crc16::create(const input::pointer &a_deeper, - unsigned long a_address, endian_t a_end) + uint32_t a_address, endian_t a_end) { return pointer @@ -146,7 +146,7 @@ srecord::input_filter_message_crc16::process(const memory &buffer, // // Turn the CRC into the first data record. // - unsigned char chunk[2]; + uint8_t chunk[2]; record::encode(chunk, crc, sizeof(chunk), end); result = record(record::type_data, address, chunk, sizeof(chunk)); } diff --git a/srecord/input/filter/message/crc16.h b/srecord/input/filter/message/crc16.h index 4bad34f6..1b29bc94 100644 --- a/srecord/input/filter/message/crc16.h +++ b/srecord/input/filter/message/crc16.h @@ -52,7 +52,7 @@ class input_filter_message_crc16: * The byte order. */ input_filter_message_crc16(const input::pointer &deeper, - unsigned long address, endian_t end); + uint32_t address, endian_t end); public: /** @@ -66,7 +66,7 @@ class input_filter_message_crc16: * @param end * The byte order. */ - static pointer create(const input::pointer &deeper, unsigned long address, + static pointer create(const input::pointer &deeper, uint32_t address, endian_t end); protected: @@ -84,7 +84,7 @@ class input_filter_message_crc16: * The address instance variable is used to remember where to place * the CRC in memory. */ - unsigned long address; + uint32_t address; /** * The end instance variable is used to remember whether the byte @@ -105,7 +105,7 @@ class input_filter_message_crc16: */ bool augment_flag{true}; - unsigned short polynomial{crc16::polynomial_ccitt}; + uint16_t polynomial{crc16::polynomial_ccitt}; /** * The bitdir instance variable is used to remember the bit diff --git a/srecord/input/filter/message/crc32.cc b/srecord/input/filter/message/crc32.cc index b07a028c..6e72601f 100644 --- a/srecord/input/filter/message/crc32.cc +++ b/srecord/input/filter/message/crc32.cc @@ -25,7 +25,7 @@ srecord::input_filter_message_crc32::input_filter_message_crc32( const input::pointer &a_deeper, - unsigned long a_address, + uint32_t a_address, endian_t a_end ) : input_filter_message(a_deeper), @@ -38,7 +38,7 @@ srecord::input_filter_message_crc32::input_filter_message_crc32( srecord::input::pointer srecord::input_filter_message_crc32::create(const input::pointer &a_deeper, - unsigned long a_address, endian_t a_end) + uint32_t a_address, endian_t a_end) { return pointer @@ -83,12 +83,12 @@ srecord::input_filter_message_crc32::process(const memory &input, memory_walker_crc32::pointer w = memory_walker_crc32::create(seed_mode); input.walk(w); - unsigned long crc = w->get(); + uint32_t crc = w->get(); // // Turn the CRC into the first data record. // - unsigned char chunk[4]; + uint8_t chunk[4]; record::encode(chunk, crc, sizeof(chunk), end); output = record(record::type_data, address, chunk, sizeof(chunk)); } diff --git a/srecord/input/filter/message/crc32.h b/srecord/input/filter/message/crc32.h index 75653bf2..b97dc9e2 100644 --- a/srecord/input/filter/message/crc32.h +++ b/srecord/input/filter/message/crc32.h @@ -52,7 +52,7 @@ class input_filter_message_crc32: * The byte order. */ input_filter_message_crc32(const input::pointer &deeper, - unsigned long address, endian_t end); + uint32_t address, endian_t end); public: /** @@ -66,7 +66,7 @@ class input_filter_message_crc32: * @param end * The byte order. */ - static pointer create(const input::pointer &deeper, unsigned long address, + static pointer create(const input::pointer &deeper, uint32_t address, endian_t end); protected: @@ -84,7 +84,7 @@ class input_filter_message_crc32: * The address instance variable is used to remember where to place * the CRC in memory. */ - unsigned long address; + uint32_t address; /** * The end instance variable is used to remember whether the byte diff --git a/srecord/input/filter/message/fletcher16.cc b/srecord/input/filter/message/fletcher16.cc index 3c16b34f..b3552cc9 100644 --- a/srecord/input/filter/message/fletcher16.cc +++ b/srecord/input/filter/message/fletcher16.cc @@ -23,7 +23,7 @@ srecord::input_filter_message_fletcher16::input_filter_message_fletcher16( const input::pointer &a_deeper, - unsigned long a_address, + uint32_t a_address, endian_t a_end ) : input_filter_message(a_deeper), @@ -35,7 +35,7 @@ srecord::input_filter_message_fletcher16::input_filter_message_fletcher16( srecord::input::pointer srecord::input_filter_message_fletcher16::create( - const input::pointer &a_deeper, unsigned long a_address, + const input::pointer &a_deeper, uint32_t a_address, endian_t a_end) { return @@ -73,12 +73,12 @@ srecord::input_filter_message_fletcher16::process(const memory &input, memory_walker_fletcher16::pointer w = memory_walker_fletcher16::create(sum1, sum2, answer, end); input.walk(w); - unsigned short fletcher = w->get(); + uint16_t fletcher = w->get(); // // Turn the Fletcher-16 checksum into the first data record. // - unsigned char chunk[2]; + uint8_t chunk[2]; record::encode(chunk, fletcher, sizeof(chunk), end); output = record(record::type_data, address, chunk, sizeof(chunk)); } diff --git a/srecord/input/filter/message/fletcher16.h b/srecord/input/filter/message/fletcher16.h index 1758df9a..b98d0931 100644 --- a/srecord/input/filter/message/fletcher16.h +++ b/srecord/input/filter/message/fletcher16.h @@ -52,7 +52,7 @@ class input_filter_message_fletcher16: * The byte order. */ input_filter_message_fletcher16(const input::pointer &deeper, - unsigned long address, endian_t end); + uint32_t address, endian_t end); public: /** @@ -66,7 +66,7 @@ class input_filter_message_fletcher16: * @param end * The byte order. */ - static pointer create(const input::pointer &deeper, unsigned long address, + static pointer create(const input::pointer &deeper, uint32_t address, endian_t end); protected: @@ -84,7 +84,7 @@ class input_filter_message_fletcher16: * The address instance variable is used to remember where to place * the Fletcher 16 checksum in memory. */ - unsigned long address; + uint32_t address; /** * The end instance variable is used to remember whether the byte @@ -92,9 +92,9 @@ class input_filter_message_fletcher16: */ endian_t end; - unsigned char sum1{0xFF}; + uint8_t sum1{0xFF}; - unsigned char sum2{0xFF}; + uint8_t sum2{0xFF}; int answer{-1}; diff --git a/srecord/input/filter/message/fletcher32.cc b/srecord/input/filter/message/fletcher32.cc index bd22abb8..73607370 100644 --- a/srecord/input/filter/message/fletcher32.cc +++ b/srecord/input/filter/message/fletcher32.cc @@ -23,7 +23,7 @@ srecord::input_filter_message_fletcher32::input_filter_message_fletcher32( const input::pointer &a_deeper, - unsigned long a_address, + uint32_t a_address, endian_t a_end ) : input_filter_message(a_deeper), @@ -35,7 +35,7 @@ srecord::input_filter_message_fletcher32::input_filter_message_fletcher32( srecord::input::pointer srecord::input_filter_message_fletcher32::create( - const input::pointer &a_deeper, unsigned long a_address, + const input::pointer &a_deeper, uint32_t a_address, endian_t a_end) { return @@ -58,12 +58,12 @@ srecord::input_filter_message_fletcher32::process(const memory &input, memory_walker_fletcher32::pointer w = memory_walker_fletcher32::create(); input.walk(w); - unsigned long fletcher = w->get(); + uint32_t fletcher = w->get(); // // Turn the CRC into the first data record. // - unsigned char chunk[4]; + uint8_t chunk[4]; record::encode(chunk, fletcher, sizeof(chunk), end); output = record(record::type_data, address, chunk, sizeof(chunk)); } diff --git a/srecord/input/filter/message/fletcher32.h b/srecord/input/filter/message/fletcher32.h index bfee9493..8826825b 100644 --- a/srecord/input/filter/message/fletcher32.h +++ b/srecord/input/filter/message/fletcher32.h @@ -52,7 +52,7 @@ class input_filter_message_fletcher32: * The byte order. */ input_filter_message_fletcher32(const input::pointer &deeper, - unsigned long address, endian_t end); + uint32_t address, endian_t end); public: /** @@ -66,7 +66,7 @@ class input_filter_message_fletcher32: * @param end * The byte order. */ - static pointer create(const input::pointer &deeper, unsigned long address, + static pointer create(const input::pointer &deeper, uint32_t address, endian_t end); protected: @@ -81,7 +81,7 @@ class input_filter_message_fletcher32: * The address instance variable is used to remember where to place * the Fletcher 32 checksum in memory. */ - unsigned long address; + uint32_t address; /** * The end instance variable is used to remember whether the byte diff --git a/srecord/input/filter/message/gcrypt.cc b/srecord/input/filter/message/gcrypt.cc index b57cbfbc..263977b0 100644 --- a/srecord/input/filter/message/gcrypt.cc +++ b/srecord/input/filter/message/gcrypt.cc @@ -24,7 +24,7 @@ srecord::input_filter_message_gcrypt::input_filter_message_gcrypt( const input::pointer &a_deeper, - unsigned long a_address, + uint32_t a_address, int a_algo, bool a_hmac ) : @@ -38,7 +38,7 @@ srecord::input_filter_message_gcrypt::input_filter_message_gcrypt( srecord::input::pointer srecord::input_filter_message_gcrypt::create(const input::pointer &a_deeper, - unsigned long a_address, int algo, bool hmac) + uint32_t a_address, int algo, bool hmac) { return pointer @@ -56,7 +56,7 @@ srecord::input_filter_message_gcrypt::create(const input::pointer &a_deeper, srecord::input::pointer srecord::input_filter_message_gcrypt::create(const input::pointer &a_deeper, - unsigned long a_address, const char *name, bool a_hmac) + uint32_t a_address, const char *name, bool a_hmac) { return create(a_deeper, a_address, algorithm_from_name(name), a_hmac); } @@ -64,7 +64,7 @@ srecord::input_filter_message_gcrypt::create(const input::pointer &a_deeper, srecord::input::pointer srecord::input_filter_message_gcrypt::create_md5( - const input::pointer &a_deeper, unsigned long a_address) + const input::pointer &a_deeper, uint32_t a_address) { #ifdef HAVE_LIBGCRYPT return create(a_deeper, a_address, GCRY_MD_MD5); @@ -79,7 +79,7 @@ srecord::input_filter_message_gcrypt::create_md5( srecord::input::pointer srecord::input_filter_message_gcrypt::create_sha1( - const input::pointer &a_deeper, unsigned long a_address) + const input::pointer &a_deeper, uint32_t a_address) { #ifdef HAVE_LIBGCRYPT return create(a_deeper, a_address, GCRY_MD_SHA1); @@ -94,7 +94,7 @@ srecord::input_filter_message_gcrypt::create_sha1( srecord::input::pointer srecord::input_filter_message_gcrypt::create_rmd160( - const input::pointer &a_deeper, unsigned long a_address) + const input::pointer &a_deeper, uint32_t a_address) { #ifdef HAVE_LIBGCRYPT return create(a_deeper, a_address, GCRY_MD_RMD160); @@ -109,7 +109,7 @@ srecord::input_filter_message_gcrypt::create_rmd160( srecord::input::pointer srecord::input_filter_message_gcrypt::create_md2( - const input::pointer &a_deeper, unsigned long a_address) + const input::pointer &a_deeper, uint32_t a_address) { #ifdef HAVE_LIBGCRYPT return create(a_deeper, a_address, GCRY_MD_MD2); @@ -124,7 +124,7 @@ srecord::input_filter_message_gcrypt::create_md2( srecord::input::pointer srecord::input_filter_message_gcrypt::create_tiger( - const input::pointer &a_deeper, unsigned long a_address) + const input::pointer &a_deeper, uint32_t a_address) { #ifdef HAVE_LIBGCRYPT return create(a_deeper, a_address, GCRY_MD_TIGER); @@ -139,7 +139,7 @@ srecord::input_filter_message_gcrypt::create_tiger( srecord::input::pointer srecord::input_filter_message_gcrypt::create_haval( - const input::pointer &a_deeper, unsigned long a_address) + const input::pointer &a_deeper, uint32_t a_address) { #ifdef HAVE_LIBGCRYPT return create(a_deeper, a_address, GCRY_MD_HAVAL); @@ -154,7 +154,7 @@ srecord::input_filter_message_gcrypt::create_haval( srecord::input::pointer srecord::input_filter_message_gcrypt::create_sha256( - const input::pointer &a_deeper, unsigned long a_address) + const input::pointer &a_deeper, uint32_t a_address) { #ifdef HAVE_LIBGCRYPT return create(a_deeper, a_address, GCRY_MD_SHA256); @@ -169,7 +169,7 @@ srecord::input_filter_message_gcrypt::create_sha256( srecord::input::pointer srecord::input_filter_message_gcrypt::create_sha384( - const input::pointer &a_deeper, unsigned long a_address) + const input::pointer &a_deeper, uint32_t a_address) { #ifdef HAVE_LIBGCRYPT return create(a_deeper, a_address, GCRY_MD_SHA384); @@ -184,7 +184,7 @@ srecord::input_filter_message_gcrypt::create_sha384( srecord::input::pointer srecord::input_filter_message_gcrypt::create_sha512( - const input::pointer &a_deeper, unsigned long a_address) + const input::pointer &a_deeper, uint32_t a_address) { #ifdef HAVE_LIBGCRYPT return create(a_deeper, a_address, GCRY_MD_SHA512); @@ -199,7 +199,7 @@ srecord::input_filter_message_gcrypt::create_sha512( srecord::input::pointer srecord::input_filter_message_gcrypt::create_sha224( - const input::pointer &a_deeper, unsigned long a_address) + const input::pointer &a_deeper, uint32_t a_address) { #ifdef HAVE_LIBGCRYPT_SHA224 return create(a_deeper, a_address, GCRY_MD_SHA224); @@ -214,7 +214,7 @@ srecord::input_filter_message_gcrypt::create_sha224( srecord::input::pointer srecord::input_filter_message_gcrypt::create_md4( - const input::pointer &a_deeper, unsigned long a_address) + const input::pointer &a_deeper, uint32_t a_address) { #ifdef HAVE_LIBGCRYPT return create(a_deeper, a_address, GCRY_MD_MD4); @@ -229,7 +229,7 @@ srecord::input_filter_message_gcrypt::create_md4( srecord::input::pointer srecord::input_filter_message_gcrypt::create_crc32( - const srecord::input::pointer &a_deeper, unsigned long a_address) + const srecord::input::pointer &a_deeper, uint32_t a_address) { #ifdef HAVE_LIBGCRYPT return create(a_deeper, a_address, GCRY_MD_CRC32); @@ -244,7 +244,7 @@ srecord::input_filter_message_gcrypt::create_crc32( srecord::input::pointer srecord::input_filter_message_gcrypt::create_crc32_rfc1510( - const input::pointer &a_deeper, unsigned long a_address) + const input::pointer &a_deeper, uint32_t a_address) { #ifdef HAVE_LIBGCRYPT return create(a_deeper, a_address, GCRY_MD_CRC32_RFC1510); @@ -259,7 +259,7 @@ srecord::input_filter_message_gcrypt::create_crc32_rfc1510( srecord::input::pointer srecord::input_filter_message_gcrypt::create_crc24_rfc2440( - const input::pointer &a_deeper, unsigned long a_address) + const input::pointer &a_deeper, uint32_t a_address) { #ifdef HAVE_LIBGCRYPT return create(a_deeper, a_address, GCRY_MD_CRC24_RFC2440); @@ -274,7 +274,7 @@ srecord::input_filter_message_gcrypt::create_crc24_rfc2440( srecord::input::pointer srecord::input_filter_message_gcrypt::create_whirlpool( - const input::pointer &a_deeper, unsigned long a_address) + const input::pointer &a_deeper, uint32_t a_address) { #ifdef HAVE_LIBGCRYPT_WHIRLPOOL return create(a_deeper, a_address, GCRY_MD_WHIRLPOOL); @@ -345,7 +345,7 @@ srecord::input_filter_message_gcrypt::process(const memory &input, input.walk(w); // generate the result - const unsigned char *data = gcry_md_read(handle, algo); + const uint8_t *data = gcry_md_read(handle, algo); size_t data_size = gcry_md_get_algo_dlen(algo); output = record(record::type_data, address, data, data_size); @@ -359,7 +359,7 @@ srecord::input_filter_message_gcrypt::process(const memory &input, ( record::type_data, address, - (const unsigned char *)"oops", + (const uint8_t *)"oops", 4 ); #endif diff --git a/srecord/input/filter/message/gcrypt.h b/srecord/input/filter/message/gcrypt.h index 4da6c7c6..75a946e3 100644 --- a/srecord/input/filter/message/gcrypt.h +++ b/srecord/input/filter/message/gcrypt.h @@ -58,7 +58,7 @@ class input_filter_message_gcrypt: * Add a message authentication code */ input_filter_message_gcrypt(const input::pointer &deeper, - unsigned long address, int algo, bool hmac); + uint32_t address, int algo, bool hmac); /** @@ -76,7 +76,7 @@ class input_filter_message_gcrypt: * @param hmac * Add a message authentication code */ - static pointer create(const input::pointer &deeper, unsigned long address, + static pointer create(const input::pointer &deeper, uint32_t address, int algo, bool hmac = false); /** @@ -106,7 +106,7 @@ class input_filter_message_gcrypt: * @param hmac * Turn the hash into a HMAC. */ - static pointer create(const input::pointer &deeper, unsigned long address, + static pointer create(const input::pointer &deeper, uint32_t address, const char *algo, bool hmac = false); /** @@ -119,7 +119,7 @@ class input_filter_message_gcrypt: * Where to place the hash in memory. */ static pointer create_md5(const input::pointer &deeper, - unsigned long address); + uint32_t address); /** * The create_sha1 class method is used to create a new dynamically @@ -131,7 +131,7 @@ class input_filter_message_gcrypt: * Where to place the hash in memory. */ static pointer create_sha1(const input::pointer &deeper, - unsigned long address); + uint32_t address); /** * The create_rmd160 class method is used to create a new dynamically @@ -143,7 +143,7 @@ class input_filter_message_gcrypt: * Where to place the hash in memory. */ static pointer create_rmd160(const input::pointer &deeper, - unsigned long address); + uint32_t address); /** * The create_md2 class method is used to create a new dynamically @@ -155,7 +155,7 @@ class input_filter_message_gcrypt: * Where to place the hash in memory. */ static pointer create_md2(const input::pointer &deeper, - unsigned long address); + uint32_t address); /** * The create_tiger class method is used to create a new dynamically @@ -167,7 +167,7 @@ class input_filter_message_gcrypt: * Where to place the hash in memory. */ static pointer create_tiger(const input::pointer &deeper, - unsigned long address); + uint32_t address); /** * The create_haval class method is used to create a new dynamically @@ -179,7 +179,7 @@ class input_filter_message_gcrypt: * Where to place the hash in memory. */ static pointer create_haval(const input::pointer &deeper, - unsigned long address); + uint32_t address); /** * The create_sha256 class method is used to create a new dynamically @@ -191,7 +191,7 @@ class input_filter_message_gcrypt: * Where to place the hash in memory. */ static pointer create_sha256(const input::pointer &deeper, - unsigned long address); + uint32_t address); /** * The create_sha384 class method is used to create a new dynamically @@ -203,7 +203,7 @@ class input_filter_message_gcrypt: * Where to place the hash in memory. */ static pointer create_sha384(const input::pointer &deeper, - unsigned long address); + uint32_t address); /** * The create_sha512 class method is used to create a new dynamically @@ -215,7 +215,7 @@ class input_filter_message_gcrypt: * Where to place the hash in memory. */ static pointer create_sha512(const input::pointer &deeper, - unsigned long address); + uint32_t address); /** * The create_sha224 class method is used to create a new dynamically @@ -227,7 +227,7 @@ class input_filter_message_gcrypt: * Where to place the hash in memory. */ static pointer create_sha224(const input::pointer &deeper, - unsigned long address); + uint32_t address); /** * The create_md4 class method is used to create a new dynamically @@ -239,7 +239,7 @@ class input_filter_message_gcrypt: * Where to place the hash in memory. */ static pointer create_md4(const input::pointer &deeper, - unsigned long address); + uint32_t address); /** * The create_crc32 class method is used to create a new dynamically @@ -251,7 +251,7 @@ class input_filter_message_gcrypt: * Where to place the hash in memory. */ static pointer create_crc32(const input::pointer &deeper, - unsigned long address); + uint32_t address); /** * The create_crc32_rfc1510 class method is used to create a new @@ -264,7 +264,7 @@ class input_filter_message_gcrypt: * Where to place the hash in memory. */ static pointer create_crc32_rfc1510(const input::pointer &deeper, - unsigned long address); + uint32_t address); /** * The create_crc24_rfc2440 class method is used to create a new @@ -277,7 +277,7 @@ class input_filter_message_gcrypt: * Where to place the hash in memory. */ static pointer create_crc24_rfc2440(const input::pointer &deeper, - unsigned long address); + uint32_t address); /** * The create_whirlpool class method is used to create a new @@ -290,7 +290,7 @@ class input_filter_message_gcrypt: * Where to place the hash in memory. */ static pointer create_whirlpool(const input::pointer &deeper, - unsigned long address); + uint32_t address); protected: // See base class for documentation. @@ -316,7 +316,7 @@ class input_filter_message_gcrypt: * The address instance variable is used to remember where to place * the hash in memory. */ - unsigned long address; + uint32_t address; public: /** diff --git a/srecord/input/filter/message/stm32.cc b/srecord/input/filter/message/stm32.cc index 75e5db6e..4750373b 100644 --- a/srecord/input/filter/message/stm32.cc +++ b/srecord/input/filter/message/stm32.cc @@ -33,7 +33,7 @@ srecord::input_filter_message_stm32::input_filter_message_stm32( const input::pointer &a_deeper, - unsigned long a_address, + uint32_t a_address, endian_t a_end ) : input_filter_message(a_deeper), @@ -45,7 +45,7 @@ srecord::input_filter_message_stm32::input_filter_message_stm32( srecord::input::pointer srecord::input_filter_message_stm32::create(const input::pointer &a_deeper, - unsigned long a_address, endian_t a_end) + uint32_t a_address, endian_t a_end) { return pointer @@ -71,12 +71,12 @@ srecord::input_filter_message_stm32::process(const memory &input, // memory_walker_stm32::pointer w = memory_walker_stm32::create(); input.walk(w); - unsigned long crc = w->get(); + uint32_t crc = w->get(); // // Turn the CRC into the first data record. // - unsigned char chunk[4]; + uint8_t chunk[4]; record::encode(chunk, crc, sizeof(chunk), end); output = record(record::type_data, address, chunk, sizeof(chunk)); } diff --git a/srecord/input/filter/message/stm32.h b/srecord/input/filter/message/stm32.h index 2a020d82..28f2200c 100644 --- a/srecord/input/filter/message/stm32.h +++ b/srecord/input/filter/message/stm32.h @@ -61,7 +61,7 @@ class input_filter_message_stm32: * The byte order. */ input_filter_message_stm32(const input::pointer &deeper, - unsigned long address, endian_t end); + uint32_t address, endian_t end); public: /** @@ -75,7 +75,7 @@ class input_filter_message_stm32: * @param end * The byte order. */ - static pointer create(const input::pointer &deeper, unsigned long address, + static pointer create(const input::pointer &deeper, uint32_t address, endian_t end); protected: @@ -96,7 +96,7 @@ class input_filter_message_stm32: * The address instance variable is used to remember where to place * the CRC in memory. */ - unsigned long address; + uint32_t address; /** * The end instance variable is used to remember whether the byte diff --git a/srecord/input/filter/random_fill.cc b/srecord/input/filter/random_fill.cc index f023926b..145e9e64 100644 --- a/srecord/input/filter/random_fill.cc +++ b/srecord/input/filter/random_fill.cc @@ -44,7 +44,7 @@ srecord::input_filter_random_fill::generate(srecord::record &record) { if (range.empty()) return false; - unsigned char buffer[srecord::record::max_data_length]; + uint8_t buffer[srecord::record::max_data_length]; interval::data_t lo = range.get_lowest(); interval::data_t hi = lo + sizeof(buffer); if (hi < lo) diff --git a/srecord/input/filter/sequence.cc b/srecord/input/filter/sequence.cc index 333a546c..2c8aefba 100644 --- a/srecord/input/filter/sequence.cc +++ b/srecord/input/filter/sequence.cc @@ -43,7 +43,7 @@ srecord::input_filter_sequence::read(srecord::record &record) if (record.get_type() == srecord::record::type_data) { #if 0 - fprintf(stderr, "%s: %d: address = %08lX, length = %08X\n", + fprintf(stderr, "%s: %d: address = %08X, length = %08X\n", __FILE__, __LINE__, record.get_address(), record.get_length() @@ -60,7 +60,7 @@ srecord::input_filter_sequence::read(srecord::record &record) warning ( "data records not in strictly ascending order " - "(expected >= 0x%04lX, got 0x%04lX)", + "(expected >= 0x%04X, got 0x%04lX)", last_address, long(record.get_address()) ); diff --git a/srecord/input/filter/sequence.h b/srecord/input/filter/sequence.h index cc8f1d0c..8a330b48 100644 --- a/srecord/input/filter/sequence.h +++ b/srecord/input/filter/sequence.h @@ -63,7 +63,7 @@ class input_filter_sequence: * addresses less than this cause an "out of sequence" warning. * It is check and updated by the read() method. */ - unsigned long last_address{0}; + uint32_t last_address{0}; /** * The warned instance variable is used to remember whether or not diff --git a/srecord/input/filter/split.cc b/srecord/input/filter/split.cc index 9025197a..46eb7f7b 100644 --- a/srecord/input/filter/split.cc +++ b/srecord/input/filter/split.cc @@ -71,7 +71,7 @@ srecord::input_filter_split::read(srecord::record &record) srecord::record::address_t phase = addr % modulus; if (phase < width) { - unsigned char c = buffer.get_data(buffer_pos++); + uint8_t c = buffer.get_data(buffer_pos++); // // Because the offset was made positive by // subtracting it from the modulus (to avoid diff --git a/srecord/input/filter/unfill.cc b/srecord/input/filter/unfill.cc index 8cc9569f..651fd9c5 100644 --- a/srecord/input/filter/unfill.cc +++ b/srecord/input/filter/unfill.cc @@ -60,8 +60,8 @@ srecord::input_filter_unfill::read(srecord::record &record) } int first_pos = buffer_pos; - unsigned long addr = buffer.get_address() + buffer_pos; - unsigned char c = buffer.get_data(buffer_pos++); + uint32_t addr = buffer.get_address() + buffer_pos; + uint8_t c = buffer.get_data(buffer_pos++); if (c == fill_value) { // diff --git a/srecord/input/filter/unsplit.cc b/srecord/input/filter/unsplit.cc index 32b952eb..7a2d1510 100644 --- a/srecord/input/filter/unsplit.cc +++ b/srecord/input/filter/unsplit.cc @@ -60,8 +60,8 @@ srecord::input_filter_unsplit::read(srecord::record &record) buffer_pos = 0; } - unsigned long addr = buffer.get_address() + buffer_pos; - unsigned char c = buffer.get_data(buffer_pos++); + uint32_t addr = buffer.get_address() + buffer_pos; + uint8_t c = buffer.get_data(buffer_pos++); int phase = addr % width; addr = (addr / width) * modulus + phase + offset; record = srecord::record(srecord::record::type_data, addr, &c, 1); diff --git a/srecord/input/generator.cc b/srecord/input/generator.cc index 8f37b5db..9f2ab597 100644 --- a/srecord/input/generator.cc +++ b/srecord/input/generator.cc @@ -94,7 +94,7 @@ srecord::input_generator::create(srecord::arglex_tool *cmdln) case srecord::arglex_tool::token_constant_be: { cmdln->token_next(); - unsigned long datum = + uint32_t datum = cmdln->get_number("--generate --b-e-constant "); int length = cmdln->get_number("--generate --b-e-constant "); @@ -106,17 +106,17 @@ srecord::input_generator::create(srecord::arglex_tool *cmdln) length ); } - unsigned long over = (1UL << (8U * length)) - 1; + uint32_t over = (1UL << (8U * length)) - 1; if (length < 4 && datum > over) { cmdln->fatal_error ( - "datum %lu out of range [0..%lu]", + "datum %u out of range [0..%u]", datum, over ); } - unsigned char data[4]; + uint8_t data[4]; data[3] = datum; data[2] = datum >> 8; data[1] = datum >> 16; @@ -134,7 +134,7 @@ srecord::input_generator::create(srecord::arglex_tool *cmdln) case srecord::arglex_tool::token_constant_le: { cmdln->token_next(); - unsigned long datum = + uint32_t datum = cmdln->get_number("--generate --l-e-constant "); int length = cmdln->get_number("--generate --l-e-constant "); @@ -146,17 +146,17 @@ srecord::input_generator::create(srecord::arglex_tool *cmdln) length ); } - unsigned long over = (1UL << (8U * length)) - 1; + uint32_t over = (1UL << (8U * length)) - 1; if (length < 4 && datum > over) { cmdln->fatal_error ( - "datum %lu out of range [0..%lu]", + "datum %u out of range [0..%u]", datum, over ); } - unsigned char data[4]; + uint8_t data[4]; data[0] = datum; data[1] = datum >> 8; data[2] = datum >> 16; @@ -193,7 +193,7 @@ srecord::input_generator::create(srecord::arglex_tool *cmdln) cmdln->token_next(); size_t length = 0; size_t maxlen = 16; - auto *data = new unsigned char [maxlen]; + auto *data = new uint8_t [maxlen]; for (;;) { // @@ -208,7 +208,7 @@ srecord::input_generator::create(srecord::arglex_tool *cmdln) if (length >= maxlen) { size_t new_maxlen = maxlen * 2 + 16; - auto *new_data = new unsigned char [new_maxlen]; + auto *new_data = new uint8_t [new_maxlen]; memcpy(new_data, data, length); delete [] data; data = new_data; @@ -276,7 +276,7 @@ srecord::input_generator::create(srecord::arglex_tool *cmdln) srecord::input_generator_repeat::create ( range, - (unsigned char *)s.c_str(), + (uint8_t *)s.c_str(), s.size() ); break; diff --git a/srecord/input/generator.h b/srecord/input/generator.h index 167382a9..d40e7d86 100644 --- a/srecord/input/generator.h +++ b/srecord/input/generator.h @@ -72,7 +72,7 @@ class input_generator: * @returns * one byte of data */ - virtual unsigned char generate_data(unsigned long address) = 0; + virtual uint8_t generate_data(uint32_t address) = 0; private: /** diff --git a/srecord/input/generator/constant.cc b/srecord/input/generator/constant.cc index b5461959..717f5ba4 100644 --- a/srecord/input/generator/constant.cc +++ b/srecord/input/generator/constant.cc @@ -22,7 +22,7 @@ #include srecord::input_generator_constant::input_generator_constant( - const interval &a_range, unsigned char a_datum) : + const interval &a_range, uint8_t a_datum) : srecord::input_generator(a_range), datum(a_datum) { @@ -31,14 +31,14 @@ srecord::input_generator_constant::input_generator_constant( srecord::input::pointer srecord::input_generator_constant::create(const interval &a_range, - unsigned char a_datum) + uint8_t a_datum) { return pointer(new srecord::input_generator_constant(a_range, a_datum)); } -unsigned char -srecord::input_generator_constant::generate_data(unsigned long) +uint8_t +srecord::input_generator_constant::generate_data(uint32_t) { return datum; } diff --git a/srecord/input/generator/constant.h b/srecord/input/generator/constant.h index 72c8cda5..5d496c0b 100644 --- a/srecord/input/generator/constant.h +++ b/srecord/input/generator/constant.h @@ -42,14 +42,14 @@ class input_generator_constant: /** * The constructor. */ - input_generator_constant(const interval &range, unsigned char datum); + input_generator_constant(const interval &range, uint8_t datum); public: /** * The create class method is used to create new dynamically * allocated instances of this class. */ - static pointer create(const interval &range, unsigned char datum); + static pointer create(const interval &range, uint8_t datum); protected: // See base class for documentation. @@ -59,14 +59,14 @@ class input_generator_constant: const char *get_file_format_name() const override; // See base class for documentation. - unsigned char generate_data(unsigned long address) override; + uint8_t generate_data(uint32_t address) override; private: /** * The datum instance variable is used to remember the constant * byte value to be generated. */ - unsigned char datum; + uint8_t datum; public: /** diff --git a/srecord/input/generator/random.cc b/srecord/input/generator/random.cc index 6fa63f3c..b916dff6 100644 --- a/srecord/input/generator/random.cc +++ b/srecord/input/generator/random.cc @@ -35,8 +35,8 @@ srecord::input_generator_random::create(const interval &a_range) } -unsigned char -srecord::input_generator_random::generate_data(unsigned long) +uint8_t +srecord::input_generator_random::generate_data(uint32_t) { return r250(); } diff --git a/srecord/input/generator/random.h b/srecord/input/generator/random.h index a4aa0ce4..a6a181d0 100644 --- a/srecord/input/generator/random.h +++ b/srecord/input/generator/random.h @@ -59,7 +59,7 @@ class input_generator_random: const char *get_file_format_name() const override; // See base class for documentation. - unsigned char generate_data(unsigned long address) override; + uint8_t generate_data(uint32_t address) override; public: /** diff --git a/srecord/input/generator/repeat.cc b/srecord/input/generator/repeat.cc index c9e2205e..649db79e 100644 --- a/srecord/input/generator/repeat.cc +++ b/srecord/input/generator/repeat.cc @@ -27,14 +27,14 @@ srecord::input_generator_repeat::~input_generator_repeat() srecord::input_generator_repeat::input_generator_repeat( - const interval &a_range, const unsigned char *a_data, size_t a_length) : + const interval &a_range, const uint8_t *a_data, size_t a_length) : srecord::input_generator(a_range), address(a_range.get_lowest()), data(0), length(a_length) { // assert(length > 0); - data = new unsigned char [length]; + data = new uint8_t [length]; for (size_t j = 0; j < length; ++j) data[j] = a_data[j]; } @@ -42,15 +42,15 @@ srecord::input_generator_repeat::input_generator_repeat( srecord::input::pointer srecord::input_generator_repeat::create(const interval &a_range, - unsigned char *a_data, size_t a_length) + uint8_t *a_data, size_t a_length) { return pointer(new srecord::input_generator_repeat(a_range, a_data, a_length)); } -unsigned char -srecord::input_generator_repeat::generate_data(unsigned long addr) +uint8_t +srecord::input_generator_repeat::generate_data(uint32_t addr) { return data[(addr - address) % length]; } diff --git a/srecord/input/generator/repeat.h b/srecord/input/generator/repeat.h index 96aed992..2c370ed2 100644 --- a/srecord/input/generator/repeat.h +++ b/srecord/input/generator/repeat.h @@ -49,7 +49,7 @@ class input_generator_repeat: * @param length * The length of the array of data to be repeated. */ - input_generator_repeat(const interval &range, const unsigned char *data, + input_generator_repeat(const interval &range, const uint8_t *data, size_t length); public: @@ -64,12 +64,12 @@ class input_generator_repeat: * @param length * The length of the array of data to be repeated. */ - static pointer create(const interval &range, unsigned char *data, + static pointer create(const interval &range, uint8_t *data, size_t length); protected: // See base class for documentation. - unsigned char generate_data(unsigned long address) override; + uint8_t generate_data(uint32_t address) override; // See base class for documentation. std::string filename() const override; @@ -83,13 +83,13 @@ class input_generator_repeat: * the generated data, so that modulo arithmetic will align the * data repeats. */ - unsigned long address; + uint32_t address; /** * The data instance variable is used to remember the base of a * dynamically allocated array of data to be repeated. */ - unsigned char *data; + uint8_t *data; /** * The length instance variable is used to remember the length of diff --git a/srecord/interval.cc b/srecord/interval.cc index 3a2beac5..d0195820 100644 --- a/srecord/interval.cc +++ b/srecord/interval.cc @@ -770,7 +770,7 @@ to_string(srecord::interval::data_t x) if (x >= 0x1000000) width += 2; char buffer[20]; - snprintf(buffer, sizeof(buffer), "0x%0*lX", width, (unsigned long)x); + snprintf(buffer, sizeof(buffer), "0x%0*X", width, (uint32_t)x); return buffer; } diff --git a/srecord/memory.cc b/srecord/memory.cc index 2ddf107b..af844bc8 100644 --- a/srecord/memory.cc +++ b/srecord/memory.cc @@ -98,7 +98,7 @@ srecord::memory::copy(const srecord::memory &rhs) srecord::memory_chunk * -srecord::memory::find(unsigned long address) +srecord::memory::find(uint32_t address) const { // @@ -156,32 +156,32 @@ srecord::memory::find(unsigned long address) void -srecord::memory::set(unsigned long address, int datum) +srecord::memory::set(uint32_t address, int datum) { - unsigned long address_hi = address / srecord::memory_chunk::size; - unsigned long address_lo = address % srecord::memory_chunk::size; + uint32_t address_hi = address / srecord::memory_chunk::size; + uint32_t address_lo = address % srecord::memory_chunk::size; srecord::memory_chunk *mcp = find(address_hi); mcp->set(address_lo, datum); } int -srecord::memory::get(unsigned long address) +srecord::memory::get(uint32_t address) const { - unsigned long address_hi = address / srecord::memory_chunk::size; - unsigned long address_lo = address % srecord::memory_chunk::size; + uint32_t address_hi = address / srecord::memory_chunk::size; + uint32_t address_lo = address % srecord::memory_chunk::size; srecord::memory_chunk *mcp = find(address_hi); return mcp->get(address_lo); } bool -srecord::memory::set_p(unsigned long address) +srecord::memory::set_p(uint32_t address) const { - unsigned long address_hi = address / srecord::memory_chunk::size; - unsigned long address_lo = address % srecord::memory_chunk::size; + uint32_t address_hi = address / srecord::memory_chunk::size; + uint32_t address_lo = address % srecord::memory_chunk::size; srecord::memory_chunk *mcp = find(address_hi); return mcp->set_p(address_lo); } @@ -215,7 +215,7 @@ srecord::memory::compare(const srecord::memory &lhs, const srecord::memory &rhs) } -unsigned long +uint32_t srecord::memory::get_lower_bound() const { @@ -225,7 +225,7 @@ srecord::memory::get_lower_bound() } -unsigned long +uint32_t srecord::memory::get_upper_bound() const { @@ -375,7 +375,7 @@ operator != (const srecord::memory &lhs, const srecord::memory &rhs) srecord::memory_chunk * -srecord::memory::find_next_chunk(unsigned long address) +srecord::memory::find_next_chunk(uint32_t address) const { // @@ -406,10 +406,10 @@ srecord::memory::find_next_chunk(unsigned long address) bool -srecord::memory::find_next_data(unsigned long &address, void *data, +srecord::memory::find_next_data(uint32_t &address, void *data, size_t &nbytes) const { - unsigned long address_hi = address / srecord::memory_chunk::size; + uint32_t address_hi = address / srecord::memory_chunk::size; for (;;) { srecord::memory_chunk *mcp = find_next_chunk(address_hi); @@ -461,7 +461,7 @@ srecord::memory::get_execution_start_address() void -srecord::memory::set_execution_start_address(unsigned long addr) +srecord::memory::set_execution_start_address(uint32_t addr) { delete execution_start_address; execution_start_address = diff --git a/srecord/memory.h b/srecord/memory.h index 7f0dc7f4..5e15577b 100644 --- a/srecord/memory.h +++ b/srecord/memory.h @@ -67,7 +67,7 @@ class memory * the memory_chunk::set method, to set the byte within * the chunk. */ - void set(unsigned long address, int value); + void set(uint32_t address, int value); /** * The get method is used to fetch the value of the byte at @@ -80,7 +80,7 @@ class memory * the memory_chunk::get method, to get the byte within * the chunk. */ - int get(unsigned long address) const; + int get(uint32_t address) const; /** * The set_p method is used to determine whether the byte at @@ -91,7 +91,7 @@ class memory * the memory_chunk::set_p method, to get the status of * the byte within the chunk. */ - bool set_p(unsigned long address) const; + bool set_p(uint32_t address) const; /** * The walk method is used to apply a memory_walker derived @@ -149,7 +149,7 @@ class memory * * Calls the find_next_chunk() method. */ - bool find_next_data(unsigned long &address, void *data, + bool find_next_data(uint32_t &address, void *data, size_t &nbytes) const; /** @@ -181,7 +181,7 @@ class memory * The set_execution_start_address method may be used to set the * execution start address record. */ - void set_execution_start_address(unsigned long value); + void set_execution_start_address(uint32_t value); /** * The has_holes method may be used to determine whether or not the @@ -198,13 +198,13 @@ class memory * The get_lower_bound method is used to obtain the lower bound * (lowest address) of the memory image. */ - unsigned long get_lower_bound() const; + uint32_t get_lower_bound() const; /** * The get_upper_bound method is used to obtain the upper bound * (maximum address plus one) of the memory image. */ - unsigned long get_upper_bound() const; + uint32_t get_upper_bound() const; /** * The is_well_aligned method is used to test whether or not @@ -259,7 +259,7 @@ class memory * * Called by the get(), set() and set_p() methods. */ - memory_chunk *find(unsigned long address) const; + memory_chunk *find(uint32_t address) const; /** * The cache instance variable is used to accelerate the find() @@ -273,7 +273,7 @@ class memory * byte, in cases where the walk() method is not appropriate. * Called by the find_next_data() method. */ - memory_chunk *find_next_chunk(unsigned long) const; + memory_chunk *find_next_chunk(uint32_t) const; /** * The find_next_chunk_index instance variable is used by diff --git a/srecord/memory/chunk.cc b/srecord/memory/chunk.cc index f232ce6c..b25c004e 100644 --- a/srecord/memory/chunk.cc +++ b/srecord/memory/chunk.cc @@ -23,7 +23,7 @@ #include -srecord::memory_chunk::memory_chunk(unsigned long arg) : +srecord::memory_chunk::memory_chunk(uint32_t arg) : address(arg) { memset(data, 0, sizeof(data)); @@ -53,7 +53,7 @@ srecord::memory_chunk::operator=(const srecord::memory_chunk &arg) void -srecord::memory_chunk::set(unsigned long offset, int datum) +srecord::memory_chunk::set(uint32_t offset, int datum) { data[offset] = datum; mask[offset >> 3] |= (1 << (offset & 7)); @@ -78,7 +78,7 @@ srecord::memory_chunk::walk(srecord::memory_walker::pointer w) bool -srecord::memory_chunk::find_next_data(unsigned long &ret_addr, void *ret_data, +srecord::memory_chunk::find_next_data(uint32_t &ret_addr, void *ret_data, size_t &nbytes) const { @@ -102,14 +102,14 @@ srecord::memory_chunk::find_next_data(unsigned long &ret_addr, void *ret_data, int -srecord::memory_chunk::get(unsigned long offset) +srecord::memory_chunk::get(uint32_t offset) { return data[offset]; } bool -srecord::memory_chunk::set_p(unsigned long offset) +srecord::memory_chunk::set_p(uint32_t offset) const { return (0 != (mask[offset >> 3] & (1 << (offset & 7)))); @@ -131,7 +131,7 @@ srecord::memory_chunk::equal(const srecord::memory_chunk &lhs, } -unsigned long +uint32_t srecord::memory_chunk::get_upper_bound() const { @@ -145,7 +145,7 @@ srecord::memory_chunk::get_upper_bound() } -unsigned long +uint32_t srecord::memory_chunk::get_lower_bound() const { diff --git a/srecord/memory/chunk.h b/srecord/memory/chunk.h index 5d61f052..16f7a6cc 100644 --- a/srecord/memory/chunk.h +++ b/srecord/memory/chunk.h @@ -53,7 +53,7 @@ class memory_chunk /** * The constructor. */ - memory_chunk(unsigned long address); + memory_chunk(uint32_t address); /** * The copy constructor. @@ -74,19 +74,19 @@ class memory_chunk * The set method is used to set the byte at the given offset within * the chunk. */ - void set(unsigned long offset, int value); + void set(uint32_t offset, int value); /** * The get method is used to get the value at the given offset * within the chunk. */ - int get(unsigned long offset); + int get(uint32_t offset); /** * The get_p method is used to determine whether the byte at the * given offset within the chunk contains valid data. */ - bool set_p(unsigned long) const; + bool set_p(uint32_t) const; /** * The walk method is used to iterate across all of the bytes which @@ -99,7 +99,7 @@ class memory_chunk * chunk. This is NOT the address of the first byte, it is the * chunk number. To calculate the byte address, multiply by size. */ - unsigned long get_address() const { return address; } + uint32_t get_address() const { return address; } /** * The equal class method is used to determine whether two memory @@ -112,21 +112,21 @@ class memory_chunk * The find_next_data method is used when iterating across all of * the bytes set within the chunk. */ - bool find_next_data(unsigned long &, void *, size_t &) const; + bool find_next_data(uint32_t &, void *, size_t &) const; /** * The get_upper_bound method is used to determine the upper bound * (offset of last byte with valid data, plus one) of the chunk. * It returns a memory byte address, NOT the chunk offset. */ - unsigned long get_upper_bound() const; + uint32_t get_upper_bound() const; /** * The get_lower_bound method is used to determine the lower bound * (offset of first byte with valid data) of the chunk. * It returns a memory byte address, NOT the chunk offset. */ - unsigned long get_lower_bound() const; + uint32_t get_lower_bound() const; private: /** @@ -134,18 +134,18 @@ class memory_chunk * the first byte, it is the chunk number. To calculate the byte * address, multiply by size. */ - unsigned long address; + uint32_t address; /** * The data array is used to remember the values of valid data bytes. */ - unsigned char data[size]{}; + uint8_t data[size]{}; /** * The mask array is used to remember which values in the data * array contain valid values. */ - unsigned char mask[(size + 7) / 8]{}; + uint8_t mask[(size + 7) / 8]{}; public: /** diff --git a/srecord/memory/walker.cc b/srecord/memory/walker.cc index fc77fa50..ad23c557 100644 --- a/srecord/memory/walker.cc +++ b/srecord/memory/walker.cc @@ -22,7 +22,7 @@ void -srecord::memory_walker::notify_upper_bound(unsigned long) +srecord::memory_walker::notify_upper_bound(uint32_t) { // Do nothing. } diff --git a/srecord/memory/walker.h b/srecord/memory/walker.h index 08a2e0ed..de3d0a1e 100644 --- a/srecord/memory/walker.h +++ b/srecord/memory/walker.h @@ -52,7 +52,7 @@ class memory_walker * @param data_size * The size, in bytes, of this chunk of memory. */ - virtual void observe(unsigned long address, const void *data, + virtual void observe(uint32_t address, const void *data, int data_size) = 0; /** @@ -70,7 +70,7 @@ class memory_walker * @param address * The address of the byte immediately beyond the used memory. */ - virtual void notify_upper_bound(unsigned long address); + virtual void notify_upper_bound(uint32_t address); /** * The observe_header method is used to inform the walker of the diff --git a/srecord/memory/walker/adler16.cc b/srecord/memory/walker/adler16.cc index 24e6836d..3ace32d1 100644 --- a/srecord/memory/walker/adler16.cc +++ b/srecord/memory/walker/adler16.cc @@ -29,7 +29,7 @@ srecord::memory_walker_adler16::create() void -srecord::memory_walker_adler16::observe(unsigned long, const void *data, +srecord::memory_walker_adler16::observe(uint32_t, const void *data, int length) { checksum.nextbuf(data, length); diff --git a/srecord/memory/walker/adler16.h b/srecord/memory/walker/adler16.h index 3ff36ed6..47527005 100644 --- a/srecord/memory/walker/adler16.h +++ b/srecord/memory/walker/adler16.h @@ -63,7 +63,7 @@ class memory_walker_adler16: protected: // See base class for documentation. - void observe(unsigned long, const void *, int) override; + void observe(uint32_t, const void *, int) override; private: /** diff --git a/srecord/memory/walker/adler32.cc b/srecord/memory/walker/adler32.cc index a29aa223..1f034b2e 100644 --- a/srecord/memory/walker/adler32.cc +++ b/srecord/memory/walker/adler32.cc @@ -29,7 +29,7 @@ srecord::memory_walker_adler32::create() void -srecord::memory_walker_adler32::observe(unsigned long, const void *data, +srecord::memory_walker_adler32::observe(uint32_t, const void *data, int length) { checksum.nextbuf(data, length); diff --git a/srecord/memory/walker/adler32.h b/srecord/memory/walker/adler32.h index c9e13636..4fa75c5a 100644 --- a/srecord/memory/walker/adler32.h +++ b/srecord/memory/walker/adler32.h @@ -63,7 +63,7 @@ class memory_walker_adler32: protected: // See base class for documentation. - void observe(unsigned long, const void *, int) override; + void observe(uint32_t, const void *, int) override; private: /** diff --git a/srecord/memory/walker/alignment.cc b/srecord/memory/walker/alignment.cc index fa8f7f1c..01726c8b 100644 --- a/srecord/memory/walker/alignment.cc +++ b/srecord/memory/walker/alignment.cc @@ -44,7 +44,7 @@ srecord::memory_walker_alignment::is_well_aligned() void -srecord::memory_walker_alignment::observe(unsigned long address, const void *, +srecord::memory_walker_alignment::observe(uint32_t address, const void *, int data_size) { if (data_seen && address != current_address) diff --git a/srecord/memory/walker/alignment.h b/srecord/memory/walker/alignment.h index 81251159..84c17bed 100644 --- a/srecord/memory/walker/alignment.h +++ b/srecord/memory/walker/alignment.h @@ -60,7 +60,7 @@ class memory_walker_alignment: protected: // See base class for documentation. - void observe(unsigned long, const void *, int) override; + void observe(uint32_t, const void *, int) override; // See base class for documentation. void observe_end() override; @@ -76,7 +76,7 @@ class memory_walker_alignment: memory_walker_alignment(unsigned multiple); unsigned multiple{2}; - unsigned long current_address{0}; + uint32_t current_address{0}; bool data_seen{false}; bool well_aligned{true}; diff --git a/srecord/memory/walker/compare.cc b/srecord/memory/walker/compare.cc index 404d6138..6619c4f8 100644 --- a/srecord/memory/walker/compare.cc +++ b/srecord/memory/walker/compare.cc @@ -40,13 +40,13 @@ srecord::memory_walker_compare::create(const srecord::memory &a1, bool a2) void -srecord::memory_walker_compare::observe(unsigned long addr, const void *p, +srecord::memory_walker_compare::observe(uint32_t addr, const void *p, int len) { interval wrongTemp; interval unsetTemp; - auto *data = (unsigned char *)p; + auto *data = (uint8_t *)p; for (int j = 0; j < len; ++j) { if (other.set_p(addr + j)) diff --git a/srecord/memory/walker/compare.h b/srecord/memory/walker/compare.h index d22b3d95..bc2bf4ab 100644 --- a/srecord/memory/walker/compare.h +++ b/srecord/memory/walker/compare.h @@ -77,7 +77,7 @@ class memory_walker_compare: static pointer create(const memory &other, bool check_wrong); // See base class for documentation. - void observe(unsigned long, const void *, int) override; + void observe(uint32_t, const void *, int) override; /** * The print method is used to print the results of the comparison diff --git a/srecord/memory/walker/continuity.cc b/srecord/memory/walker/continuity.cc index c0c4e9e8..695e4634 100644 --- a/srecord/memory/walker/continuity.cc +++ b/srecord/memory/walker/continuity.cc @@ -28,7 +28,7 @@ srecord::memory_walker_continuity::create() void -srecord::memory_walker_continuity::observe(unsigned long addr, const void *, +srecord::memory_walker_continuity::observe(uint32_t addr, const void *, int nbytes) { if (data_seen) diff --git a/srecord/memory/walker/continuity.h b/srecord/memory/walker/continuity.h index 15e38283..34cc9b5e 100644 --- a/srecord/memory/walker/continuity.h +++ b/srecord/memory/walker/continuity.h @@ -66,10 +66,10 @@ class memory_walker_continuity: protected: // See base class for documentation. - void observe(unsigned long, const void *, int) override; + void observe(uint32_t, const void *, int) override; private: - unsigned long current_address{0}; + uint32_t current_address{0}; bool data_seen{false}; int nholes{0}; diff --git a/srecord/memory/walker/crc16.cc b/srecord/memory/walker/crc16.cc index 481bc826..4c274485 100644 --- a/srecord/memory/walker/crc16.cc +++ b/srecord/memory/walker/crc16.cc @@ -28,7 +28,7 @@ srecord::memory_walker_crc16::~memory_walker_crc16() srecord::memory_walker_crc16::memory_walker_crc16(crc16::seed_mode_t seed_mode, - bool augment_flag, unsigned short polynomial, crc16::bit_direction_t bitdir) + bool augment_flag, uint16_t polynomial, crc16::bit_direction_t bitdir) { checksum = new crc16(seed_mode, augment_flag, polynomial, bitdir); } @@ -36,7 +36,7 @@ srecord::memory_walker_crc16::memory_walker_crc16(crc16::seed_mode_t seed_mode, srecord::memory_walker_crc16::pointer srecord::memory_walker_crc16::create(crc16::seed_mode_t arg1, bool a_augment, - unsigned short polynomial, crc16::bit_direction_t a_bitdir) + uint16_t polynomial, crc16::bit_direction_t a_bitdir) { return pointer @@ -53,7 +53,7 @@ srecord::memory_walker_crc16::create(crc16::seed_mode_t arg1, bool a_augment, void -srecord::memory_walker_crc16::observe(unsigned long, const void *data, +srecord::memory_walker_crc16::observe(uint32_t, const void *data, int length) { checksum->nextbuf(data, length); diff --git a/srecord/memory/walker/crc16.h b/srecord/memory/walker/crc16.h index 9733cfeb..aa769fe2 100644 --- a/srecord/memory/walker/crc16.h +++ b/srecord/memory/walker/crc16.h @@ -56,7 +56,7 @@ class memory_walker_crc16: * the bit direction of the CRC. */ memory_walker_crc16(crc16::seed_mode_t seed_mode, bool augment_flag, - unsigned short polynomial, crc16::bit_direction_t bitdir); + uint16_t polynomial, crc16::bit_direction_t bitdir); public: /** @@ -73,7 +73,7 @@ class memory_walker_crc16: * the bit direction of the CRC */ static pointer create(crc16::seed_mode_t seed_mode, bool augment_flag, - unsigned short polynomial, crc16::bit_direction_t bitdir); + uint16_t polynomial, crc16::bit_direction_t bitdir); /** * The get method is used to get the CRC16 checksum once all memory @@ -83,7 +83,7 @@ class memory_walker_crc16: protected: // See base class for documentation. - void observe(unsigned long, const void *, int) override; + void observe(uint32_t, const void *, int) override; private: /** diff --git a/srecord/memory/walker/crc32.cc b/srecord/memory/walker/crc32.cc index f5dcf009..f9058b7c 100644 --- a/srecord/memory/walker/crc32.cc +++ b/srecord/memory/walker/crc32.cc @@ -36,7 +36,7 @@ srecord::memory_walker_crc32::create(crc32::seed_mode_t seed_mode) void -srecord::memory_walker_crc32::observe(unsigned long, const void *data, +srecord::memory_walker_crc32::observe(uint32_t, const void *data, int length) { checksum.nextbuf(data, length); diff --git a/srecord/memory/walker/crc32.h b/srecord/memory/walker/crc32.h index d62fb789..2b93ab87 100644 --- a/srecord/memory/walker/crc32.h +++ b/srecord/memory/walker/crc32.h @@ -69,7 +69,7 @@ class memory_walker_crc32: protected: // See base class for documentation. - void observe(unsigned long, const void *, int) override; + void observe(uint32_t, const void *, int) override; private: /** diff --git a/srecord/memory/walker/fletcher16.cc b/srecord/memory/walker/fletcher16.cc index 5db09325..009bb0a4 100644 --- a/srecord/memory/walker/fletcher16.cc +++ b/srecord/memory/walker/fletcher16.cc @@ -41,7 +41,7 @@ srecord::memory_walker_fletcher16::create(int a_sum1, int a_sum2, void -srecord::memory_walker_fletcher16::observe(unsigned long, const void *data, +srecord::memory_walker_fletcher16::observe(uint32_t, const void *data, int data_size) { checksum.nextbuf(data, data_size); diff --git a/srecord/memory/walker/fletcher16.h b/srecord/memory/walker/fletcher16.h index c7b71b9b..e9114a9b 100644 --- a/srecord/memory/walker/fletcher16.h +++ b/srecord/memory/walker/fletcher16.h @@ -90,7 +90,7 @@ class memory_walker_fletcher16: protected: // See base class for documentation. - void observe(unsigned long address, + void observe(uint32_t address, const void *data, int data_size) override; diff --git a/srecord/memory/walker/fletcher32.cc b/srecord/memory/walker/fletcher32.cc index 8a744569..dacb1c61 100644 --- a/srecord/memory/walker/fletcher32.cc +++ b/srecord/memory/walker/fletcher32.cc @@ -27,7 +27,7 @@ srecord::memory_walker_fletcher32::create() void -srecord::memory_walker_fletcher32::observe(unsigned long, const void *data, +srecord::memory_walker_fletcher32::observe(uint32_t, const void *data, int length) { checksum.nextbuf(data, length); diff --git a/srecord/memory/walker/fletcher32.h b/srecord/memory/walker/fletcher32.h index 0c896daf..911dff50 100644 --- a/srecord/memory/walker/fletcher32.h +++ b/srecord/memory/walker/fletcher32.h @@ -62,7 +62,7 @@ class memory_walker_fletcher32: protected: // See base class for documentation. - void observe(unsigned long, const void *, int) override; + void observe(uint32_t, const void *, int) override; private: /** diff --git a/srecord/memory/walker/gcrypt.cc b/srecord/memory/walker/gcrypt.cc index 249516a8..ba21bd0c 100644 --- a/srecord/memory/walker/gcrypt.cc +++ b/srecord/memory/walker/gcrypt.cc @@ -33,7 +33,7 @@ srecord::memory_walker_gcrypt::create(gcry_md_hd_t a_handle) void -srecord::memory_walker_gcrypt::observe(unsigned long, const void *data, +srecord::memory_walker_gcrypt::observe(uint32_t, const void *data, int length) { #ifdef HAVE_LIBGCRYPT diff --git a/srecord/memory/walker/gcrypt.h b/srecord/memory/walker/gcrypt.h index d8f205a9..682923e0 100644 --- a/srecord/memory/walker/gcrypt.h +++ b/srecord/memory/walker/gcrypt.h @@ -69,7 +69,7 @@ class memory_walker_gcrypt: protected: // See base class for documentation. - void observe(unsigned long, const void *, int) override; + void observe(uint32_t, const void *, int) override; private: /** diff --git a/srecord/memory/walker/stm32.cc b/srecord/memory/walker/stm32.cc index f12d8728..e1ac705c 100644 --- a/srecord/memory/walker/stm32.cc +++ b/srecord/memory/walker/stm32.cc @@ -41,7 +41,7 @@ srecord::memory_walker_stm32::create() void -srecord::memory_walker_stm32::observe(unsigned long, const void *data, +srecord::memory_walker_stm32::observe(uint32_t, const void *data, int length) { checksum.nextbuf(data, length); diff --git a/srecord/memory/walker/stm32.h b/srecord/memory/walker/stm32.h index 687897b2..f9a7ad1c 100644 --- a/srecord/memory/walker/stm32.h +++ b/srecord/memory/walker/stm32.h @@ -68,7 +68,7 @@ class memory_walker_stm32: protected: // See base class for documentation. - void observe(unsigned long, const void *, int) override; + void observe(uint32_t, const void *, int) override; private: /** diff --git a/srecord/memory/walker/writer.cc b/srecord/memory/walker/writer.cc index f30a58a9..32e137ff 100644 --- a/srecord/memory/walker/writer.cc +++ b/srecord/memory/walker/writer.cc @@ -37,14 +37,14 @@ srecord::memory_walker_writer::create(const srecord::output::pointer &arg) void -srecord::memory_walker_writer::notify_upper_bound(unsigned long address) +srecord::memory_walker_writer::notify_upper_bound(uint32_t address) { op->notify_upper_bound(address); } void -srecord::memory_walker_writer::observe(unsigned long address, const void *data, +srecord::memory_walker_writer::observe(uint32_t address, const void *data, int length) { op->write_data(address, data, length); diff --git a/srecord/memory/walker/writer.h b/srecord/memory/walker/writer.h index c9f2a8a0..9b6ad047 100644 --- a/srecord/memory/walker/writer.h +++ b/srecord/memory/walker/writer.h @@ -60,10 +60,10 @@ class memory_walker_writer: protected: // See base class for documentation. - void observe(unsigned long, const void *, int) override; + void observe(uint32_t, const void *, int) override; // See base class for documentation. - void notify_upper_bound(long unsigned) override; + void notify_upper_bound(uint32_t) override; // See base class for documentation. void observe_header(const record *) override; diff --git a/srecord/output.cc b/srecord/output.cc index bde8c312..91b382aa 100644 --- a/srecord/output.cc +++ b/srecord/output.cc @@ -127,7 +127,7 @@ srecord::output::write_header(const srecord::record *rp) void -srecord::output::write_data(unsigned long address, const void *data, +srecord::output::write_data(uint32_t address, const void *data, size_t length) { const auto *data_p = (const srecord::record::data_t *)data; @@ -169,7 +169,7 @@ srecord::output::write_execution_start_address(const srecord::record *rp) void -srecord::output::notify_upper_bound(unsigned long) +srecord::output::notify_upper_bound(uint32_t) { } diff --git a/srecord/output.h b/srecord/output.h index 3fff60ca..8f47dec2 100644 --- a/srecord/output.h +++ b/srecord/output.h @@ -66,7 +66,7 @@ class output * A suitable data record will be produced. The #write method * will be called. */ - virtual void write_data(unsigned long, const void *, size_t); + virtual void write_data(uint32_t, const void *, size_t); /** * The write_execution_start_address method is used to write an @@ -189,7 +189,7 @@ class output * @param addr * One past the highest used memory byte. */ - virtual void notify_upper_bound(unsigned long addr); + virtual void notify_upper_bound(uint32_t addr); /** * The command_line method is used by arglex_srec::get_output when diff --git a/srecord/output/file.cc b/srecord/output/file.cc index e03216ed..83158c87 100644 --- a/srecord/output/file.cc +++ b/srecord/output/file.cc @@ -188,7 +188,7 @@ srecord::output_file::put_nibble(int n) void -srecord::output_file::put_byte(unsigned char n) +srecord::output_file::put_byte(uint8_t n) { put_nibble(n >> 4); put_nibble(n); @@ -213,7 +213,7 @@ srecord::output_file::put_word_le(int n) void -srecord::output_file::put_3bytes_be(unsigned long n) +srecord::output_file::put_3bytes_be(uint32_t n) { put_byte(n >> 16); put_byte(n >> 8); @@ -222,7 +222,7 @@ srecord::output_file::put_3bytes_be(unsigned long n) void -srecord::output_file::put_3bytes_le(unsigned long n) +srecord::output_file::put_3bytes_le(uint32_t n) { put_byte(n); put_byte(n >> 8); @@ -231,7 +231,7 @@ srecord::output_file::put_3bytes_le(unsigned long n) void -srecord::output_file::put_4bytes_be(unsigned long n) +srecord::output_file::put_4bytes_be(uint32_t n) { put_byte(n >> 24); put_byte(n >> 16); @@ -241,7 +241,7 @@ srecord::output_file::put_4bytes_be(unsigned long n) void -srecord::output_file::put_4bytes_le(unsigned long n) +srecord::output_file::put_4bytes_le(uint32_t n) { put_byte(n); put_byte(n >> 8); @@ -271,14 +271,14 @@ srecord::output_file::checksum_reset() } void -srecord::output_file::checksum_add(unsigned char n) +srecord::output_file::checksum_add(uint8_t n) { checksum += n; } void -srecord::output_file::seek_to(unsigned long address) +srecord::output_file::seek_to(uint32_t address) { // // Seeking on non-regular files is problematic. Avoid doing @@ -314,7 +314,7 @@ srecord::output_file::seek_to(unsigned long address) ((double)address / (double)(1UL << 30)) ); } - fatal_error_errno("seek 0x%lX", address); + fatal_error_errno("seek 0x%X", address); } position = address; } @@ -426,12 +426,12 @@ srecord::output_file::set_is_regular() void -srecord::output_file::fatal_hole_error(unsigned long lo, unsigned long hi) +srecord::output_file::fatal_hole_error(uint32_t lo, uint32_t hi) { fatal_error ( "The %s output format is unable to cope with holes in the data," - "however there is a hole at 0x%04lX..0x%04lX.", + "however there is a hole at 0x%04X..0x%04X.", format_name(), lo, hi - 1 @@ -474,16 +474,16 @@ void srecord::output_file::data_address_too_large(const srecord::record &record, unsigned nbits) const { - unsigned long lo = record.get_address(); - unsigned long hi = lo + record.get_length() - 1; + uint32_t lo = record.get_address(); + uint32_t hi = lo + record.get_length() - 1; assert(nbits <= 32); if (nbits > 0) { int prec = (nbits + 3) / 4; fatal_error ( - "data address range (0x%.*lX..0x%.*lX) is too large, " - "the available range is only (0x%.*lx..0x%.*lX)", + "data address range (0x%.*X..0x%.*X) is too large, " + "the available range is only (0x%.*lX..0x%.*lX)", prec, lo, prec, @@ -494,5 +494,5 @@ srecord::output_file::data_address_too_large(const srecord::record &record, (1UL << nbits) - 1 ); } - fatal_error("data address (0x%lX..0x%lX) too large", lo, hi); + fatal_error("data address (0x%X..0x%X) too large", lo, hi); } diff --git a/srecord/output/file.h b/srecord/output/file.h index 3a233e5a..05ef00e7 100644 --- a/srecord/output/file.h +++ b/srecord/output/file.h @@ -154,7 +154,7 @@ class output_file: * they have a special case. Over-ride with caution, as it affects * many other methods. */ - virtual void put_byte(unsigned char value); + virtual void put_byte(uint8_t value); /** * The put_word_be method is used to send a 16-bit value to the @@ -176,7 +176,7 @@ class output_file: * three byte values are sent big-endian (most significant byte * first). */ - virtual void put_3bytes_be(unsigned long value); + virtual void put_3bytes_be(uint32_t value); /** * The put_3bytes_le method is used to send a 24-bit value to the @@ -184,7 +184,7 @@ class output_file: * three byte values are sent little-endian (least significant byte * first). */ - virtual void put_3bytes_le(unsigned long value); + virtual void put_3bytes_le(uint32_t value); /** * The put_4bytes_be method is used to send a 32-bit value to the @@ -192,7 +192,7 @@ class output_file: * four byte values are sent big-endian (most significant byte * first). */ - virtual void put_4bytes_be(unsigned long value); + virtual void put_4bytes_be(uint32_t value); /** * The put_4bytes_le method is used to send a 32-bit value to the @@ -200,7 +200,7 @@ class output_file: * four byte values are sent little-endian (least significant byte * first). */ - virtual void put_4bytes_le(unsigned long value); + virtual void put_4bytes_le(uint32_t value); /** * The checksum_reset method is used to set the running checksum to @@ -216,7 +216,7 @@ class output_file: * classes may override if they need to. Do this with caution, as * it affects other methods. */ - virtual void checksum_add(unsigned char n); + virtual void checksum_add(uint8_t n); /** * The checksum_get method is used to get the current value of the @@ -238,7 +238,7 @@ class output_file: * The seek_to method is used to move the output position to the * specified location in the output file. */ - void seek_to(unsigned long); + void seek_to(uint32_t); /** * The put_string method is used to send a nul-terminated C string @@ -382,7 +382,7 @@ class output_file: * The fatal_hole_error method is used to report problems with * holes in the data, for formats that cannot cope with them. */ - void fatal_hole_error(unsigned long lo, unsigned long hi); + void fatal_hole_error(uint32_t lo, uint32_t hi); /** * The data_address_too_large method is used to report fatal @@ -403,7 +403,7 @@ class output_file: * current position within the output file. Set by the put_char * method, and the seek_to method. Used by the seek_to method. */ - unsigned long position{0}; + uint32_t position{0}; /** * The is_regular instance variable is used to remember whether diff --git a/srecord/output/file/aomf.cc b/srecord/output/file/aomf.cc index e0308a0b..9a87ce81 100644 --- a/srecord/output/file/aomf.cc +++ b/srecord/output/file/aomf.cc @@ -39,7 +39,7 @@ srecord::output_file_aomf::create(const std::string &a_file_name) void -srecord::output_file_aomf::emit_record(int type, const unsigned char *data, +srecord::output_file_aomf::emit_record(int type, const uint8_t *data, size_t length) { checksum_reset(); @@ -62,7 +62,7 @@ srecord::output_file_aomf::module_header_record(const char *name) // 0xFE -> PL/M-51 // 0xFF -> RL51 // - unsigned char buffer[1 + 255 + 2]; + uint8_t buffer[1 + 255 + 2]; size_t len = strlen(name); if (len > 255) len = 255; @@ -75,11 +75,11 @@ srecord::output_file_aomf::module_header_record(const char *name) void -srecord::output_file_aomf::content_record(unsigned long address, - const unsigned char *data, size_t len) +srecord::output_file_aomf::content_record(uint32_t address, + const uint8_t *data, size_t len) { const size_t maxlen = 4 * srecord::record::max_data_length; - auto *buffer = new unsigned char[maxlen + 3]; + auto *buffer = new uint8_t[maxlen + 3]; while (len > 0) { @@ -101,7 +101,7 @@ srecord::output_file_aomf::content_record(unsigned long address, void srecord::output_file_aomf::module_end_record(const char *name) { - unsigned char buffer[1 + 255 + 4]; + uint8_t buffer[1 + 255 + 4]; size_t len = strlen(name); if (len > 255) len = 255; @@ -116,7 +116,7 @@ srecord::output_file_aomf::module_end_record(const char *name) void -srecord::output_file_aomf::put_byte(unsigned char n) +srecord::output_file_aomf::put_byte(uint8_t n) { checksum_add(n); put_char(n); diff --git a/srecord/output/file/aomf.h b/srecord/output/file/aomf.h index 9044f3e0..1da6e4af 100644 --- a/srecord/output/file/aomf.h +++ b/srecord/output/file/aomf.h @@ -84,7 +84,7 @@ class output_file_aomf: * Each has an 8-but type, a 16-bit little-endian length, a payload, * and an 8-bit 2s complement checksum. */ - void emit_record(int, const unsigned char *, size_t); + void emit_record(int, const uint8_t *, size_t); /** * The module_header_record method is used to write an AOMF Module @@ -95,7 +95,7 @@ class output_file_aomf: /** * The content_record method is used to write an AOMF Content Record. */ - void content_record(unsigned long address, const unsigned char *data, + void content_record(uint32_t address, const uint8_t *data, size_t length); /** @@ -110,13 +110,13 @@ class output_file_aomf: * This method also tracks the byte_offset, so that we can * align to specific boundaries. Calls the #checksum_add method. */ - void put_byte(unsigned char) override; + void put_byte(uint8_t) override; /** * The byte_offset instance variable is used to track the location * in the output file. Maintained by the #put_byte method. */ - unsigned long byte_offset{}; + uint32_t byte_offset{}; /** * The module_name instance variable is used to remember the diff --git a/srecord/output/file/ascii_hex.cc b/srecord/output/file/ascii_hex.cc index 3d885485..db761fc5 100644 --- a/srecord/output/file/ascii_hex.cc +++ b/srecord/output/file/ascii_hex.cc @@ -89,7 +89,7 @@ srecord::output_file_ascii_hex::write(const srecord::record &record) start_code_emitted = true; if (!enable_optional_address_flag) - address = (unsigned long)-1L; + address = (uint32_t)-1L; } if (address != record.get_address()) { @@ -125,7 +125,7 @@ srecord::output_file_ascii_hex::write(const srecord::record &record) // Now write out the new address. It is important not to // disturb the checksum, so don't use the put_byte method. // - put_stringf("$A%0*lX,\n", address_width, address); + put_stringf("$A%0*X,\n", address_width, address); column = 0; } for (size_t j = 0; j < record.get_length(); ++j) diff --git a/srecord/output/file/ascii_hex.h b/srecord/output/file/ascii_hex.h index 0f0a1575..a45e840c 100644 --- a/srecord/output/file/ascii_hex.h +++ b/srecord/output/file/ascii_hex.h @@ -82,7 +82,7 @@ class output_file_ascii_hex: * The address instance variable is used to remember where we are * up to in the output. Used to limit the number of $A line emitted. */ - unsigned long address{0}; + uint32_t address{0}; /** * The column instance variable is used to remember which column diff --git a/srecord/output/file/asm.cc b/srecord/output/file/asm.cc index ff727920..b07dc072 100644 --- a/srecord/output/file/asm.cc +++ b/srecord/output/file/asm.cc @@ -60,15 +60,15 @@ srecord::output_file_asm::~output_file_asm() x2.first_interval_only(); x -= x2; - unsigned long val = x2.get_lowest(); + uint32_t val = x2.get_lowest(); char buffer[20]; // We do it this way, rather than just making argument 3 a // (?:) conditional, so that the compiler can tell us when // we get the types wrong. (Besides, it will optimize.) if (hex_style) - snprintf(buffer, sizeof(buffer), "0x%8.8lX", val); + snprintf(buffer, sizeof(buffer), "0x%8.8X", val); else - snprintf(buffer, sizeof(buffer), "%lu", val); + snprintf(buffer, sizeof(buffer), "%u", val); long len = strlen(buffer); if (column && column + len + 2 > line_length) @@ -126,14 +126,14 @@ srecord::output_file_asm::~output_file_asm() x -= x2; ++nsections; - unsigned long slen = x2.get_highest() - x2.get_lowest(); + uint32_t slen = x2.get_highest() - x2.get_lowest(); if (output_word) slen /= 2; char buffer[30]; if (hex_style) - snprintf(buffer, sizeof(buffer), "0x%8.8lX", slen); + snprintf(buffer, sizeof(buffer), "0x%8.8X", slen); else - snprintf(buffer, sizeof(buffer), "%lu", slen); + snprintf(buffer, sizeof(buffer), "%u", slen); long len = strlen(buffer); if (column && column + len + 2 > line_length) { @@ -182,13 +182,13 @@ srecord::output_file_asm::~output_file_asm() if (enable_footer_flag) { - unsigned long hi = range.get_highest(); - put_stringf("; upper bound = 0x%4.4lX\n", hi); - unsigned long lo = range.get_lowest(); - put_stringf("; lower bound = 0x%4.4lX\n", lo); + uint32_t hi = range.get_highest(); + put_stringf("; upper bound = 0x%4.4X\n", hi); + uint32_t lo = range.get_lowest(); + put_stringf("; lower bound = 0x%4.4X\n", lo); } - unsigned long len = range.get_highest() - range.get_lowest(); - put_stringf("; length = 0x%4.4lX\n", len); + uint32_t len = range.get_highest() - range.get_lowest(); + put_stringf("; length = 0x%4.4X\n", len); if (section_style) { @@ -277,9 +277,9 @@ srecord::output_file_asm::emit_byte(int n) { char buffer[8]; if (hex_style) - sprintf(buffer, "0x%2.2X", (unsigned char)n); + sprintf(buffer, "0x%2.2X", (uint8_t)n); else - sprintf(buffer, "%u", (unsigned char)n); + sprintf(buffer, "%u", (uint8_t)n); int len = strlen(buffer); if (column && (column + 1 + len) > line_length) { @@ -315,9 +315,9 @@ srecord::output_file_asm::emit_word(unsigned int n) { char buffer[16]; if (hex_style) - snprintf(buffer, sizeof(buffer), "0x%4.4X", (unsigned short)n); + snprintf(buffer, sizeof(buffer), "0x%4.4X", (uint16_t)n); else - snprintf(buffer, sizeof(buffer), "%u", (unsigned short)n); + snprintf(buffer, sizeof(buffer), "%u", (uint16_t)n); int len = strlen(buffer); if (column && (column + 1 + len) > line_length) { @@ -361,8 +361,8 @@ srecord::output_file_asm::write(const srecord::record & record) // emit header records as comments in the file { bool bol = true; - const unsigned char *cp = record.get_data(); - const unsigned char *ep = cp + record.get_length(); + const uint8_t *cp = record.get_data(); + const uint8_t *ep = cp + record.get_length(); while (cp < ep) { int c = *cp++; @@ -403,7 +403,7 @@ srecord::output_file_asm::write(const srecord::record & record) } if (!enable_optional_address_flag) - current_address = (unsigned long)-1L; + current_address = (uint32_t)-1L; } if (current_address != record.get_address()) @@ -424,7 +424,7 @@ srecord::output_file_asm::write(const srecord::record & record) put_stringf ( "; To avoid this next %s directive, use the " - "--offset -0x%lX filter.\n", + "--offset -0x%X filter.\n", org, current_address ); @@ -439,7 +439,7 @@ srecord::output_file_asm::write(const srecord::record & record) org ); } - put_stringf(" %-7s %lu\n", org, current_address); + put_stringf(" %-7s %u\n", org, current_address); } } if (output_word) @@ -455,10 +455,10 @@ srecord::output_file_asm::write(const srecord::record & record) // for (int j = 0; j < len; j += 2) { - unsigned char n1 = record.get_data(j); - unsigned char n2 = record.get_data(j + 1); + uint8_t n1 = record.get_data(j); + uint8_t n2 = record.get_data(j + 1); // little-endian - unsigned short n = n1 + (n2 << 8); + uint16_t n = n1 + (n2 << 8); emit_word(n); } } @@ -487,7 +487,7 @@ srecord::output_file_asm::write(const srecord::record & record) put_char('\n'); column = 0; } - put_stringf("; execution start address = 0x%4.4lX\n", taddr); + put_stringf("; execution start address = 0x%4.4X\n", taddr); } break; } diff --git a/srecord/output/file/asm.h b/srecord/output/file/asm.h index 94e33647..cb8f7b95 100644 --- a/srecord/output/file/asm.h +++ b/srecord/output/file/asm.h @@ -92,7 +92,7 @@ class output_file_asm: * The taddr instance variable is used to remember the * termination address, to be emitted in the footer. */ - unsigned long taddr{0}; + uint32_t taddr{0}; /** * The range instance variable is used to remember the range @@ -111,7 +111,7 @@ class output_file_asm: * the current address that the file is positioned at. This is * used to know whether we need to add padding. */ - unsigned long current_address{0}; + uint32_t current_address{0}; /** * The line_length instance variable is used to remember the @@ -148,7 +148,7 @@ class output_file_asm: * The emit_4byte method is used to emit a double word (4 Byte). It uses * column to track the position, so as not to exceed line_length. */ - void emit_4byte_array(unsigned long *); + void emit_4byte_array(uint32_t *); /** * The dot_style instance variable is used to remember whether or diff --git a/srecord/output/file/basic.cc b/srecord/output/file/basic.cc index cad731d3..8c5ddcd2 100644 --- a/srecord/output/file/basic.cc +++ b/srecord/output/file/basic.cc @@ -34,14 +34,14 @@ srecord::output_file_basic::~output_file_basic() if (enable_footer_flag) { - put_stringf("REM termination = %lu\n", taddr); - unsigned long start = range.get_lowest(); - put_stringf("REM start = %lu\n", start); - unsigned long finish = range.get_highest(); - put_stringf("REM finish = %lu\n", finish); + put_stringf("REM termination = %u\n", taddr); + uint32_t start = range.get_lowest(); + put_stringf("REM start = %u\n", start); + uint32_t finish = range.get_highest(); + put_stringf("REM finish = %u\n", finish); } - unsigned long len = range.get_highest() - range.get_lowest(); - put_stringf("REM length = %lu\n", len); + uint32_t len = range.get_highest() - range.get_lowest(); + put_stringf("REM length = %u\n", len); } @@ -62,7 +62,7 @@ void srecord::output_file_basic::emit_byte(int n) { char buffer[8]; - sprintf(buffer, "%d", (unsigned char)n); + sprintf(buffer, "%d", (uint8_t)n); int len = strlen(buffer); if (column && column + 1 + len > line_length) { @@ -98,8 +98,8 @@ srecord::output_file_basic::write(const srecord::record &record) // emit header records as comments in the file { bool bol = true; - const unsigned char *cp = record.get_data(); - const unsigned char *ep = cp + record.get_length(); + const uint8_t *cp = record.get_data(); + const uint8_t *ep = cp + record.get_length(); while (cp < ep) { int c = *cp++; diff --git a/srecord/output/file/basic.h b/srecord/output/file/basic.h index a4ad0d72..854119e4 100644 --- a/srecord/output/file/basic.h +++ b/srecord/output/file/basic.h @@ -83,7 +83,7 @@ class output_file_basic: * The taddr instance variable is used to remember the * termination address, to be emitted in the footer. */ - unsigned long taddr{0}; + uint32_t taddr{0}; /** * The range instance variable is used to remember the range @@ -102,7 +102,7 @@ class output_file_basic: * the current address that the file is positioned at. This is * used to know whether we need to add padding. */ - unsigned long current_address{0}; + uint32_t current_address{0}; /** * The line_length instance variable is used to remember the diff --git a/srecord/output/file/binary.cc b/srecord/output/file/binary.cc index 9ae41dfc..043c9669 100644 --- a/srecord/output/file/binary.cc +++ b/srecord/output/file/binary.cc @@ -44,7 +44,7 @@ srecord::output_file_binary::write(const srecord::record &record) if (record.get_type() != srecord::record::type_data) return; seek_to(record.get_address()); - const unsigned char *data = record.get_data(); + const uint8_t *data = record.get_data(); int length = record.get_length(); while (length-- > 0) put_char(*data++); diff --git a/srecord/output/file/coe.cc b/srecord/output/file/coe.cc index 6461b1c8..0bc01142 100644 --- a/srecord/output/file/coe.cc +++ b/srecord/output/file/coe.cc @@ -34,7 +34,7 @@ srecord::output_file_coe::~output_file_coe() { put_stringf ( - "; depth = %lu; 0x%04lX\n", + "; depth = %u; 0x%04X\n", actual_depth / width_in_bytes, actual_depth / width_in_bytes ); @@ -97,7 +97,7 @@ srecord::output_file_coe::command_line(srecord::arglex_tool *cmdln) void -srecord::output_file_coe::notify_upper_bound(unsigned long addr) +srecord::output_file_coe::notify_upper_bound(uint32_t addr) { depth = addr; actual_depth = addr; @@ -123,7 +123,7 @@ srecord::output_file_coe::emit_header() { put_stringf ( - "; depth = %ld; 0x%04lX\n", + "; depth = %d; 0x%04X\n", actual_depth / width_in_bytes, actual_depth / width_in_bytes ); @@ -157,14 +157,14 @@ srecord::output_file_coe::write(const srecord::record &record) put_string("; "); if (record.get_address() != 0) { - unsigned long addr = record.get_address(); - put_stringf("%04lX: ", addr); + uint32_t addr = record.get_address(); + put_stringf("%04X: ", addr); } - const unsigned char *cp = record.get_data(); - const unsigned char *ep = cp + record.get_length(); + const uint8_t *cp = record.get_data(); + const uint8_t *ep = cp + record.get_length(); while (cp < ep) { - unsigned char c = *cp++; + uint8_t c = *cp++; if (c == '\n') { put_string("\n; "); @@ -180,7 +180,7 @@ srecord::output_file_coe::write(const srecord::record &record) case srecord::record::type_data: { - unsigned long addr = record.get_address(); + uint32_t addr = record.get_address(); unsigned len = record.get_length(); if ((addr % width_in_bytes) || (len % width_in_bytes)) fatal_alignment_error(width_in_bytes); @@ -205,7 +205,7 @@ srecord::output_file_coe::write(const srecord::record &record) got_data = true; } - unsigned long d = addr + len; + uint32_t d = addr + len; if (actual_depth < d) actual_depth = d; } @@ -219,8 +219,8 @@ srecord::output_file_coe::write(const srecord::record &record) put_stringf(";\n"); got_data = false; } - unsigned long addr = record.get_address(); - put_stringf("; data record count = %lu\n", addr); + uint32_t addr = record.get_address(); + put_stringf("; data record count = %u\n", addr); } break; @@ -232,8 +232,8 @@ srecord::output_file_coe::write(const srecord::record &record) put_stringf(";\n"); got_data = false; } - unsigned long addr = record.get_address(); - put_stringf("; start address = %04lX\n", addr); + uint32_t addr = record.get_address(); + put_stringf("; start address = %04X\n", addr); } break; } diff --git a/srecord/output/file/coe.h b/srecord/output/file/coe.h index 803d754a..2230873b 100644 --- a/srecord/output/file/coe.h +++ b/srecord/output/file/coe.h @@ -81,7 +81,7 @@ class output_file_coe: const char *format_name() const override; // See base class for documentation. - void notify_upper_bound(unsigned long addr) override; + void notify_upper_bound(uint32_t addr) override; private: /** @@ -89,14 +89,14 @@ class output_file_coe: * memory address to be written. This is also used to detect holes * in the input data. */ - unsigned long address{0}; + uint32_t address{0}; /** * The depth instance variable is used to remember how many bytes * of data there is. Kind of broken, because we don't know this * when the header is actually printed. */ - unsigned long depth{0}; + uint32_t depth{0}; /** * The width instance variable is used to remember how many bits @@ -114,7 +114,7 @@ class output_file_coe: * The actual_depth instance variable is used to remember how many * bytes of data there were. This is printed in the footer. */ - unsigned long actual_depth{0}; + uint32_t actual_depth{0}; /** * The header_done instance variable is used to remember whether diff --git a/srecord/output/file/cosmac.cc b/srecord/output/file/cosmac.cc index e68e5b2d..9fbd3d9d 100644 --- a/srecord/output/file/cosmac.cc +++ b/srecord/output/file/cosmac.cc @@ -55,17 +55,17 @@ srecord::output_file_cosmac::write(const srecord::record &record) if (header_required) { address = record.get_address(); - put_stringf("!M%.*lX ", (int)address_length, address); + put_stringf("!M%.*X ", (int)address_length, address); column = address_length + 3; header_required = false; if (!enable_optional_address_flag) - address = (unsigned long)-1L; + address = (uint32_t)-1L; } if (address != record.get_address()) { address = record.get_address(); - put_stringf(";\n%.*lX ", (int)address_length, address); + put_stringf(";\n%.*X ", (int)address_length, address); column = address_length + 1; } for (size_t j = 0; j < record.get_length(); ++j) diff --git a/srecord/output/file/cosmac.h b/srecord/output/file/cosmac.h index cd361fdb..5c16268c 100644 --- a/srecord/output/file/cosmac.h +++ b/srecord/output/file/cosmac.h @@ -82,7 +82,7 @@ class output_file_cosmac: * The address instance variable is used to remember the current * output address, so that file size can be optimized. */ - unsigned long address{0}; + uint32_t address{0}; /** * The address_length is used to remember the preferred number of diff --git a/srecord/output/file/dec_binary.cc b/srecord/output/file/dec_binary.cc index d35dc4b9..e8b42505 100644 --- a/srecord/output/file/dec_binary.cc +++ b/srecord/output/file/dec_binary.cc @@ -50,7 +50,7 @@ srecord::output_file_dec_binary::create(const std::string &a_file_name) void -srecord::output_file_dec_binary::put_byte(unsigned char n) +srecord::output_file_dec_binary::put_byte(uint8_t n) { checksum_add(n); put_char(n); diff --git a/srecord/output/file/dec_binary.h b/srecord/output/file/dec_binary.h index 1af38fad..4a459931 100644 --- a/srecord/output/file/dec_binary.h +++ b/srecord/output/file/dec_binary.h @@ -91,13 +91,13 @@ class output_file_dec_binary: * method also tracks the byte_offset, so that we can align to * specific boundaries. Calls the checksum_add() method. */ - void put_byte(unsigned char) override; + void put_byte(uint8_t) override; /** * The byte_offset instance variable is used to track the location * in the output file. Maintained by the put_byte() method. */ - unsigned long byte_offset{}; + uint32_t byte_offset{}; /** * The pref_block_size is used to remember the preferred diff --git a/srecord/output/file/emon52.h b/srecord/output/file/emon52.h index c8ccaad4..e3cb520c 100644 --- a/srecord/output/file/emon52.h +++ b/srecord/output/file/emon52.h @@ -91,7 +91,7 @@ class output_file_emon52: * The write_inner method is used to write a single line (record) * to the file. Use by the write() method. */ - void write_inner(int type, unsigned long addr, int addr_len, + void write_inner(int type, uint32_t addr, int addr_len, const void *data, int data_len); public: diff --git a/srecord/output/file/fairchild.cc b/srecord/output/file/fairchild.cc index 486e8614..f8abce32 100644 --- a/srecord/output/file/fairchild.cc +++ b/srecord/output/file/fairchild.cc @@ -45,7 +45,7 @@ srecord::output_file_fairchild::put_nibble(unsigned n) void -srecord::output_file_fairchild::put_byte(unsigned char n) +srecord::output_file_fairchild::put_byte(uint8_t n) { // This differs from srecord::output_file::put_byte only in that it // doesn't add to the checksum. @@ -61,7 +61,7 @@ srecord::output_file_fairchild::write(const srecord::record &record) { case srecord::record::type_header: if (!enable_optional_address_flag) - address = (unsigned long)-1L; + address = (uint32_t)-1L; break; case srecord::record::type_unknown: @@ -72,12 +72,12 @@ srecord::output_file_fairchild::write(const srecord::record &record) case srecord::record::type_data: { int len = record.get_length(); - unsigned long new_addr = record.get_address(); + uint32_t new_addr = record.get_address(); if ((new_addr & 7) || (len & 7)) fatal_alignment_error(8); if (address != new_addr) { - put_stringf("S%4.4lX\n", new_addr); + put_stringf("S%4.4X\n", new_addr); address = new_addr; } for (int j = 0; j < len; j += 8) diff --git a/srecord/output/file/fairchild.h b/srecord/output/file/fairchild.h index 1bece89c..e7cc8c66 100644 --- a/srecord/output/file/fairchild.h +++ b/srecord/output/file/fairchild.h @@ -90,13 +90,13 @@ class output_file_fairchild: * We override the one in the base class because the checksum is * nibble-based, not byte-based. */ - void put_byte(unsigned char) override; + void put_byte(uint8_t) override; /** * The address instance variable is used to remember the current * memory position within the output. */ - unsigned long address{~0UL}; + uint32_t address{~0U}; public: /** diff --git a/srecord/output/file/fastload.cc b/srecord/output/file/fastload.cc index 10c9f192..af287cd8 100644 --- a/srecord/output/file/fastload.cc +++ b/srecord/output/file/fastload.cc @@ -55,10 +55,10 @@ srecord::output_file_fastload::create(const std::string &a_filename) void -srecord::output_file_fastload::put_number(unsigned long n, int min_digits) +srecord::output_file_fastload::put_number(uint32_t n, int min_digits) { - unsigned char buffer[20]; - unsigned char *bp = buffer; + uint8_t buffer[20]; + uint8_t *bp = buffer; while (n || min_digits > 0) { *bp++ = n & 63; @@ -77,7 +77,7 @@ srecord::output_file_fastload::put_number(unsigned long n, int min_digits) static int -number_width(unsigned long n) +number_width(uint32_t n) { int result = 0; while (n) @@ -90,7 +90,7 @@ number_width(unsigned long n) void -srecord::output_file_fastload::put_command(int c, unsigned long n, int ndigits) +srecord::output_file_fastload::put_command(int c, uint32_t n, int ndigits) { int width = number_width(n); if (width < ndigits) @@ -120,7 +120,7 @@ srecord::output_file_fastload::write(const srecord::record &record) case srecord::record::type_header: // This format can't do header records if (!enable_optional_address_flag) - address = (unsigned long)-1L; + address = (uint32_t)-1L; break; case srecord::record::type_data: @@ -147,13 +147,13 @@ srecord::output_file_fastload::write(const srecord::record &record) checksum_reset(); bytes_since_checksum = 0; } - unsigned char n1 = record.get_data(j); + uint8_t n1 = record.get_data(j); checksum_add(n1); - unsigned char n2 = record.get_data(j + 1); + uint8_t n2 = record.get_data(j + 1); checksum_add(n2); - unsigned char n3 = record.get_data(j + 2); + uint8_t n3 = record.get_data(j + 2); checksum_add(n3); - unsigned long n = (n1 << 16) | (n2 << 8) | n3; + uint32_t n = (n1 << 16) | (n2 << 8) | n3; if (column + 4 > line_length || prev_was_command) { put_char('\n'); @@ -165,9 +165,9 @@ srecord::output_file_fastload::write(const srecord::record &record) } for (; j < record.get_length(); ++j) { - unsigned char n = record.get_data(j); + uint8_t n = record.get_data(j); checksum_add(n); - put_command('B', (unsigned long)n, 2); + put_command('B', (uint32_t)n, 2); bytes_since_checksum++; } address += record.get_length(); diff --git a/srecord/output/file/fastload.h b/srecord/output/file/fastload.h index d1acb57a..7b414e30 100644 --- a/srecord/output/file/fastload.h +++ b/srecord/output/file/fastload.h @@ -91,7 +91,7 @@ class output_file_fastload: * The address instance variable is used to track the current * address location within the file. */ - unsigned long address{~0UL}; + uint32_t address{~0U}; /** * The column instance variable is used to track the current output @@ -125,20 +125,20 @@ class output_file_fastload: * The write_inner method is used to write a single line (record) * to the file. Use by the write() method. */ - void write_inner(int type, unsigned long addr, int addr_len, + void write_inner(int type, uint32_t addr, int addr_len, const void *data, int data_len); /** * The put_number method is used to write the given value to the * output in base-64 (big endian) notation. */ - void put_number(unsigned long value, int ndigits); + void put_number(uint32_t value, int ndigits); /** * The put_command method is used to write a command to the file, * including the leading '/' and the trailing newline. */ - void put_command(int c, unsigned long n, int ndigits); + void put_command(int c, uint32_t n, int ndigits); public: /** diff --git a/srecord/output/file/formatted_binary.cc b/srecord/output/file/formatted_binary.cc index 3fa181c8..50c3b091 100644 --- a/srecord/output/file/formatted_binary.cc +++ b/srecord/output/file/formatted_binary.cc @@ -52,7 +52,7 @@ srecord::output_file_formatted_binary::create(const std::string &a_file_name) void -srecord::output_file_formatted_binary::notify_upper_bound(unsigned long arg) +srecord::output_file_formatted_binary::notify_upper_bound(uint32_t arg) { upper_bound = arg; if (upper_bound == 0) @@ -109,7 +109,7 @@ srecord::output_file_formatted_binary::write(const srecord::record &record) put_char(0xFF); ++address; } - const unsigned char *data = record.get_data(); + const uint8_t *data = record.get_data(); int length = record.get_length(); while (length-- > 0) { diff --git a/srecord/output/file/formatted_binary.h b/srecord/output/file/formatted_binary.h index a3d8e4db..77fb45c0 100644 --- a/srecord/output/file/formatted_binary.h +++ b/srecord/output/file/formatted_binary.h @@ -60,7 +60,7 @@ class output_file_formatted_binary: protected: // See base class for documentation. - void notify_upper_bound(long unsigned) override; + void notify_upper_bound(uint32_t) override; // See base class for documentation. void write(const record &) override; @@ -88,19 +88,19 @@ class output_file_formatted_binary: * The upper_bound instance variable is used to remember the upper * bound of memory addresses (maximum address plus one). */ - unsigned long upper_bound{0}; + uint32_t upper_bound{0}; /** * The address instance variable is used to remember the current * output address, to know if padding is required. */ - unsigned long address{0}; + uint32_t address{0}; /** * The check_sum instance variable is used to remember the running * sum of data bytes written to date. */ - unsigned short check_sum{0}; + uint16_t check_sum{0}; public: /** diff --git a/srecord/output/file/four_packed_code.cc b/srecord/output/file/four_packed_code.cc index 0fefd9a6..e4982a21 100644 --- a/srecord/output/file/four_packed_code.cc +++ b/srecord/output/file/four_packed_code.cc @@ -23,7 +23,7 @@ #include -static unsigned char digit[] = { +static uint8_t digit[] = { '%', // 0 '&', // 1 '\'', // 2 @@ -133,9 +133,9 @@ srecord::output_file_four_packed_code::create(const std::string &a_file_name) void -srecord::output_file_four_packed_code::put_byte(unsigned char n) +srecord::output_file_four_packed_code::put_byte(uint8_t n) { - put_byte_value |= (unsigned long)n << ((3 - put_byte_pos) << 3); + put_byte_value |= (uint32_t)n << ((3 - put_byte_pos) << 3); ++put_byte_pos; if (put_byte_pos >= 4) { @@ -160,7 +160,7 @@ srecord::output_file_four_packed_code::put_byte(unsigned char n) void -srecord::output_file_four_packed_code::write_inner(unsigned long address, +srecord::output_file_four_packed_code::write_inner(uint32_t address, const void *data, int data_nbytes) { // @@ -172,7 +172,7 @@ srecord::output_file_four_packed_code::write_inner(unsigned long address, // // Assemble the data for this line using format code zero // - unsigned char buffer[261]; // Worst case is 252 byte length plus header + uint8_t buffer[261]; // Worst case is 252 byte length plus header buffer[0] = 0; // checksum field buffer[1] = 4 + data_nbytes; // byte count field buffer[2] = 0; // format code, first byte diff --git a/srecord/output/file/four_packed_code.h b/srecord/output/file/four_packed_code.h index 4e1af02e..d968dbd1 100644 --- a/srecord/output/file/four_packed_code.h +++ b/srecord/output/file/four_packed_code.h @@ -100,20 +100,20 @@ class output_file_four_packed_code: * At the end of 4 bytes, the 5-character base85 encoding * is issued. */ - unsigned long put_byte_value{0}; + uint32_t put_byte_value{0}; /** * The write_inner method is used by the write method to * write a single line of output. */ - void write_inner(unsigned long address, const void *data, + void write_inner(uint32_t address, const void *data, int data_length); /** * See base class for documentation. We over-ride this method * so that we can do the base85 encoding of each 4-byte chunk. */ - void put_byte(unsigned char) override; + void put_byte(uint8_t) override; public: /** diff --git a/srecord/output/file/hexdump.cc b/srecord/output/file/hexdump.cc index 6c4511ca..c89af245 100644 --- a/srecord/output/file/hexdump.cc +++ b/srecord/output/file/hexdump.cc @@ -56,7 +56,7 @@ srecord::output_file_hexdump::command_line(srecord::arglex_tool *) void srecord::output_file_hexdump::row_cache_print() { - if (row_cache_address == (unsigned long)(-1)) + if (row_cache_address == (uint32_t)(-1)) return; char *cp = row_cache; char *ep = cp + row_cache_size; @@ -66,7 +66,7 @@ srecord::output_file_hexdump::row_cache_print() put_char(*cp++); put_char('\n'); memset(row_cache, ' ', row_cache_size); - row_cache_address = (unsigned long)-1; + row_cache_address = (uint32_t)-1; } @@ -100,10 +100,10 @@ hex(char *buffer, long value, int nbytes) void -srecord::output_file_hexdump::emit_byte(unsigned long address, - unsigned char data) +srecord::output_file_hexdump::emit_byte(uint32_t address, + uint8_t data) { - if (row_cache_address != (unsigned long)(-1)) + if (row_cache_address != (uint32_t)(-1)) { if (row_cache_address != (address & ~row_cache_address_mask)) { @@ -111,7 +111,7 @@ srecord::output_file_hexdump::emit_byte(unsigned long address, row_cache_print(); } } - if (row_cache_address == (unsigned long)(-1)) + if (row_cache_address == (uint32_t)(-1)) { row_cache_address = address & ~row_cache_address_mask; hex(row_cache, row_cache_address, address_length); @@ -142,7 +142,7 @@ srecord::output_file_hexdump::write(const srecord::record &record) case srecord::record::type_data: { - unsigned long a = record.get_address(); + uint32_t a = record.get_address(); for (size_t j = 0; j < record.get_length(); ++j) emit_byte(a + j, record.get_data(j)); } diff --git a/srecord/output/file/hexdump.h b/srecord/output/file/hexdump.h index f8f7e9af..62d3b696 100644 --- a/srecord/output/file/hexdump.h +++ b/srecord/output/file/hexdump.h @@ -95,14 +95,14 @@ class output_file_hexdump: * address of the beginning of the row, NOT the current byte. * The lower "number_of_columns" bits are always zero. */ - unsigned long row_cache_address{(unsigned long)-1}; + uint32_t row_cache_address{(uint32_t)-1}; /** * The row_cache_address_mask instance variable is used to remember * the mask to calculate the column within the output line, give a * byte address. */ - unsigned long row_cache_address_mask{0}; + uint32_t row_cache_address_mask{0}; /** * The row_cache_size instance variable is used to remember the @@ -127,7 +127,7 @@ class output_file_hexdump: * The emit_byte method is used to emit a single byte. It uses * column to track the position, so as not to exceed line_length. */ - void emit_byte(unsigned long address, unsigned char data); + void emit_byte(uint32_t address, uint8_t data); /** * The row_cache_print method is used to print the row cache to the diff --git a/srecord/output/file/idt.cc b/srecord/output/file/idt.cc index 723ad980..a4006c94 100644 --- a/srecord/output/file/idt.cc +++ b/srecord/output/file/idt.cc @@ -42,8 +42,8 @@ srecord::output_file_idt::create(const std::string &a_file_name) void -srecord::output_file_idt::write_inner(int tag, unsigned long address, - unsigned address_nbytes, const unsigned char *data, size_t data_nbytes) +srecord::output_file_idt::write_inner(int tag, uint32_t address, + unsigned address_nbytes, const uint8_t *data, size_t data_nbytes) { // // Make sure the line is not too long. @@ -52,23 +52,23 @@ srecord::output_file_idt::write_inner(int tag, unsigned long address, { fatal_error ( - "data length (%d+%ld>254) too long", + "data length (%d+%d>254) too long", address_nbytes, - (unsigned long)data_nbytes + (uint32_t)data_nbytes ); } // intro put_char('S'); put_nibble(tag); - unsigned char line_length = address_nbytes + data_nbytes + 1; + uint8_t line_length = address_nbytes + data_nbytes + 1; put_char(line_length); - unsigned char csum = line_length; + uint8_t csum = line_length; // address for (unsigned j = 0; j < address_nbytes; ++j) { - unsigned char c = address >> (8 * (address_nbytes - 1 - j)); + uint8_t c = address >> (8 * (address_nbytes - 1 - j)); put_char(c); csum += c; } @@ -76,7 +76,7 @@ srecord::output_file_idt::write_inner(int tag, unsigned long address, // data for (unsigned j = 0; j < data_nbytes; ++j) { - unsigned char c = data[j]; + uint8_t c = data[j]; put_char(c); csum += c; } @@ -116,7 +116,7 @@ srecord::output_file_idt::write(const srecord::record &record) // // Make sure the address is nicely aligned. // - unsigned long addr = record.get_address(); + uint32_t addr = record.get_address(); switch (record.get_type()) { diff --git a/srecord/output/file/idt.h b/srecord/output/file/idt.h index 84175be7..97b2c31d 100644 --- a/srecord/output/file/idt.h +++ b/srecord/output/file/idt.h @@ -88,7 +88,7 @@ class output_file_idt: * number of output data lines have occurred to date. This is used * at the end of the file to emit an S5 record. */ - unsigned long data_count{0}; + uint32_t data_count{0}; /** * The pref_block_size instance variable is used to remember the @@ -133,8 +133,8 @@ class output_file_idt: * @param data_nbytes * The number of bytes of payload. */ - void write_inner(int tag, unsigned long address, unsigned address_nbytes, - const unsigned char *data, size_t data_nbytes); + void write_inner(int tag, uint32_t address, unsigned address_nbytes, + const uint8_t *data, size_t data_nbytes); public: /** diff --git a/srecord/output/file/intel.cc b/srecord/output/file/intel.cc index 0e0e5d06..b72d1c8c 100644 --- a/srecord/output/file/intel.cc +++ b/srecord/output/file/intel.cc @@ -45,7 +45,7 @@ srecord::output_file_intel::create(const std::string &a_file_name) void -srecord::output_file_intel::write_inner(int tag, unsigned long address, +srecord::output_file_intel::write_inner(int tag, uint32_t address, const void *data, int data_nbytes) { // @@ -60,12 +60,12 @@ srecord::output_file_intel::write_inner(int tag, unsigned long address, put_char(':'); checksum_reset(); put_byte(data_nbytes); - unsigned char tmp[2]; + uint8_t tmp[2]; srecord::record::encode_big_endian(tmp, address, 2); put_byte(tmp[0]); put_byte(tmp[1]); put_byte(tag); - const auto *data_p = (const unsigned char *)data; + const auto *data_p = (const uint8_t *)data; for (int j = 0; j < data_nbytes; ++j) put_byte(data_p[j]); put_byte(-checksum_get()); @@ -76,7 +76,7 @@ srecord::output_file_intel::write_inner(int tag, unsigned long address, void srecord::output_file_intel::write(const srecord::record &record) { - unsigned char tmp[4]; + uint8_t tmp[4]; switch (record.get_type()) { case srecord::record::type_header: diff --git a/srecord/output/file/intel.h b/srecord/output/file/intel.h index 9fe941ca..46a3b6d6 100644 --- a/srecord/output/file/intel.h +++ b/srecord/output/file/intel.h @@ -83,13 +83,13 @@ class output_file_intel: * The write_inner method is used to write a single line to the * output file. */ - void write_inner(int, unsigned long, const void *, int); + void write_inner(int, uint32_t, const void *, int); /** * The address_base instance variable is used to remember the * current position within the output file */ - unsigned long address_base{0}; + uint32_t address_base{0}; /** * The pref_block_size instance variable is used to remember the diff --git a/srecord/output/file/intel16.cc b/srecord/output/file/intel16.cc index e0768ee6..9a5eff41 100644 --- a/srecord/output/file/intel16.cc +++ b/srecord/output/file/intel16.cc @@ -47,7 +47,7 @@ srecord::output_file_intel16::create(const std::string &a_file_name) void -srecord::output_file_intel16::write_inner(int tag, unsigned long address, +srecord::output_file_intel16::write_inner(int tag, uint32_t address, const void *data, int data_nbytes) { // @@ -62,12 +62,12 @@ srecord::output_file_intel16::write_inner(int tag, unsigned long address, put_char(':'); checksum_reset(); put_byte(data_nbytes >> 1); - unsigned char tmp[2]; + uint8_t tmp[2]; srecord::record::encode_big_endian(tmp, address, 2); put_byte(tmp[0]); put_byte(tmp[1]); put_byte(tag); - const auto *data_p = (const unsigned char *)data; + const auto *data_p = (const uint8_t *)data; for (int j = 0; j < data_nbytes; ++j) { // Note: bytes are ordered HI,LO so we invert @@ -81,7 +81,7 @@ srecord::output_file_intel16::write_inner(int tag, unsigned long address, void srecord::output_file_intel16::write(const srecord::record &record) { - unsigned char tmp[4]; + uint8_t tmp[4]; switch (record.get_type()) { case srecord::record::type_header: diff --git a/srecord/output/file/intel16.h b/srecord/output/file/intel16.h index c6459a12..f4ed2ce1 100644 --- a/srecord/output/file/intel16.h +++ b/srecord/output/file/intel16.h @@ -83,13 +83,13 @@ class output_file_intel16: * The write_inner method is used to write a single line to the * output file. */ - void write_inner(int, unsigned long, const void *, int); + void write_inner(int, uint32_t, const void *, int); /** * The address_base instance variable is used to remember the * current position within the output file */ - unsigned long address_base{0}; + uint32_t address_base{0}; /** * The pref_block_size instance variable is used to remember the diff --git a/srecord/output/file/mem.cc b/srecord/output/file/mem.cc index 559c4635..340e4918 100644 --- a/srecord/output/file/mem.cc +++ b/srecord/output/file/mem.cc @@ -28,7 +28,7 @@ srecord::output_file_mem::~output_file_mem() if (column) put_char('\n'); if (enable_header_flag && actual_depth != depth) - put_stringf("#Depth=%lu;\n", actual_depth / width_in_bytes); + put_stringf("#Depth=%u;\n", actual_depth / width_in_bytes); } @@ -87,7 +87,7 @@ srecord::output_file_mem::command_line(srecord::arglex_tool *cmdln) void -srecord::output_file_mem::notify_upper_bound(unsigned long addr) +srecord::output_file_mem::notify_upper_bound(uint32_t addr) { depth = addr; actual_depth = addr; @@ -109,7 +109,7 @@ srecord::output_file_mem::emit_header() put_stringf("#Format=Hex\n"); // Bin | Hex | AddrHex if (actual_depth != 0) { - put_stringf("#Depth=%lu\n", actual_depth / width_in_bytes); + put_stringf("#Depth=%u\n", actual_depth / width_in_bytes); } put_stringf("#Width=%d\n", width); // 0: binary, 1: octal, 3: decimal, 3: hexadecimal @@ -155,11 +155,11 @@ srecord::output_file_mem::write(const srecord::record &record) // Output the header record as a comment. emit_header(); - const unsigned char *cp = record.get_data(); - const unsigned char *ep = cp + record.get_length(); + const uint8_t *cp = record.get_data(); + const uint8_t *ep = cp + record.get_length(); while (cp < ep) { - unsigned char c = *cp++; + uint8_t c = *cp++; if (c == '\n') { if (column == 0) @@ -176,8 +176,8 @@ srecord::output_file_mem::write(const srecord::record &record) column = 2; if (record.get_address() != 0) { - unsigned long addr = record.get_address(); - put_stringf("%04lX: ", addr); + uint32_t addr = record.get_address(); + put_stringf("%04X: ", addr); column += 6; } } @@ -194,7 +194,7 @@ srecord::output_file_mem::write(const srecord::record &record) case srecord::record::type_data: { - unsigned long addr = record.get_address(); + uint32_t addr = record.get_address(); unsigned len = record.get_length(); if (address != addr) fatal_hole_error(address, addr); @@ -238,8 +238,8 @@ srecord::output_file_mem::write(const srecord::record &record) put_char('\n'); column = 0; } - unsigned long addr = record.get_address(); - put_stringf("# data record count = %lu\n", addr); + uint32_t addr = record.get_address(); + put_stringf("# data record count = %u\n", addr); } break; @@ -251,8 +251,8 @@ srecord::output_file_mem::write(const srecord::record &record) put_char('\n'); column = 0; } - unsigned long addr = record.get_address(); - put_stringf("# execution start address = %04lX\n", addr); + uint32_t addr = record.get_address(); + put_stringf("# execution start address = %04X\n", addr); } break; } diff --git a/srecord/output/file/mem.h b/srecord/output/file/mem.h index 2c83da35..ca9dd5a6 100644 --- a/srecord/output/file/mem.h +++ b/srecord/output/file/mem.h @@ -81,7 +81,7 @@ class output_file_mem: const char *format_name() const override; // See base class for documentation. - void notify_upper_bound(unsigned long addr) override; + void notify_upper_bound(uint32_t addr) override; private: /** @@ -89,7 +89,7 @@ class output_file_mem: * memory address to be written. This is also used to detect holes * in the input data. */ - unsigned long address{0}; + uint32_t address{0}; /** * The column instance variable is used to remember the output text @@ -102,7 +102,7 @@ class output_file_mem: * of data there is. Kind of broken, because we don't know this * when the header is actually printed. */ - unsigned long depth{0}; + uint32_t depth{0}; /** * The width instance variable is used to remember how many bits @@ -120,7 +120,7 @@ class output_file_mem: * The actual_depth instance variable is used to remember how many * bytes of data there were. This is printed in the footer. */ - unsigned long actual_depth{0}; + uint32_t actual_depth{0}; /** * The header_done instance variable is used to remember whether diff --git a/srecord/output/file/mif.cc b/srecord/output/file/mif.cc index 4783c3f5..b4669684 100644 --- a/srecord/output/file/mif.cc +++ b/srecord/output/file/mif.cc @@ -27,7 +27,7 @@ srecord::output_file_mif::~output_file_mif() emit_header(); put_stringf("END;\n"); if (enable_header_flag && actual_depth != depth) - put_stringf("-- DEPTH = %lu;\n", actual_depth / width_in_bytes); + put_stringf("-- DEPTH = %u;\n", actual_depth / width_in_bytes); } @@ -86,7 +86,7 @@ srecord::output_file_mif::command_line(srecord::arglex_tool *cmdln) void -srecord::output_file_mif::notify_upper_bound(unsigned long addr) +srecord::output_file_mif::notify_upper_bound(uint32_t addr) { depth = addr; actual_depth = addr; @@ -109,13 +109,13 @@ srecord::output_file_mif::emit_header() ); if (actual_depth != 0) { - put_stringf("DEPTH = %lu;\n", actual_depth / width_in_bytes); + put_stringf("DEPTH = %u;\n", actual_depth / width_in_bytes); } else { put_stringf ( - "DEPTH = %lu; " + "DEPTH = %u; " "-- see comment at end of file for the actual size\n", depth / width_in_bytes ); @@ -147,14 +147,14 @@ srecord::output_file_mif::write(const srecord::record &record) put_string("-- "); if (record.get_address() != 0) { - unsigned long addr = record.get_address(); - put_stringf("%04lX: ", addr); + uint32_t addr = record.get_address(); + put_stringf("%04X: ", addr); } - const unsigned char *cp = record.get_data(); - const unsigned char *ep = cp + record.get_length(); + const uint8_t *cp = record.get_data(); + const uint8_t *ep = cp + record.get_length(); while (cp < ep) { - unsigned char c = *cp++; + uint8_t c = *cp++; if (c == '\n') { put_string("\n-- "); @@ -170,12 +170,12 @@ srecord::output_file_mif::write(const srecord::record &record) case srecord::record::type_data: { - unsigned long addr = record.get_address(); + uint32_t addr = record.get_address(); unsigned len = record.get_length(); if ((addr % width_in_bytes) || (len % width_in_bytes)) fatal_alignment_error(width_in_bytes); emit_header(); - put_stringf("%04lX:", addr / width_in_bytes); + put_stringf("%04X:", addr / width_in_bytes); for (unsigned j = 0; j < len; ++j) { if ((j % width_in_bytes) == 0) @@ -184,7 +184,7 @@ srecord::output_file_mif::write(const srecord::record &record) } put_stringf(";\n"); - unsigned long d = addr + len; + uint32_t d = addr + len; if (actual_depth < d) actual_depth = d; } @@ -193,16 +193,16 @@ srecord::output_file_mif::write(const srecord::record &record) case srecord::record::type_data_count: if (enable_data_count_flag) { - unsigned long addr = record.get_address(); - put_stringf("-- data record count = %lu\n", addr); + uint32_t addr = record.get_address(); + put_stringf("-- data record count = %u\n", addr); } break; case srecord::record::type_execution_start_address: if (enable_goto_addr_flag) { - unsigned long addr = record.get_address(); - put_stringf("-- start address = %04lX\n", addr); + uint32_t addr = record.get_address(); + put_stringf("-- start address = %04X\n", addr); } break; } diff --git a/srecord/output/file/mif.h b/srecord/output/file/mif.h index a157210c..b2d36a00 100644 --- a/srecord/output/file/mif.h +++ b/srecord/output/file/mif.h @@ -81,7 +81,7 @@ class output_file_mif: const char *format_name() const override; // See base class for documentation. - void notify_upper_bound(unsigned long addr) override; + void notify_upper_bound(uint32_t addr) override; private: /** @@ -89,7 +89,7 @@ class output_file_mif: * of data there is. Kind of broken, because we don't know this * when the header is actually printed. */ - unsigned long depth{65536}; + uint32_t depth{65536}; /** * The width instance variable is used to remember how many bits @@ -107,7 +107,7 @@ class output_file_mif: * The actual_depth instance variable is used to remember how many * bytes of data there were. This is printed in the footer. */ - unsigned long actual_depth{0}; + uint32_t actual_depth{0}; /** * The header_done instance variable is used to remember whether diff --git a/srecord/output/file/mips_flash.cc b/srecord/output/file/mips_flash.cc index 2f2d0126..823dd6c9 100644 --- a/srecord/output/file/mips_flash.cc +++ b/srecord/output/file/mips_flash.cc @@ -91,8 +91,8 @@ srecord::output_file_mips_flash::write(const srecord::record &record) return; for (size_t j = 0; j < record.get_length(); ++j) { - unsigned long byte_address = record.get_address() + j; - unsigned char byte = record.get_data(j); + uint32_t byte_address = record.get_address() + j; + uint8_t byte = record.get_data(j); bool new_sector = !base_set || ((address >> 17) != (byte_address >> 17)); bool new_address = !base_set || (address != byte_address); @@ -123,9 +123,9 @@ srecord::output_file_mips_flash::write(const srecord::record &record) if (new_sector) { // Started a new sector, by erasing it. - unsigned long sbase = address & ~0x1FFFF; - put_stringf(">%.5lxxxx ", sbase >> 12); - put_stringf("@%.8lx !E\n", sbase); + uint32_t sbase = address & ~0x1FFFF; + put_stringf(">%.5xxxx ", sbase >> 12); + put_stringf("@%.8x !E\n", sbase); if (sbase != address) new_address = true; } @@ -139,13 +139,13 @@ srecord::output_file_mips_flash::write(const srecord::record &record) fatal_alignment_error(4); // Set new write address. - put_stringf("@%.8lx\n", address); + put_stringf("@%.8x\n", address); } if (new_address || new_sector || (address & 0x0FFF) == 0) { // Update the display. - put_stringf(">%.8lx\n", address); + put_stringf(">%.8x\n", address); } ++address; @@ -188,8 +188,8 @@ srecord::output_file_mips_flash::buffer_flush() return; if ((buffer_length & 3) != 0) fatal_alignment_error(4); - const unsigned char *end = buffer + buffer_length; - for (const unsigned char *bp = buffer; bp < end; bp += 4) + const uint8_t *end = buffer + buffer_length; + for (const uint8_t *bp = buffer; bp < end; bp += 4) { if (column) { diff --git a/srecord/output/file/mips_flash.h b/srecord/output/file/mips_flash.h index 7513df2c..9aaba8a9 100644 --- a/srecord/output/file/mips_flash.h +++ b/srecord/output/file/mips_flash.h @@ -93,7 +93,7 @@ class output_file_mips_flash: * The write_inner method is used to write a single line (record) * to the file. Use by the write() method. */ - void write_inner(int type, unsigned long addr, int addr_len, + void write_inner(int type, uint32_t addr, int addr_len, const void *data, int data_len); /** @@ -106,13 +106,13 @@ class output_file_mips_flash: * The address instance variable is used to remember the address at * which the next byte is to be placed. */ - unsigned long address{0}; + uint32_t address{0}; /** * The base instance variable is used to remember the base address * of the current flash segment. */ - unsigned long base{0}; + uint32_t base{0}; /** * The base_set instance variable is used to remember whether or @@ -125,7 +125,7 @@ class output_file_mips_flash: * The buffer instance variable is used to remember the accumulated * data so far. Must be a multiple of 4 bytes long. */ - unsigned char buffer[256]{}; + uint8_t buffer[256]{}; /** * The buffer_length instance variable is used to remember how many diff --git a/srecord/output/file/mos_tech.h b/srecord/output/file/mos_tech.h index 53e8bb26..d832eb8e 100644 --- a/srecord/output/file/mos_tech.h +++ b/srecord/output/file/mos_tech.h @@ -97,7 +97,7 @@ class output_file_mos_tech: * The write_inner method is used to write a single line (record) * to the file. Use by the write() method. */ - void write_inner(int type, unsigned long addr, int addr_len, + void write_inner(int type, uint32_t addr, int addr_len, const void *data, int data_len); public: diff --git a/srecord/output/file/motorola.cc b/srecord/output/file/motorola.cc index 234bfc35..cebcbaf9 100644 --- a/srecord/output/file/motorola.cc +++ b/srecord/output/file/motorola.cc @@ -92,7 +92,7 @@ srecord::output_file_motorola::command_line(srecord::arglex_tool *cmdln) void -srecord::output_file_motorola::write_inner(int tag, unsigned long address, +srecord::output_file_motorola::write_inner(int tag, uint32_t address, int address_nbytes, const void *data, int data_nbytes) { // @@ -111,7 +111,7 @@ srecord::output_file_motorola::write_inner(int tag, unsigned long address, // // Assemble the data for this line. // - unsigned char buffer[256]; + uint8_t buffer[256]; int line_length = address_nbytes + data_nbytes + 1; buffer[0] = line_length; srecord::record::encode_big_endian(buffer + 1, address, address_nbytes); @@ -162,14 +162,14 @@ srecord::output_file_motorola::write(const srecord::record &record) // Make sure the address is nicely aligned. // FIXME: cope with this more elegantly. // - unsigned long shifted_address = record.get_address(); + uint32_t shifted_address = record.get_address(); if (address_shift) { if (shifted_address & ((1 << address_shift) - 1)) { fatal_error ( - "address 0x%04lX not aligned on %d byte boundary", + "address 0x%04X not aligned on %d byte boundary", shifted_address, (1 << address_shift) ); diff --git a/srecord/output/file/motorola.h b/srecord/output/file/motorola.h index e064f13a..d254a6bc 100644 --- a/srecord/output/file/motorola.h +++ b/srecord/output/file/motorola.h @@ -91,7 +91,7 @@ class output_file_motorola: * number of output data lines have occurred to date. This is used * at the end of the file to emit an S5 record. */ - unsigned long data_count{0}; + uint32_t data_count{0}; /** * The pref_block_size instance variable is used to remember the @@ -148,7 +148,7 @@ class output_file_motorola: * @param data_nbytes * The number of bytes of payload. */ - void write_inner(int tag, unsigned long address, int address_nbytes, + void write_inner(int tag, uint32_t address, int address_nbytes, const void *data, int data_nbytes); public: diff --git a/srecord/output/file/msbin.cc b/srecord/output/file/msbin.cc index de6c0f74..e7e849ee 100644 --- a/srecord/output/file/msbin.cc +++ b/srecord/output/file/msbin.cc @@ -69,7 +69,7 @@ srecord::output_file_msbin::create(const std::string &a_file_name) void srecord::output_file_msbin::write_dword_le(uint32_t d) { - unsigned char c[sizeof(uint32_t)]; + uint8_t c[sizeof(uint32_t)]; srecord::record::encode_little_endian(c, d, sizeof(c)); @@ -79,7 +79,7 @@ srecord::output_file_msbin::write_dword_le(uint32_t d) uint32_t -srecord::output_file_msbin::checksum(const unsigned char *data, size_t len) +srecord::output_file_msbin::checksum(const uint8_t *data, size_t len) { uint32_t sum = 0; @@ -94,7 +94,7 @@ void srecord::output_file_msbin::write_file_header(uint32_t start, uint32_t length) { // Write magic - static const unsigned char Magic[7] = + static const uint8_t Magic[7] = { 'B', '0', '0', '0', 'F', 'F', '\n' }; for (size_t i = 0; i < sizeof(Magic); ++i) put_char(Magic[i]); @@ -118,7 +118,7 @@ srecord::output_file_msbin::write_record_header(uint32_t addr, uint32_t length, void srecord::output_file_msbin::write_record_data(const record &r) { - const unsigned char *data = r.get_data(); + const uint8_t *data = r.get_data(); size_t length = r.get_length(); while (length-- > 0) put_char(*data++); @@ -230,7 +230,7 @@ srecord::output_file_msbin::append_pending_record(const record &r) void -srecord::output_file_msbin::notify_upper_bound(unsigned long addr) +srecord::output_file_msbin::notify_upper_bound(uint32_t addr) { upper_bound = addr; } @@ -251,8 +251,8 @@ srecord::output_file_msbin::write(const srecord::record &record) case srecord::record::type_data: if (beginning_of_file) { - const unsigned long start = record.get_address(); - const unsigned long length = upper_bound - start; + const uint32_t start = record.get_address(); + const uint32_t length = upper_bound - start; write_file_header(start, length); beginning_of_file = false; } diff --git a/srecord/output/file/msbin.h b/srecord/output/file/msbin.h index a0b8908b..cae72e53 100644 --- a/srecord/output/file/msbin.h +++ b/srecord/output/file/msbin.h @@ -86,7 +86,7 @@ class output_file_msbin: const char *format_name() const override; // See base class for documentation. - void notify_upper_bound(unsigned long addr) override; + void notify_upper_bound(uint32_t addr) override; // See base class for documentation. bool is_binary() const override; @@ -120,7 +120,7 @@ class output_file_msbin: * @param len * The length of the data to be check-summed. */ - static uint32_t checksum(const unsigned char *data, size_t len); + static uint32_t checksum(const uint8_t *data, size_t len); /** * The write_file_header method is used to write the file header diff --git a/srecord/output/file/needham.cc b/srecord/output/file/needham.cc index c0523724..caf48c7a 100644 --- a/srecord/output/file/needham.cc +++ b/srecord/output/file/needham.cc @@ -54,7 +54,7 @@ srecord::output_file_needham::write(const srecord::record &record) case srecord::record::type_header: // ignore if (!enable_optional_address_flag) - address = (unsigned long)-1L; + address = (uint32_t)-1L; break; case srecord::record::type_data: @@ -75,7 +75,7 @@ srecord::output_file_needham::write(const srecord::record &record) width = 3; if (width < address_length) width = address_length; - put_stringf("$A%0*lX,\n", width * 2, address); + put_stringf("$A%0*X,\n", width * 2, address); column = 0; } for (size_t j = 0; j < record.get_length(); ++j) diff --git a/srecord/output/file/needham.h b/srecord/output/file/needham.h index e73e4c49..af29a91f 100644 --- a/srecord/output/file/needham.h +++ b/srecord/output/file/needham.h @@ -82,7 +82,7 @@ class output_file_needham: * The address instance variable is used to remember where in the * file the output has reached. This is used to fill gaps. */ - unsigned long address{0}; + uint32_t address{0}; /** * The column instance variable is used to remember the column of diff --git a/srecord/output/file/os65v.cc b/srecord/output/file/os65v.cc index cd1b37fd..b906f9b0 100644 --- a/srecord/output/file/os65v.cc +++ b/srecord/output/file/os65v.cc @@ -84,12 +84,12 @@ srecord::output_file_os65v::write(const srecord::record &record) ) { address = record.get_address(); - put_stringf(".%04lX/", address); + put_stringf(".%04X/", address); state = '/'; } for (size_t j = 0; j < record.get_length(); ++j) { - unsigned char n = record.get_data(j); + uint8_t n = record.get_data(j); if (address == 0x00FD && n == 0) { // Actually, it's probably a bad idea to write on any of @@ -119,7 +119,7 @@ srecord::output_file_os65v::write(const srecord::record &record) if (address != record.get_address() || state == 0) { address = record.get_address(); - put_stringf(".%04lX", address); + put_stringf(".%04X", address); state = '.'; } put_char('G'); diff --git a/srecord/output/file/os65v.h b/srecord/output/file/os65v.h index 5f6bb5ae..00082bfc 100644 --- a/srecord/output/file/os65v.h +++ b/srecord/output/file/os65v.h @@ -86,7 +86,7 @@ class output_file_os65v: * The address instance variable is used to remember the current * file location. */ - unsigned long address{0}; + uint32_t address{0}; /** * The output mode is either address mode ('.') or data mode ('/'). diff --git a/srecord/output/file/ppb.cc b/srecord/output/file/ppb.cc index 5f5a8209..88ed8c2c 100644 --- a/srecord/output/file/ppb.cc +++ b/srecord/output/file/ppb.cc @@ -63,8 +63,8 @@ srecord::output_file_ppb::write(const srecord::record &record) case srecord::record::type_data: for (size_t j = 0; j < record.get_length(); ++j) { - unsigned char data = record.get_data(j); - unsigned long data_address = record.get_address() + j; + uint8_t data = record.get_data(j); + uint32_t data_address = record.get_address() + j; if (data_address != address) { @@ -125,7 +125,7 @@ srecord::output_file_ppb::format_name() void -srecord::output_file_ppb::put_bin_4be(unsigned long value) +srecord::output_file_ppb::put_bin_4be(uint32_t value) { put_char(value >> 24); put_char(value >> 16); @@ -134,8 +134,8 @@ srecord::output_file_ppb::put_bin_4be(unsigned long value) } -unsigned char -srecord::output_file_ppb::sum_ulong(unsigned long value, unsigned char sum) +uint8_t +srecord::output_file_ppb::sum_ulong(uint32_t value, uint8_t sum) { sum += (value >> 24); sum += (value >> 16); @@ -147,8 +147,8 @@ srecord::output_file_ppb::sum_ulong(unsigned long value, unsigned char sum) void -srecord::output_file_ppb::packet(unsigned long address, - const unsigned char *data, size_t data_size) +srecord::output_file_ppb::packet(uint32_t address, + const uint8_t *data, size_t data_size) { enum { SOH = 1 }; enum { CSLEN = 1024 }; @@ -157,7 +157,7 @@ srecord::output_file_ppb::packet(unsigned long address, put_bin_4be(data_size); put_bin_4be(address); - unsigned char chksum = sum_ulong(data_size, 0); + uint8_t chksum = sum_ulong(data_size, 0); chksum = sum_ulong(address, chksum); for (size_t j = 0; j < data_size; ++j) diff --git a/srecord/output/file/ppb.h b/srecord/output/file/ppb.h index 3e7341d8..bd42048c 100644 --- a/srecord/output/file/ppb.h +++ b/srecord/output/file/ppb.h @@ -82,13 +82,13 @@ class output_file_ppb: * The address instance variable is used to remember the address of * the next data byte to be parsed. */ - unsigned long address{-1UL}; + uint32_t address{-1U}; /** * The buffer instance variable is used to remember the accumulated * data bytes to be written to the file. */ - unsigned char buffer[8192]{}; + uint8_t buffer[8192]{}; /** * The buffer_length instance variable is used to remember how many @@ -112,19 +112,19 @@ class output_file_ppb: * The packet method is used to write out the #buffer as an * appropriately constructed packet. */ - void packet(unsigned long address, const unsigned char *data, + void packet(uint32_t address, const uint8_t *data, size_t data_size); /** * The put_bin_4be method is used to write out 4 binary bytes of a * 32-bit value, big endian ordering. */ - void put_bin_4be(unsigned long value); + void put_bin_4be(uint32_t value); /** * 8-bit checksum a 4 byte sequence. */ - unsigned char sum_ulong(unsigned long value, unsigned char sum); + uint8_t sum_ulong(uint32_t value, uint8_t sum); public: /** diff --git a/srecord/output/file/ppx.cc b/srecord/output/file/ppx.cc index e31bdacc..9a4918ae 100644 --- a/srecord/output/file/ppx.cc +++ b/srecord/output/file/ppx.cc @@ -81,8 +81,8 @@ srecord::output_file_ppx::write(const srecord::record &record) } for (size_t j = 0; j < record.get_length(); ++j) { - unsigned char data = record.get_data(j); - unsigned long data_address = record.get_address() + j; + uint8_t data = record.get_data(j); + uint32_t data_address = record.get_address() + j; if (data_address >= (1UL << 16)) data_address_too_large(record, 16); diff --git a/srecord/output/file/ppx.h b/srecord/output/file/ppx.h index 2f8f6025..86c97170 100644 --- a/srecord/output/file/ppx.h +++ b/srecord/output/file/ppx.h @@ -85,7 +85,7 @@ class output_file_ppx: * The address instance variable is used to remember the address of * the next data byte to be parsed. */ - unsigned long address{0}; + uint32_t address{0}; /** * The line_length instance variable is used to remember how long @@ -103,7 +103,7 @@ class output_file_ppx: * The dsum instance variable is used to remember the simple sum of * all the data bytes, but not the address bytes. */ - unsigned short dsum{0}; + uint16_t dsum{0}; public: /** diff --git a/srecord/output/file/signetics.cc b/srecord/output/file/signetics.cc index 51b2e02f..0a854d50 100644 --- a/srecord/output/file/signetics.cc +++ b/srecord/output/file/signetics.cc @@ -46,7 +46,7 @@ srecord::output_file_signetics::create(const std::string &a_file_name) void -srecord::output_file_signetics::checksum_add(unsigned char n) +srecord::output_file_signetics::checksum_add(uint8_t n) { checksum ^= n; checksum = (checksum << 1) | ((checksum >> 7) & 1); diff --git a/srecord/output/file/signetics.h b/srecord/output/file/signetics.h index 38e1d856..c8536b52 100644 --- a/srecord/output/file/signetics.h +++ b/srecord/output/file/signetics.h @@ -84,7 +84,7 @@ class output_file_signetics: * See base class for documentation. We over-ride the base * implementation because signetics uses its own XOR-ROL algorithm. */ - void checksum_add(unsigned char) override; + void checksum_add(uint8_t) override; private: /** @@ -99,13 +99,13 @@ class output_file_signetics: * address immediately beyond the last address of data in the file. * This is used to write the file termination record. */ - unsigned long last_address{0}; + uint32_t last_address{0}; /** * The write_inner method is used to write one line/record to the * output. It is called by the write() method. */ - void write_inner(int, unsigned long, int, const void *, int); + void write_inner(int, uint32_t, int, const void *, int); public: /** diff --git a/srecord/output/file/spectrum.cc b/srecord/output/file/spectrum.cc index 89f97876..2096e835 100644 --- a/srecord/output/file/spectrum.cc +++ b/srecord/output/file/spectrum.cc @@ -44,16 +44,16 @@ srecord::output_file_spectrum::create(const std::string &a_file_name) void -srecord::output_file_spectrum::put_decimal(unsigned long n) +srecord::output_file_spectrum::put_decimal(uint32_t n) { - put_stringf("%4.4lu", n); + put_stringf("%4.4u", n); } void -srecord::output_file_spectrum::put_binary(unsigned char n) +srecord::output_file_spectrum::put_binary(uint8_t n) { - for (unsigned char bit = 0x80; bit; bit >>= 1) + for (uint8_t bit = 0x80; bit; bit >>= 1) { put_char((n & bit) ? '1' : '0'); } @@ -72,7 +72,7 @@ srecord::output_file_spectrum::write(const srecord::record &record) case srecord::record::type_data: { - unsigned long address = record.get_address(); + uint32_t address = record.get_address(); int length = record.get_length(); for (int j = 0; j < length; ++j) { diff --git a/srecord/output/file/spectrum.h b/srecord/output/file/spectrum.h index 5618c2ed..2690dd2d 100644 --- a/srecord/output/file/spectrum.h +++ b/srecord/output/file/spectrum.h @@ -84,14 +84,14 @@ class output_file_spectrum: * the output, as a decimal (base 10) number. It will have at * least four digits. */ - void put_decimal(unsigned long); + void put_decimal(uint32_t); /** * The put_binary method is used to write the binary data to the * output, as a binary (base 2) number. It will have exactly * eight digits. */ - void put_binary(unsigned char); + void put_binary(uint8_t); public: /** diff --git a/srecord/output/file/stewie.cc b/srecord/output/file/stewie.cc index 22e594cd..f93d823f 100644 --- a/srecord/output/file/stewie.cc +++ b/srecord/output/file/stewie.cc @@ -54,7 +54,7 @@ srecord::output_file_stewie::create(const std::string &a_file_name) void -srecord::output_file_stewie::put_byte(unsigned char n) +srecord::output_file_stewie::put_byte(uint8_t n) { put_char(n); checksum_add(n); @@ -62,7 +62,7 @@ srecord::output_file_stewie::put_byte(unsigned char n) void -srecord::output_file_stewie::write_inner(int tag, unsigned long address, +srecord::output_file_stewie::write_inner(int tag, uint32_t address, int address_nbytes, const void *data, int data_nbytes) { // @@ -81,7 +81,7 @@ srecord::output_file_stewie::write_inner(int tag, unsigned long address, // // Assemble the data for this record. // - unsigned char buffer[256]; + uint8_t buffer[256]; int line_length = address_nbytes + data_nbytes + 1; buffer[0] = line_length; srecord::record::encode_big_endian(buffer + 1, address, address_nbytes); diff --git a/srecord/output/file/stewie.h b/srecord/output/file/stewie.h index 280f2228..a570a055 100644 --- a/srecord/output/file/stewie.h +++ b/srecord/output/file/stewie.h @@ -77,7 +77,7 @@ class output_file_stewie: bool preferred_block_size_set(int nbytes) override; // See base class for documentation. - void put_byte(unsigned char) override; + void put_byte(uint8_t) override; // See base class for documentation. const char *format_name() const override; @@ -87,7 +87,7 @@ class output_file_stewie: * The data_count instance variable is used to remember how many * data records have occurred so far in the output file. */ - unsigned long data_count{0}; + uint32_t data_count{0}; /** * The address_length instance variable is used to remember the @@ -104,7 +104,7 @@ class output_file_stewie: /** * Write a data record. */ - void write_inner(int, unsigned long, int, const void *, int); + void write_inner(int, uint32_t, int, const void *, int); public: /** diff --git a/srecord/output/file/tektronix.cc b/srecord/output/file/tektronix.cc index 6de5bc01..0e1f0ebb 100644 --- a/srecord/output/file/tektronix.cc +++ b/srecord/output/file/tektronix.cc @@ -45,7 +45,7 @@ srecord::output_file_tektronix::put_nibble(int n) void -srecord::output_file_tektronix::put_byte(unsigned char n) +srecord::output_file_tektronix::put_byte(uint8_t n) { // This differs from srecord::output_file::put_byte only in that it // doesn't add to the checksum. @@ -55,7 +55,7 @@ srecord::output_file_tektronix::put_byte(unsigned char n) void -srecord::output_file_tektronix::write_inner(unsigned long address, +srecord::output_file_tektronix::write_inner(uint32_t address, const void *data, int data_nbytes) { // @@ -68,7 +68,7 @@ srecord::output_file_tektronix::write_inner(unsigned long address, // Emit the line as hexadecimal text. // put_char('/'); - unsigned char tmp[2]; + uint8_t tmp[2]; srecord::record::encode_big_endian(tmp, address, 2); checksum_reset(); put_byte(tmp[0]); @@ -78,7 +78,7 @@ srecord::output_file_tektronix::write_inner(unsigned long address, if (data_nbytes) { checksum_reset(); - const auto *data_p = (const unsigned char *)data; + const auto *data_p = (const uint8_t *)data; for (int j = 0; j < data_nbytes; ++j) put_byte(data_p[j]); put_byte(checksum_get()); @@ -118,10 +118,10 @@ srecord::output_file_tektronix::write(const srecord::record &record) { if (record.get_address() >= (1UL << 16)) { - unsigned long addr = record.get_address(); + uint32_t addr = record.get_address(); fatal_error ( - "execution start address (0x%08lX > 0xFFFF) too large", + "execution start address (0x%08X > 0xFFFF) too large", addr ); } diff --git a/srecord/output/file/tektronix.h b/srecord/output/file/tektronix.h index d5894cb6..85ad0fde 100644 --- a/srecord/output/file/tektronix.h +++ b/srecord/output/file/tektronix.h @@ -79,7 +79,7 @@ class output_file_tektronix: void put_nibble(int); // See base class for documentation. - void put_byte(unsigned char) override; + void put_byte(uint8_t) override; // See base class for documentation. const char *format_name() const override; @@ -102,7 +102,7 @@ class output_file_tektronix: * @param data_nbytes * The number of bytes of payload. */ - void write_inner(unsigned long address, const void *data, int data_nbytes); + void write_inner(uint32_t address, const void *data, int data_nbytes); public: /** diff --git a/srecord/output/file/tektronix_extended.cc b/srecord/output/file/tektronix_extended.cc index ac0b130b..b9556ded 100644 --- a/srecord/output/file/tektronix_extended.cc +++ b/srecord/output/file/tektronix_extended.cc @@ -38,11 +38,11 @@ srecord::output_file_tektronix_extended::create(const std::string &a_file_name) void srecord::output_file_tektronix_extended::write_inner(int tag, - unsigned long addr, int addr_nbytes, const void *data_p, int data_nbytes) + uint32_t addr, int addr_nbytes, const void *data_p, int data_nbytes) { if (addr_nbytes < address_length) addr_nbytes = address_length; - unsigned char buf[260]; + uint8_t buf[260]; int record_length = 6 + (addr_nbytes + data_nbytes) * 2; if (record_length >= 256) { @@ -64,7 +64,7 @@ srecord::output_file_tektronix_extended::write_inner(int tag, int j; for (j = 0; j < 2 * addr_nbytes; ++j) csum += buf[pos++] = (addr >> (4 * (2*addr_nbytes-1 - j))) & 15; - const auto *data = (const unsigned char *)data_p; + const auto *data = (const uint8_t *)data_p; for (j = 0; j < data_nbytes; ++j) { csum += buf[pos++] = (data[j] >> 4) & 15; @@ -88,7 +88,7 @@ srecord::output_file_tektronix_extended::write_inner(int tag, static int -addr_width(unsigned long n) +addr_width(uint32_t n) { if (n < (1UL << 16)) return 2; diff --git a/srecord/output/file/tektronix_extended.h b/srecord/output/file/tektronix_extended.h index 6064d200..fb5663d8 100644 --- a/srecord/output/file/tektronix_extended.h +++ b/srecord/output/file/tektronix_extended.h @@ -106,7 +106,7 @@ class output_file_tektronix_extended: * @param data_nbytes * The number of bytes of payload. */ - void write_inner(int tag, unsigned long address, int address_nbytes, + void write_inner(int tag, uint32_t address, int address_nbytes, const void *data, int data_nbytes); public: diff --git a/srecord/output/file/ti_tagged.cc b/srecord/output/file/ti_tagged.cc index 0eec7f2e..d276e89c 100644 --- a/srecord/output/file/ti_tagged.cc +++ b/srecord/output/file/ti_tagged.cc @@ -61,7 +61,7 @@ srecord::output_file_ti_tagged::put_char(int c) } else { - csum += (unsigned char)c; + csum += (uint8_t)c; ++column; } inherited::put_char(c); @@ -86,18 +86,18 @@ srecord::output_file_ti_tagged::write(const srecord::record &record) if (enable_header_flag) { put_stringf("K%4.4X", (unsigned)(5 + record.get_length())); - const unsigned char *cp = record.get_data(); - const unsigned char *ep = cp + record.get_length(); + const uint8_t *cp = record.get_data(); + const uint8_t *ep = cp + record.get_length(); while (cp < ep) { - unsigned char c = *cp++; + uint8_t c = *cp++; if (!isprint(c)) c = ' '; put_char(c); } } if (!enable_optional_address_flag) - address = (unsigned long)-1; + address = (uint32_t)-1; break; case srecord::record::type_data: diff --git a/srecord/output/file/ti_tagged.h b/srecord/output/file/ti_tagged.h index 687e789f..973c32e1 100644 --- a/srecord/output/file/ti_tagged.h +++ b/srecord/output/file/ti_tagged.h @@ -88,7 +88,7 @@ class output_file_ti_tagged: * The address instance variable is used to remember the current * address within the output file. */ - unsigned long address{0}; + uint32_t address{0}; /** * The column instance variable is used to remember the current diff --git a/srecord/output/file/ti_tagged_16.cc b/srecord/output/file/ti_tagged_16.cc index 5bdce2cf..91b278b9 100644 --- a/srecord/output/file/ti_tagged_16.cc +++ b/srecord/output/file/ti_tagged_16.cc @@ -60,7 +60,7 @@ srecord::output_file_ti_tagged_16::put_char(int c) } else { - csum += (unsigned char)c; + csum += (uint8_t)c; ++column; } inherited::put_char(c); @@ -86,18 +86,18 @@ srecord::output_file_ti_tagged_16::write(const srecord::record &record) if (enable_header_flag) { put_stringf("K%4.4X", (int)(5 + record.get_length())); - const unsigned char *cp = record.get_data(); - const unsigned char *ep = cp + record.get_length(); + const uint8_t *cp = record.get_data(); + const uint8_t *ep = cp + record.get_length(); while (cp < ep) { - unsigned char c = *cp++; + uint8_t c = *cp++; if (!isprint(c)) c = ' '; put_char(c); } } if (!enable_optional_address_flag) - address = (unsigned long)-1L; + address = (uint32_t)-1L; break; case srecord::record::type_data: diff --git a/srecord/output/file/ti_tagged_16.h b/srecord/output/file/ti_tagged_16.h index 5d92576d..11afce39 100644 --- a/srecord/output/file/ti_tagged_16.h +++ b/srecord/output/file/ti_tagged_16.h @@ -88,7 +88,7 @@ class output_file_ti_tagged_16: * The address instance variable is used to remember the current * address within the output file. */ - unsigned long address{0}; + uint32_t address{0}; /** * The column instance variable is used to remember the current diff --git a/srecord/output/file/ti_txt.cc b/srecord/output/file/ti_txt.cc index da62d85c..449ccbe6 100644 --- a/srecord/output/file/ti_txt.cc +++ b/srecord/output/file/ti_txt.cc @@ -47,7 +47,7 @@ srecord::output_file_ti_txt::create(const std::string &a_file_name) void -srecord::output_file_ti_txt::put_byte_wrap(unsigned char c) +srecord::output_file_ti_txt::put_byte_wrap(uint8_t c) { if (column && column + 3 > line_length) { @@ -96,7 +96,7 @@ srecord::output_file_ti_txt::write(const srecord::record &record) if (width < address_length) width = address_length; width *= 2; - put_stringf("@%0*lX\n", width, address); + put_stringf("@%0*X\n", width, address); } for (size_t j = 0; j < record.get_length(); ++j) { diff --git a/srecord/output/file/ti_txt.h b/srecord/output/file/ti_txt.h index 2c10fb84..9877ce87 100644 --- a/srecord/output/file/ti_txt.h +++ b/srecord/output/file/ti_txt.h @@ -84,7 +84,7 @@ class output_file_ti_txt: * are up to in the output. Used to limit the number of @ lines * emitted. */ - unsigned long address{0}; + uint32_t address{0}; /** * The address_set instance variable is used to remember whether or @@ -131,7 +131,7 @@ class output_file_ti_txt: * considering the line_length and throwing a newline if necessary. * The address is advanced by one. The column is adjusted, too. */ - void put_byte_wrap(unsigned char c); + void put_byte_wrap(uint8_t c); public: /** diff --git a/srecord/output/file/trs80.cc b/srecord/output/file/trs80.cc index b4486054..4e4281a3 100644 --- a/srecord/output/file/trs80.cc +++ b/srecord/output/file/trs80.cc @@ -50,7 +50,7 @@ srecord::output_file_trs80::create(const std::string &a_file_name) void -srecord::output_file_trs80::put_byte(unsigned char n) +srecord::output_file_trs80::put_byte(uint8_t n) { put_char(n); ++byte_offset; diff --git a/srecord/output/file/trs80.h b/srecord/output/file/trs80.h index a875de67..ed71eba4 100644 --- a/srecord/output/file/trs80.h +++ b/srecord/output/file/trs80.h @@ -97,13 +97,13 @@ class output_file_trs80: * method also tracks the byte_offset, so that we can align to * specific boundaries. Calls the checksum_add() method. */ - void put_byte(unsigned char) override; + void put_byte(uint8_t) override; /** * The byte_offset instance variable is used to track the location * in the output file. Maintained by the put_byte() method. */ - unsigned long byte_offset{}; + uint32_t byte_offset{}; /** * The pref_block_size is used to remember the preferred diff --git a/srecord/output/file/vhdl.cc b/srecord/output/file/vhdl.cc index 9ef22540..4a9e708e 100644 --- a/srecord/output/file/vhdl.cc +++ b/srecord/output/file/vhdl.cc @@ -59,8 +59,8 @@ srecord::output_file_vhdl::command_line(srecord::arglex_tool *cmdln) if (a1 > 0) { auto a2 = (unsigned)a1; - if (a2 > sizeof(unsigned long)) - a2 = sizeof(unsigned long); + if (a2 > sizeof(uint32_t)) + a2 = sizeof(uint32_t); bytes_per_word = a2; } } @@ -132,14 +132,14 @@ srecord::output_file_vhdl::write(const srecord::record &record) put_string("-- "); if (record.get_address() != 0) { - unsigned long addr = record.get_address(); - put_stringf("%08lX: ", addr); + uint32_t addr = record.get_address(); + put_stringf("%08X: ", addr); } - const unsigned char *cp = record.get_data(); - const unsigned char *ep = cp + record.get_length(); + const uint8_t *cp = record.get_data(); + const uint8_t *ep = cp + record.get_length(); while (cp < ep) { - unsigned char c = *cp++; + uint8_t c = *cp++; if (c == '\n') { put_string("\n-- "); @@ -179,10 +179,10 @@ srecord::output_file_vhdl::write(const srecord::record &record) current_word = (current_word << 8) + record.get_data(j + k); put_stringf ( - " %lu => %s_entry(%lu),\n", - (unsigned long)((record.get_address() + j) / bytes_per_word), + " %u => %s_entry(%u),\n", + (uint32_t)((record.get_address() + j) / bytes_per_word), prefix.c_str(), - (unsigned long)current_word + (uint32_t)current_word ); } break; diff --git a/srecord/output/file/vmem.cc b/srecord/output/file/vmem.cc index ded8672e..1e4e86e7 100644 --- a/srecord/output/file/vmem.cc +++ b/srecord/output/file/vmem.cc @@ -151,14 +151,14 @@ srecord::output_file_vmem::write(const srecord::record &record) put_string("/* "); if (record.get_address() != 0) { - unsigned long addr = record.get_address(); - put_stringf("%08lX: ", addr); + uint32_t addr = record.get_address(); + put_stringf("%08X: ", addr); } - const unsigned char *cp = record.get_data(); - const unsigned char *ep = cp + record.get_length(); + const uint8_t *cp = record.get_data(); + const uint8_t *ep = cp + record.get_length(); while (cp < ep) { - unsigned char c = *cp++; + uint8_t c = *cp++; if (c == '\n') put_stringf("\n * "); else if (isprint(c) || isspace(c)) @@ -172,7 +172,7 @@ srecord::output_file_vmem::write(const srecord::record &record) put_string(" */\n"); } if (!enable_optional_address_flag) - address = (unsigned long)-1L; + address = (uint32_t)-1L; break; case srecord::record::type_data: @@ -216,7 +216,7 @@ srecord::output_file_vmem::write(const srecord::record &record) // address is an address, and not a data byte. // if (column == 0) - put_stringf("@%08lX", address >> width_shift); + put_stringf("@%08X", address >> width_shift); // // Put a space between each word diff --git a/srecord/output/file/vmem.h b/srecord/output/file/vmem.h index bc6d255b..d0c34543 100644 --- a/srecord/output/file/vmem.h +++ b/srecord/output/file/vmem.h @@ -92,7 +92,7 @@ class output_file_vmem: * The address instance variable is used to remember where we are * up to in the output. */ - unsigned long address; + uint32_t address; /** * The column instance variable is used to remember which column diff --git a/srecord/output/file/wilson.cc b/srecord/output/file/wilson.cc index e9475045..1f52ef9e 100644 --- a/srecord/output/file/wilson.cc +++ b/srecord/output/file/wilson.cc @@ -42,7 +42,7 @@ srecord::output_file_wilson::create(const std::string &a_file_name) void -srecord::output_file_wilson::put_byte(unsigned char n) +srecord::output_file_wilson::put_byte(uint8_t n) { static const char *table[256] = { @@ -85,7 +85,7 @@ srecord::output_file_wilson::put_byte(unsigned char n) void -srecord::output_file_wilson::write_inner(int tag, unsigned long address, +srecord::output_file_wilson::write_inner(int tag, uint32_t address, const void *data, int data_nbytes) { // @@ -97,7 +97,7 @@ srecord::output_file_wilson::write_inner(int tag, unsigned long address, // // Assemble the data for this line. // - unsigned char buffer[256]; + uint8_t buffer[256]; int line_length = data_nbytes + 5; buffer[0] = line_length; srecord::record::encode_big_endian(buffer + 1, address, 4); diff --git a/srecord/output/file/wilson.h b/srecord/output/file/wilson.h index 161bb254..3c64f1d8 100644 --- a/srecord/output/file/wilson.h +++ b/srecord/output/file/wilson.h @@ -82,7 +82,7 @@ class output_file_wilson: bool preferred_block_size_set(int nbytes) override; // See base class for documentation. - void put_byte(unsigned char) override; + void put_byte(uint8_t) override; // See base class for documentation. const char *format_name() const override; @@ -110,7 +110,7 @@ class output_file_wilson: * @param data_nbytes * The number of bytes of payload. */ - void write_inner(int tag, unsigned long address, const void *data, + void write_inner(int tag, uint32_t address, const void *data, int data_nbytes); public: diff --git a/srecord/output/filter.cc b/srecord/output/filter.cc index c290f8b3..36068280 100644 --- a/srecord/output/filter.cc +++ b/srecord/output/filter.cc @@ -78,7 +78,7 @@ srecord::output_filter::format_name() void -srecord::output_filter::notify_upper_bound(unsigned long addr) +srecord::output_filter::notify_upper_bound(uint32_t addr) { deeper->notify_upper_bound(addr); } diff --git a/srecord/output/filter.h b/srecord/output/filter.h index ed3bdde4..25bdbbdd 100644 --- a/srecord/output/filter.h +++ b/srecord/output/filter.h @@ -69,7 +69,7 @@ class output_filter: const char *format_name() const override; // See base class for documentation. - void notify_upper_bound(unsigned long addr) override; + void notify_upper_bound(uint32_t addr) override; // See base class for documentation. void command_line(arglex_tool *cmdln) override; diff --git a/srecord/output/filter/reblock.cc b/srecord/output/filter/reblock.cc index e849014c..f27e4fc9 100644 --- a/srecord/output/filter/reblock.cc +++ b/srecord/output/filter/reblock.cc @@ -44,7 +44,7 @@ srecord::output_filter_reblock::output_filter_reblock( // will fill it up before we deeper->write it, this will minimize // the number of memmove() calls. buffer_max = 1 << 14; - buffer = new unsigned char [buffer_max]; + buffer = new uint8_t [buffer_max]; assert(buffer_max > 2 * record::max_data_length); } diff --git a/srecord/output/filter/reblock.h b/srecord/output/filter/reblock.h index 037a3eb1..4670ae5a 100644 --- a/srecord/output/filter/reblock.h +++ b/srecord/output/filter/reblock.h @@ -106,7 +106,7 @@ class output_filter_reblock: * byte address of the first byte of the output buffer. Not * meaningful if #buffer_pos is zero. */ - unsigned long buffer_address{0}; + uint32_t buffer_address{0}; /** * The buffer instance variable is used to remember the base @@ -116,7 +116,7 @@ class output_filter_reblock: * * assert(!buffer == !buffer_max); */ - unsigned char *buffer{0}; + uint8_t *buffer{0}; /** * The buffer_pos instance variable is used to remember how many diff --git a/srecord/quit/normal.cc b/srecord/quit/normal.cc index 7f3bc46a..7823e9e9 100644 --- a/srecord/quit/normal.cc +++ b/srecord/quit/normal.cc @@ -47,7 +47,7 @@ srecord::quit_normal::message_v(const char *fmt, va_list ap) char *cp = buf; for (;;) { - unsigned char c = *cp++; + uint8_t c = *cp++; if (!c) break; if (isspace(c) || !isprint(c)) diff --git a/srecord/r250.cc b/srecord/r250.cc index d167da01..127abf34 100644 --- a/srecord/r250.cc +++ b/srecord/r250.cc @@ -23,8 +23,8 @@ #include #include -static unsigned long buf[250]; -static unsigned long *pos; +static uint32_t buf[250]; +static uint32_t *pos; static inline int @@ -39,13 +39,13 @@ rand32() { return ( - ((unsigned long)rand8() << 24) + ((uint32_t)rand8() << 24) | - ((unsigned long)rand8() << 16) + ((uint32_t)rand8() << 16) | - ((unsigned long)rand8() << 8) + ((uint32_t)rand8() << 8) | - (unsigned long)rand8() + (uint32_t)rand8() ); } @@ -73,14 +73,14 @@ r250_init() // // initialise contents of array // - unsigned long *bp; + uint32_t *bp; for (bp = buf; bp < ENDOF(buf); ++bp) *bp = rand32(); // // make sure the bits are linearly independent // - unsigned long bit; + uint32_t bit; for (bit = 1, bp = buf + 3; bit; bp += 11, bit <<= 1) { if (bp >= ENDOF(buf)) @@ -90,16 +90,16 @@ r250_init() } -unsigned long +uint32_t srecord::r250() { if (!ready) r250_init(); - unsigned long *other = pos + 103; + uint32_t *other = pos + 103; if (other >= ENDOF(buf)) other -= SIZEOF(buf); *pos ^= *other; - unsigned long result = *pos++; + uint32_t result = *pos++; if (pos >= ENDOF(buf)) pos = buf; return result; diff --git a/srecord/r250.h b/srecord/r250.h index 23977161..97c29cff 100644 --- a/srecord/r250.h +++ b/srecord/r250.h @@ -19,6 +19,8 @@ #ifndef SRECORD_R250_H #define SRECORD_R250_H +#include + namespace srecord { @@ -26,7 +28,7 @@ namespace srecord * The r250 function is used to produce a 32-bit random number. * It repeats every 2**256 samples, long enough for most purposes. */ -unsigned long r250(); +uint32_t r250(); }; diff --git a/srecord/record.cc b/srecord/record.cc index 9e4067b2..e3fbd65d 100644 --- a/srecord/record.cc +++ b/srecord/record.cc @@ -28,9 +28,10 @@ srecord::record::record(const srecord::record &arg) : address(arg.address), length(arg.length) { - if (arg.length > 0) + if (arg.length > 0) { memcpy(data, arg.data, arg.length); } +} srecord::record::record(type_t arg) : diff --git a/srecord/stm32.cc b/srecord/stm32.cc index f66b772c..a64ebd7a 100644 --- a/srecord/stm32.cc +++ b/srecord/stm32.cc @@ -68,8 +68,8 @@ srecord::stm32::operator=(const stm32 &arg) // The STM32 hardware CRC calculation uses CRC polynomial 0x04C11DB7 // and operates only on words. // -static unsigned long -stm32_crc(unsigned long crc, unsigned long data) +static uint32_t +stm32_crc(uint32_t crc, uint32_t data) { crc ^= data; for (int j = 0; j < 32; ++j) @@ -86,7 +86,7 @@ stm32_crc(unsigned long crc, unsigned long data) void srecord::stm32::generator() { - unsigned long data = 0; + uint32_t data = 0; for (size_t j = 0; j < wordsize; j++) data |= (buf[j] << (8 * j)); state = stm32_crc(state, data); @@ -95,7 +95,7 @@ srecord::stm32::generator() void -srecord::stm32::next(unsigned char x) +srecord::stm32::next(uint8_t x) { buf[cnt++] = x; if (cnt == wordsize) @@ -106,7 +106,7 @@ srecord::stm32::next(unsigned char x) void srecord::stm32::nextbuf(const void *data, size_t nbytes) { - const auto *dp = (const unsigned char *)data; + const auto *dp = (const uint8_t *)data; while (nbytes > 0) { --nbytes; @@ -115,7 +115,7 @@ srecord::stm32::nextbuf(const void *data, size_t nbytes) } -unsigned long +uint32_t srecord::stm32::get() const { diff --git a/srecord/stm32.h b/srecord/stm32.h index adf14dbc..1e42ecea 100644 --- a/srecord/stm32.h +++ b/srecord/stm32.h @@ -29,6 +29,7 @@ #define SRECORD_STM32_H #include +#include namespace srecord { @@ -66,12 +67,12 @@ class stm32 * The get method is used to obtain the running value of the cyclic * redundancy check. */ - unsigned long get() const; + uint32_t get() const; /** * The next method is used to advance the state by one byte. */ - void next(unsigned char c); + void next(uint8_t c); /** * The nextbuf method is used to advance the state by a series of bytes. @@ -95,7 +96,7 @@ class stm32 * The state instance variable is used to remember the running * value of the 32-bit cyclic redundancy check. */ - unsigned long state{0xFFFFFFFF}; + uint32_t state{0xFFFFFFFF}; /** * Current counter of the byte feeding @@ -106,7 +107,7 @@ class stm32 * Buffer the incoming stream to build a word to feed to the * CRC generator. */ - unsigned char buf[wordsize]{}; + uint8_t buf[wordsize]{}; }; }; diff --git a/srecord/string/quote_c.cc b/srecord/string/quote_c.cc index 071850a9..48237110 100644 --- a/srecord/string/quote_c.cc +++ b/srecord/string/quote_c.cc @@ -27,7 +27,7 @@ srecord::string_quote_c(const std::string &arg) const char *cp = arg.c_str(); for (;;) { - unsigned char c = *cp++; + uint8_t c = *cp++; switch (c) { case '\0': @@ -55,7 +55,7 @@ srecord::string_quote_c(const std::string &arg) break; default: - if (isprint((unsigned char)c)) + if (isprint((uint8_t)c)) result += c; else { diff --git a/srecord/string/url_decode.cc b/srecord/string/url_decode.cc index 7331d69f..9a4bdf6b 100644 --- a/srecord/string/url_decode.cc +++ b/srecord/string/url_decode.cc @@ -68,7 +68,7 @@ srecord::string_url_decode(const std::string &text) std::stringstream result; while (cur < end) { - unsigned char c = *cur++; + uint8_t c = *cur++; if (c == '%') { if (end - cur >= 1 && *cur == '%') diff --git a/srecord/string/url_encode.cc b/srecord/string/url_encode.cc index aac83c53..40451866 100644 --- a/srecord/string/url_encode.cc +++ b/srecord/string/url_encode.cc @@ -33,7 +33,7 @@ nibble(unsigned x) static bool -needs_quoting(unsigned char x) +needs_quoting(uint8_t x) { if (x == '%') return true; @@ -52,7 +52,7 @@ srecord::string_url_encode(const std::string &text) std::stringstream result; while (cur < end) { - unsigned char c = *cur++; + uint8_t c = *cur++; if (needs_quoting(c)) { result << '%'; diff --git a/test/crc16/main.cc b/test/crc16/main.cc index 5130cbdc..6a1de678 100644 --- a/test/crc16/main.cc +++ b/test/crc16/main.cc @@ -56,7 +56,7 @@ main(int argc, char **argv) srecord::progname_set(argv[0]); srecord::crc16::seed_mode_t seed_mode = srecord::crc16::seed_mode_ccitt; bool augment = true; - unsigned short polynomial = srecord::crc16::polynomial_ccitt; + uint16_t polynomial = srecord::crc16::polynomial_ccitt; bool print_table = false; srecord::crc16::bit_direction_t bitdir = srecord::crc16::bit_direction_most_to_least; diff --git a/test/fletcher16/main.cc b/test/fletcher16/main.cc index d9a4cde3..7acb91c9 100644 --- a/test/fletcher16/main.cc +++ b/test/fletcher16/main.cc @@ -34,8 +34,8 @@ usage() int main(int argc, char **argv) { - unsigned char sum1 = 0xFF; - unsigned char sum2 = 0xFF; + uint8_t sum1 = 0xFF; + uint8_t sum2 = 0xFF; int answer = -1; if (argc == 2 && argv[1][0] == '-') return 0; diff --git a/test/hyphen/main.cc b/test/hyphen/main.cc index 275958de..dff748cd 100644 --- a/test/hyphen/main.cc +++ b/test/hyphen/main.cc @@ -45,7 +45,7 @@ read_one_line(const char *filename, FILE *fp, std::string &result) } if (c == '\n') return true; - result += (unsigned char)c; + result += (uint8_t)c; } } @@ -76,7 +76,7 @@ check(const char *filename) const char *cp = line.c_str(); for (;;) { - unsigned char c = *cp++; + uint8_t c = *cp++; switch (c) { case '\0': diff --git a/test/url_decode/main.cc b/test/url_decode/main.cc index e84e0fbd..817ede54 100644 --- a/test/url_decode/main.cc +++ b/test/url_decode/main.cc @@ -49,7 +49,7 @@ test_url_decode() if (!fgets(buf, sizeof(buf), stdin)) break; size_t len = strlen(buf); - while (len > 0 && isspace((unsigned char)buf[len - 1])) + while (len > 0 && isspace((uint8_t)buf[len - 1])) --len; std::string s(buf, len); printf("%s\n", srecord::string_url_decode(s).c_str()); @@ -66,7 +66,7 @@ test_url_encode() if (!fgets(buf, sizeof(buf), stdin)) break; size_t len = strlen(buf); - while (len > 0 && isspace((unsigned char)buf[len - 1])) + while (len > 0 && isspace((uint8_t)buf[len - 1])) --len; std::string s(buf, len); printf("%s\n", srecord::string_url_encode(s).c_str()); @@ -94,7 +94,7 @@ main(int argc, char **argv) if (c == -1) break; - switch ((unsigned char)c) + switch ((uint8_t)c) { case 'd': func = test_url_decode;