Skip to content

Commit

Permalink
[Modernization] Addressed PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
SeanAlling-DojoFive committed Mar 8, 2023
1 parent cead6ba commit f25f2fd
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 21 deletions.
10 changes: 7 additions & 3 deletions srecord/adler16.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,25 @@

#include <srecord/adler16.h>

uint16_t srecord::adler16::get() const
uint16_t
srecord::adler16::get()
const
{
return ((((uint16_t)sum_b) << 8) | sum_a);
}


void srecord::adler16::next(uint8_t c)
void
srecord::adler16::next(uint8_t c)
{
// This is not portable to int=16-bit machines
sum_a = (sum_a + c) % 251;
sum_b = (sum_b + sum_a) % 251;
}


void srecord::adler16::nextbuf(const void *data, size_t nbytes)
void
srecord::adler16::nextbuf(const void *data, size_t nbytes)
{
const auto *dp = (const uint8_t *)data;
while (nbytes > 0)
Expand Down
4 changes: 3 additions & 1 deletion srecord/adler32.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@

#include <srecord/adler32.h>

uint32_t srecord::adler32::get() const
uint32_t
srecord::adler32::get()
const
{
return ((((uint32_t)sum_b) << 16) | sum_a);
}
Expand Down
4 changes: 2 additions & 2 deletions srecord/arglex/tool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ srecord::arglex_tool::get_address_and_nbytes(const char *name,
{
nbytes = get_number("byte count", 1, 8);
}
if ((long long)address + nbytes > (1LL << 32))
if ((uint64_t)address + nbytes > (1LL << 32))
{
fatal_error
(
Expand Down Expand Up @@ -326,7 +326,7 @@ srecord::arglex_tool::get_address_nbytes_width(const char *name,
width = get_number("width", 1, nbytes);
}
}
if ((long long)address + nbytes > (1LL << 32))
if ((uint64_t)address + nbytes > (1LL << 32))
{
fatal_error
(
Expand Down
2 changes: 1 addition & 1 deletion srecord/arglex/tool/get_interval_small.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ srecord::arglex_tool::get_interval_small(const char *caption)
}
if (!big_range_ok)
{
long long c = result.coverage();
uint64_t c = result.coverage();
if (c > (1LL << 30))
{
fatal_error
Expand Down
10 changes: 5 additions & 5 deletions srecord/input/file/intel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -134,20 +134,20 @@ srecord::input_file_intel::read_inner(srecord::record &record)
if
(
(
(long long)address_base + address_field
(uint64_t)address_base + address_field
<
((long long)1 << 32)
((uint64_t)1 << 32)
)
&&
(
(long long)address_base + address_field + buffer[0]
(uint64_t)address_base + address_field + buffer[0]
>
((long long)1 << 32)
((uint64_t)1 << 32)
)
)
{
int split =
((long long)1 << 32) - address_base - address_field;
((uint64_t)1 << 32) - address_base - address_field;
pushback =
new srecord::record
(
Expand Down
10 changes: 5 additions & 5 deletions srecord/input/file/intel16.cc
Original file line number Diff line number Diff line change
Expand Up @@ -139,20 +139,20 @@ srecord::input_file_intel16::read_inner(record &result)
if
(
(
(long long)address_base + address_field
(uint64_t)address_base + address_field
<
((long long)1 << 32)
((uint64_t)1 << 32)
)
&&
(
(long long)address_base + address_field + nbytes
(uint64_t)address_base + address_field + nbytes
>
((long long)1 << 32)
((uint64_t)1 << 32)
)
)
{
int split =
((long long)1 << 32) - address_base - address_field;
((uint64_t)1 << 32) - address_base - address_field;
pushback =
new record
(
Expand Down
2 changes: 1 addition & 1 deletion srecord/pretty_size.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@


std::string
srecord::pretty_size(long long x, int width)
srecord::pretty_size(int64_t x, int32_t width)
{
double tmp = x;
bool negative = false;
Expand Down
2 changes: 1 addition & 1 deletion srecord/pretty_size.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ namespace srecord
* @returns
* a string, including the suffix.
*/
std::string pretty_size(long long x, int width = 0);
std::string pretty_size(int64_t x, int32_t width=0);

};

Expand Down
3 changes: 1 addition & 2 deletions srecord/record.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@ 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) :
Expand Down

0 comments on commit f25f2fd

Please sign in to comment.