src/xx: cppcheck

This commit is contained in:
Gwenhael Goavec-Merou 2023-04-15 08:20:05 +02:00
parent 3ca60dd14d
commit 0a9e8a7e4b
24 changed files with 45 additions and 36 deletions

View File

@ -107,11 +107,11 @@ int AnlogicBitParser::parse()
_bit_data.clear();
for (auto it = blocks.begin(); it != blocks.end(); it++) {
for (size_t pos = 0; pos < it->size(); pos++) {
for (size_t xpos = 0; xpos < it->size(); xpos++) {
if (_reverseOrder == true)
_bit_data += reverseByte(((*it)[pos]));
_bit_data += reverseByte(((*it)[xpos]));
else
_bit_data += ((*it)[pos]);
_bit_data += ((*it)[xpos]);
}
}
_bit_length = _bit_data.size() * 8;

View File

@ -38,7 +38,7 @@ int BitParser::parseHeader()
int pos_data = 0;
int ret = 1;
short length;
string tmp(64, ' ');
string tmp;
int pos, prev_pos;
/* Field 1 : misc header */

View File

@ -30,7 +30,8 @@ using namespace std;
#endif
CH552_jtag::CH552_jtag(const cable_t &cable,
string dev, const string &serial, uint32_t clkHZ, uint8_t verbose):
const string &dev, const string &serial, uint32_t clkHZ,
uint8_t verbose):
FTDIpp_MPSSE(cable, dev, serial, clkHZ, verbose), _to_read(0)
{
init_internal(cable.config);

View File

@ -23,7 +23,7 @@
class CH552_jtag : public JtagInterface, private FTDIpp_MPSSE {
public:
CH552_jtag(const cable_t &cable, std::string dev,
CH552_jtag(const cable_t &cable, const std::string &dev,
const std::string &serial, uint32_t clkHZ, uint8_t verbose = false);
virtual ~CH552_jtag();

View File

@ -20,7 +20,7 @@
#define KCYN "\x1B[36m"
#define KWHT "\x1B[37m"
void printError(std::string err, bool eol)
void printError(const std::string &err, bool eol)
{
if (isatty(STDERR_FILENO))
std::cerr << KRED << err << "\e[0m";
@ -31,7 +31,7 @@ void printError(std::string err, bool eol)
std::cerr << std::endl;
}
void printWarn(std::string warn, bool eol)
void printWarn(const std::string &warn, bool eol)
{
if (isatty(STDOUT_FILENO))
std::cout << KYEL << warn << "\e[0m" << std::flush;
@ -42,7 +42,7 @@ void printWarn(std::string warn, bool eol)
std::cout << std::endl;
}
void printInfo(std::string info, bool eol)
void printInfo(const std::string &info, bool eol)
{
if (isatty(STDOUT_FILENO))
std::cout << KBLUL << info << "\e[0m" << std::flush;
@ -53,7 +53,7 @@ void printInfo(std::string info, bool eol)
std::cout << std::endl;
}
void printSuccess(std::string success, bool eol)
void printSuccess(const std::string &success, bool eol)
{
if (isatty(STDOUT_FILENO))
std::cout << KGRN << success << "\e[0m" << std::flush;

View File

@ -9,9 +9,9 @@
#include <iostream>
#include <string>
void printError(std::string err, bool eol = true);
void printWarn(std::string warn, bool eol = true);
void printInfo(std::string info, bool eol = true);
void printSuccess(std::string success, bool eol = true);
void printError(const std::string &err, bool eol = true);
void printWarn(const std::string &warn, bool eol = true);
void printInfo(const std::string &info, bool eol = true);
void printSuccess(const std::string &success, bool eol = true);
#endif // DISPLAY_HPP_

View File

@ -65,7 +65,7 @@
using namespace std;
FeaParser::FeaParser(string filename, bool verbose):
FeaParser::FeaParser(const string &filename, bool verbose):
ConfigBitstreamParser(filename, ConfigBitstreamParser::BIN_MODE, verbose),
_feabits(0), _has_feabits(false)
{

View File

@ -17,7 +17,7 @@
class FeaParser: public ConfigBitstreamParser {
public:
FeaParser(std::string filename, bool verbose = false);
FeaParser(const std::string &filename, bool verbose = false);
int parse() override;
void displayHeader() override;

View File

@ -31,8 +31,8 @@ using namespace std;
#endif
FtdiJtagBitBang::FtdiJtagBitBang(const cable_t &cable,
const jtag_pins_conf_t *pin_conf, string dev, const std::string &serial,
uint32_t clkHZ, uint8_t verbose):
const jtag_pins_conf_t *pin_conf, const string &dev,
const std::string &serial, uint32_t clkHZ, uint8_t verbose):
FTDIpp_MPSSE(cable, dev, serial, clkHZ, verbose), _bitmode(0),
_curr_tms(0), _rx_size(0)
{

View File

@ -24,8 +24,8 @@
class FtdiJtagBitBang : public JtagInterface, private FTDIpp_MPSSE {
public:
FtdiJtagBitBang(const cable_t &cable,
const jtag_pins_conf_t *pin_conf, std::string dev, const std::string &serial,
uint32_t clkHZ, uint8_t verbose = 0);
const jtag_pins_conf_t *pin_conf, const std::string &dev,
const std::string &serial, uint32_t clkHZ, uint8_t verbose = 0);
virtual ~FtdiJtagBitBang();
int setClkFreq(uint32_t clkHZ) override;

View File

@ -31,7 +31,7 @@ using namespace std;
#endif
FtdiJtagMPSSE::FtdiJtagMPSSE(const cable_t &cable,
string dev, const string &serial, uint32_t clkHZ,
const string &dev, const string &serial, uint32_t clkHZ,
bool invert_read_edge, int8_t verbose):
FTDIpp_MPSSE(cable, dev, serial, clkHZ, verbose), _ch552WA(false),
_write_mode(MPSSE_WRITE_NEG), // always write on neg edge

View File

@ -23,7 +23,7 @@
class FtdiJtagMPSSE : public JtagInterface, public FTDIpp_MPSSE {
public:
FtdiJtagMPSSE(const cable_t &cable, std::string dev,
FtdiJtagMPSSE(const cable_t &cable, const std::string &dev,
const std::string &serial, uint32_t clkHZ, bool invert_read_edge,
int8_t verbose = 0);
virtual ~FtdiJtagMPSSE();

View File

@ -31,7 +31,7 @@
using namespace std;
JedParser::JedParser(string filename, bool verbose):
JedParser::JedParser(const string &filename, bool verbose):
ConfigBitstreamParser(filename, ConfigBitstreamParser::BIN_MODE, verbose),
_fuse_count(0), _pin_count(0), _max_vect_test(0),
_featuresRow(0), _feabits(0), _has_feabits(false), _checksum(0),
@ -168,7 +168,7 @@ void JedParser::displayHeader()
printf("Fuse Count : %d\n", _fuse_count);
for (size_t i = 0; i < _data_list.size(); i++) {
printf("area[%zd] %4d %4d ", i, _data_list[i].offset, _data_list[i].len);
printf("area[%zu] %4d %4d ", i, _data_list[i].offset, _data_list[i].len);
printf("%zu ", _data_list[i].data.size());
for (size_t ii = 0; ii < _data_list[i].data.size(); ii++)
for (size_t iii = 0; iii < _data_list[i].data[ii].size(); iii++)

View File

@ -25,7 +25,7 @@ class JedParser: public ConfigBitstreamParser {
};
public:
JedParser(std::string filename, bool verbose = false);
JedParser(const std::string &filename, bool verbose = false);
int parse() override;
void displayHeader() override;

View File

@ -215,6 +215,9 @@ int JetsonNanoJtagBitbang::writeTMS(uint8_t *tms_buf, uint32_t len,
{
int tms;
if (len == 0) // nothing -> stop
return len;
for (uint32_t i = 0; i < len; i++) {
tms = ((tms_buf[i >> 3] & (1 << (i & 7))) ? 1 : 0);

View File

@ -70,7 +70,8 @@ using namespace std;
* - envoyer le dernier avec 0x4B ou 0x6B
*/
Jtag::Jtag(const cable_t &cable, const jtag_pins_conf_t *pin_conf, string dev,
Jtag::Jtag(const cable_t &cable, const jtag_pins_conf_t *pin_conf,
const string &dev,
const string &serial, uint32_t clkHZ, int8_t verbose,
const string &ip_adr, int port,
const bool invert_read_edge, const string &firmware_path):

View File

@ -16,7 +16,8 @@
class Jtag {
public:
Jtag(const cable_t &cable, const jtag_pins_conf_t *pin_conf, std::string dev,
Jtag(const cable_t &cable, const jtag_pins_conf_t *pin_conf,
const std::string &dev,
const std::string &serial, uint32_t clkHZ, int8_t verbose,
const std::string &ip_adr, int port,
const bool invert_read_edge = false,

View File

@ -883,7 +883,7 @@ bool Lattice::wr_rd(uint8_t cmd,
uint8_t xfer_rx[kXferLen];
memset(xfer_tx, 0, kXferLen);
int i;
if (tx) {
if (tx != NULL && tx_len > 0) {
for (i = 0; i < tx_len; i++)
xfer_tx[i] = tx[i];
}

View File

@ -175,6 +175,9 @@ int LibgpiodJtagBitbang::writeTMS(uint8_t *tms_buf, uint32_t len,
{
int tms;
if (len == 0) // nothing -> stop
return len;
for (uint32_t i = 0; i < len; i++) {
tms = ((tms_buf[i >> 3] & (1 << (i & 7))) ? 1 : 0);

View File

@ -139,7 +139,7 @@ uint32_t POFParser::parseSection(uint16_t flag, uint32_t pos, uint32_t size)
_bit_data.begin());
_bit_length = size * 8;
if (_verbose)
printf("size %u %lu\n", size, _bit_data.size());
printf("size %u %zu\n", size, _bit_data.size());
break;
case 0x1a: // flash sections
// 12Bytes ?

View File

@ -10,12 +10,13 @@
#include "progressBar.hpp"
#include "display.hpp"
ProgressBar::ProgressBar(std::string mess, int maxValue, int progressLen,
bool quiet): _mess(mess), _maxValue(maxValue),
_progressLen(progressLen), _quiet(quiet), _first(true)
ProgressBar::ProgressBar(const std::string &mess, int maxValue,
int progressLen, bool quiet): _mess(mess), _maxValue(maxValue),
_progressLen(progressLen), last_time(std::chrono::system_clock::now()),
_quiet(quiet), _first(true)
{
last_time = std::chrono::system_clock::now();
}
void ProgressBar::display(int value, char force)
{
if (_quiet) {

View File

@ -10,7 +10,7 @@
class ProgressBar {
public:
ProgressBar(std::string mess, int maxValue, int progressLen,
ProgressBar(const std::string &mess, int maxValue, int progressLen,
bool quiet = false);
void display(int value, char force = 0);
void done();

View File

@ -135,7 +135,7 @@ Xilinx::Xilinx(Jtag *jtag, const std::string &filename,
SPIInterface(filename, verbose, 256, verify, skip_load_bridge,
skip_reset),
_device_package(device_package), _spiOverJtagPath(spiOverJtagPath),
_irlen(6), _filename(filename), _secondary_filename(secondary_filename)
_irlen(6), _secondary_filename(secondary_filename)
{
if (prg_type == Device::RD_FLASH) {
_mode = Device::READ_MODE;

View File

@ -208,7 +208,6 @@ class Xilinx: public Device, SPIInterface {
char _cpld_base_name[7]; /**< cpld name (without package size) */
int _irlen; /**< IR bit length */
std::map<std::string, std::vector<uint8_t>> _ircode_map; /**< bscan instructions based on model */
std::string _filename; /* path to the primary flash file */
std::string _secondary_filename; /* path to the secondary flash file (SPIx8) */
std::string _secondary_file_extension; /* file type for the secondary flash file */
int _flash_chips; /* bitfield to select the target in boards with two flash chips */