Skip to content

Commit b1b81da

Browse files
committedJan 15, 2023
C++: Apply misc readability fixes
Command: ~~~sh run-clang-tidy-14 -header-filter='.*' -checks='-*,readability-redundant-access-specifiers,readability-container-size-empty,readability-static-accessed-through-instance,readability-delete-null-pointer,readability-isolate-declaration' -fix ~~~ Afterwards fix white spaces (newline, indentation).
1 parent 92ab05f commit b1b81da

File tree

12 files changed

+24
-21
lines changed

12 files changed

+24
-21
lines changed
 

‎srec_info/main.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ main(int argc, char **argv)
6262
}
6363
cmdline.token_next();
6464
}
65-
if (infile.size() == 0U)
65+
if (infile.empty())
6666
infile.push_back(cmdline.get_input());
6767

6868
std::cout << std::hex << std::uppercase;

‎srecord/arglex.h

-1
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,6 @@ class arglex
348348
*/
349349
void read_arguments_file(const char *filename);
350350

351-
private:
352351
typedef std::list<std::string> deprecated_options_t;
353352

354353
/**

‎srecord/arglex/tool/input.cc

+8-4
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,8 @@ srecord::arglex_tool::get_input()
598598
endian_t end = get_endian_by_token();
599599
token_next();
600600
unsigned long address;
601-
int nbytes, width;
601+
int nbytes;
602+
int width;
602603
get_address_nbytes_width(name, address, nbytes, width);
603604
ifp =
604605
input_filter_checksum_bitnot::create
@@ -619,7 +620,8 @@ srecord::arglex_tool::get_input()
619620
endian_t end = get_endian_by_token();
620621
token_next();
621622
unsigned long address;
622-
int nbytes, width;
623+
int nbytes;
624+
int width;
623625
get_address_nbytes_width(name, address, nbytes, width);
624626
ifp =
625627
input_filter_checksum_negative::create
@@ -640,7 +642,8 @@ srecord::arglex_tool::get_input()
640642
endian_t end = get_endian_by_token();
641643
token_next();
642644
unsigned long address;
643-
int nbytes, width;
645+
int nbytes;
646+
int width;
644647
get_address_nbytes_width(name, address, nbytes, width);
645648
ifp =
646649
input_filter_checksum_positive::create
@@ -807,7 +810,8 @@ srecord::arglex_tool::get_input()
807810
bool inclusive = get_inclusive_by_token();
808811
token_next();
809812
unsigned long address;
810-
int nbytes, width;
813+
int nbytes;
814+
int width;
811815
get_address_nbytes_width(name, address, nbytes, width);
812816
ifp =
813817
input_filter_interval_length::create

‎srecord/input/file.h

-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ class input_file:
7777
// See base class for documentation.
7878
void disable_checksum_validation();
7979

80-
protected:
8180
/**
8281
* The constructor. The input will be taken from the named file
8382
* (or the standard input if the filename is "-").

‎srecord/input/file/aomf.cc

+2-3
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,7 @@ o96name(int x)
115115

116116
srecord::input_file_aomf::~input_file_aomf()
117117
{
118-
if (current_buffer)
119-
delete [] current_buffer;
118+
delete [] current_buffer;
120119
}
121120

122121

@@ -165,7 +164,7 @@ srecord::input_file_aomf::slurp()
165164
--length; // includes checksum byte
166165
if (length > current_maximum)
167166
{
168-
if (current_buffer)
167+
169168
delete [] current_buffer;
170169
while (current_maximum < length)
171170
current_maximum = current_maximum * 2 + 64;

‎srecord/input/file/hp64k.cc

+9-3
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,10 @@ srecord::input_file_hp64k::read_u16be(uint16_t *dest)
9898
bool
9999
srecord::input_file_hp64k::read_datarec(record &result)
100100
{
101-
uint16_t recsize, datasize;
102-
uint16_t load_l, load_h;
101+
uint16_t recsize;
102+
uint16_t datasize;
103+
uint16_t load_l;
104+
uint16_t load_h;
103105
size_t tmp_addr;
104106

105107
if (!read_u16be(&recsize))
@@ -197,7 +199,11 @@ srecord::input_file_hp64k::read_hdr(record &result)
197199
bool
198200
srecord::input_file_hp64k::read_pir(record &result)
199201
{
200-
uint16_t pirlen, width, base, xfer_l, xfer_h;
202+
uint16_t pirlen;
203+
uint16_t width;
204+
uint16_t base;
205+
uint16_t xfer_l;
206+
uint16_t xfer_h;
201207
uint32_t xfer;
202208

203209
if (!read_u16be(&pirlen))

‎srecord/input/file/intel.cc

+1-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@
2323

2424
srecord::input_file_intel::~input_file_intel()
2525
{
26-
if (pushback)
27-
delete pushback;
26+
delete pushback;
2827
}
2928

3029

‎srecord/input/file/ti_tagged.h

-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ class input_file_ti_tagged:
7373
*/
7474
int get_char();
7575

76-
private:
7776
typedef input_file inherited;
7877

7978
/**

‎srecord/input/file/wilson.h

-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ class input_file_wilson:
7878
*/
7979
input_file_wilson(const std::string &file_name);
8080

81-
private:
8281
/**
8382
* The read_inner method is used to read a record from the input.
8483
* The #read method is a wrapper around this method.

‎srecord/input/filter/message/gcrypt.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class input_filter_message_gcrypt:
6060
input_filter_message_gcrypt(const input::pointer &deeper,
6161
unsigned long address, int algo, bool hmac);
6262

63-
private:
63+
6464
/**
6565
* The create class method is used to create a new dynamically
6666
* allocated instance of this class.

‎srecord/memory.cc

+1-2
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@ srecord::memory::clear()
8080
execution_start_address = 0;
8181
for (int j = 0; j < nchunks; ++j)
8282
delete chunk[j];
83-
if (chunk)
84-
delete [] chunk;
83+
delete [] chunk;
8584
nchunks = 0;
8685
nchunks_max = 0;
8786
chunk = 0;

‎srecord/quit/prefix.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ srecord::quit_prefix::exit(int n)
5151
void
5252
srecord::quit_prefix::message_v(const char *fmt, va_list ap)
5353
{
54-
if (prefix != "")
54+
if (!prefix.empty())
5555
{
5656
char buf[1024];
5757
vsnprintf(buf, sizeof(buf), fmt, ap);

0 commit comments

Comments
 (0)
Please sign in to comment.