Fix some cppcheck warnings. (nw)

This commit is contained in:
Couriersud 2017-02-27 21:46:10 +01:00
parent 1ca4875436
commit c933d239f5
5 changed files with 60 additions and 36 deletions

View File

@ -10,6 +10,8 @@
###########################################################################
SRC = ..
VSBUILD = $(SRC)/buildVS
DOC = $(SRC)/documentation
ifeq ($(subst Windows_NT,windows,$(OS)),windows)
OBJ = obj/mingw
@ -131,10 +133,32 @@ NLOBJS := \
$(NLOBJ)/solver/nld_matrix_solver.o \
$(NLOBJ)/tools/nl_convert.o \
VSBUILDS = \
$(VSBUILD/netlistlib.vcxproj) \
$(VSBUILD/netlistlib.vcxproj.user \
$(VSBUILD/nltool.vcxproj \
$(VSBUILD/netlistlib.vcxproj.filters \
$(VSBUILD/nltool.vcxproj.filters \
$(VSBUILD/netlist.sln \
DOCS = \
doxygen.conf
$(DOC)/doc.css \
$(DOC)/mainpage.dox.h \
$(DOC)/primer_1.dox.h \
$(DOC)/structure.dox.h \
$(DOC)/test1-50r.svg \
ALL_OBJS = $(OBJS) $(PMAIN) $(NLOBJ)/prg/nltool.o $(NLOBJ)/prg/nlwav.o
SOURCES = $(patsubst $(OBJ)%, $(SRC)%, $(ALL_OBJS:.o=.cpp))
ALLFILES = $(SOURCES) $(VSBUILDS) $(DOCS)
MAKEFILE_TARGETS_WITHOUT_INCLUDE := clean doc clang mingw
# git archive HEAD --prefix=project-name-version/ \
# --format=zip -o project-name-version.zip
#-------------------------------------------------
# all
#-------------------------------------------------

View File

@ -641,7 +641,7 @@ void netlist_t::print_stats() const
}
}
core_device_t *netlist_t::get_single_device(const pstring classname, bool (*cc)(core_device_t *))
core_device_t *netlist_t::get_single_device(const pstring &classname, bool (*cc)(core_device_t *))
{
core_device_t *ret = nullptr;
for (auto &d : m_devices)
@ -764,7 +764,7 @@ void device_t::connect_post_start(detail::core_terminal_t &t1, detail::core_term
// family_setter_t
// -----------------------------------------------------------------------------
detail::family_setter_t::family_setter_t(core_device_t &dev, const pstring desc)
detail::family_setter_t::family_setter_t(core_device_t &dev, const pstring &desc)
{
dev.set_logic_family(dev.netlist().setup().family_from_model(desc));
}
@ -1186,7 +1186,7 @@ const pstring param_model_t::model_type()
return m_map["COREMODEL"];
}
param_str_t::param_str_t(device_t &device, const pstring name, const pstring val)
param_str_t::param_str_t(device_t &device, const pstring &name, const pstring &val)
: param_t(device, name)
{
m_param = device.setup().get_initial_param_val(this->name(),val);
@ -1200,7 +1200,7 @@ void param_str_t::changed()
{
}
param_double_t::param_double_t(device_t &device, const pstring name, const double val)
param_double_t::param_double_t(device_t &device, const pstring &name, const double val)
: param_t(device, name)
{
m_param = device.setup().get_initial_param_val(this->name(),val);
@ -1211,7 +1211,7 @@ param_double_t::~param_double_t()
{
}
#endif
param_int_t::param_int_t(device_t &device, const pstring name, const int val)
param_int_t::param_int_t(device_t &device, const pstring &name, const int val)
: param_t(device, name)
{
m_param = device.setup().get_initial_param_val(this->name(),val);
@ -1224,7 +1224,7 @@ param_int_t::~param_int_t()
}
#endif
param_logic_t::param_logic_t(device_t &device, const pstring name, const bool val)
param_logic_t::param_logic_t(device_t &device, const pstring &name, const bool val)
: param_t(device, name)
{
m_param = device.setup().get_initial_param_val(this->name(),val);
@ -1237,7 +1237,7 @@ param_logic_t::~param_logic_t()
}
#endif
param_ptr_t::param_ptr_t(device_t &device, const pstring name, uint8_t * val)
param_ptr_t::param_ptr_t(device_t &device, const pstring &name, uint8_t * val)
: param_t(device, name)
{
m_param = val; //device.setup().get_initial_param_val(this->name(),val);
@ -1270,7 +1270,7 @@ nl_double param_model_t::model_value(const pstring &entity)
return netlist().setup().model_value(m_map, entity);
}
param_data_t::param_data_t(device_t &device, const pstring name)
param_data_t::param_data_t(device_t &device, const pstring &name)
: param_str_t(device, name, "")
{
}

View File

@ -58,7 +58,7 @@ class NETLIB_NAME(name) : public device_t
#define NETLIB_CONSTRUCTOR_DERIVED(cname, pclass) \
private: detail::family_setter_t m_famsetter; \
public: template <class CLASS> NETLIB_NAME(cname)(CLASS &owner, const pstring name) \
public: template <class CLASS> NETLIB_NAME(cname)(CLASS &owner, const pstring &name) \
: NETLIB_NAME(pclass)(owner, name)
/*! Used to define the constructor of a netlist device.
@ -67,7 +67,7 @@ class NETLIB_NAME(name) : public device_t
*/
#define NETLIB_CONSTRUCTOR(cname) \
private: detail::family_setter_t m_famsetter; \
public: template <class CLASS> NETLIB_NAME(cname)(CLASS &owner, const pstring name) \
public: template <class CLASS> NETLIB_NAME(cname)(CLASS &owner, const pstring &name) \
: device_t(owner, name)
/*! Used to define the destructor of a netlist device.
@ -81,7 +81,7 @@ class NETLIB_NAME(name) : public device_t
*/
#define NETLIB_CONSTRUCTOR_EX(cname, ...) \
private: detail::family_setter_t m_famsetter; \
public: template <class CLASS> NETLIB_NAME(cname)(CLASS &owner, const pstring name, __VA_ARGS__) \
public: template <class CLASS> NETLIB_NAME(cname)(CLASS &owner, const pstring &name, __VA_ARGS__) \
: device_t(owner, name)
/*! Add this to a device definition to mark the device as dynamic.
@ -216,7 +216,7 @@ namespace netlist
/*! Constructor.
* Allows a descriptive text to be assed to the exception
*/
explicit nl_exception(const pstring text //!< text to be passed
explicit nl_exception(const pstring &text //!< text to be passed
)
: plib::pexception(text) { }
/*! Copy constructor. */
@ -314,7 +314,7 @@ namespace netlist
template <typename O>
//! Constructor.
state_var(O &owner, //!< owner must have a netlist() method.
const pstring name, //!< identifier/name for this state variable
const pstring &name, //!< identifier/name for this state variable
const T &value //!< Initial value after construction
);
//! Copy Constructor.
@ -350,7 +350,7 @@ namespace netlist
//! Constructor.
template <typename O>
state_var(O &owner, //!< owner must have a netlist() method.
const pstring name, //!< identifier/name for this state variable
const pstring &name, //!< identifier/name for this state variable
const T &value //!< Initial value after construction
);
//! Copy Constructor.
@ -398,7 +398,7 @@ namespace netlist
*
* Every class derived from the object_t class must have a name.
*/
object_t(const pstring &aname /*!< string containing name of the object */);
explicit object_t(const pstring &aname /*!< string containing name of the object */);
/*! return name of the object
*
@ -419,7 +419,7 @@ namespace netlist
struct detail::netlist_ref
{
netlist_ref(netlist_t &nl) : m_netlist(nl) { }
explicit netlist_ref(netlist_t &nl) : m_netlist(nl) { }
netlist_t & netlist() NL_NOEXCEPT { return m_netlist; }
const netlist_t & netlist() const NL_NOEXCEPT { return m_netlist; }
@ -917,7 +917,7 @@ namespace netlist
class param_ptr_t final: public param_t
{
public:
param_ptr_t(device_t &device, const pstring name, std::uint8_t* val);
param_ptr_t(device_t &device, const pstring &name, std::uint8_t* val);
std::uint8_t * operator()() const NL_NOEXCEPT { return m_param; }
void setTo(std::uint8_t *param) { set(m_param, param); }
private:
@ -927,7 +927,7 @@ namespace netlist
class param_logic_t final: public param_t
{
public:
param_logic_t(device_t &device, const pstring name, const bool val);
param_logic_t(device_t &device, const pstring &name, const bool val);
bool operator()() const NL_NOEXCEPT { return m_param; }
void setTo(const bool &param) { set(m_param, param); }
private:
@ -937,7 +937,7 @@ namespace netlist
class param_int_t final: public param_t
{
public:
param_int_t(device_t &device, const pstring name, const int val);
param_int_t(device_t &device, const pstring &name, const int val);
int operator()() const NL_NOEXCEPT { return m_param; }
void setTo(const int &param) { set(m_param, param); }
private:
@ -947,7 +947,7 @@ namespace netlist
class param_double_t final: public param_t
{
public:
param_double_t(device_t &device, const pstring name, const double val);
param_double_t(device_t &device, const pstring &name, const double val);
double operator()() const NL_NOEXCEPT { return m_param; }
void setTo(const double &param) { set(m_param, param); }
private:
@ -957,7 +957,7 @@ namespace netlist
class param_str_t : public param_t
{
public:
param_str_t(device_t &device, const pstring name, const pstring val);
param_str_t(device_t &device, const pstring &name, const pstring &val);
virtual ~param_str_t();
const pstring operator()() const NL_NOEXCEPT { return Value(); }
@ -984,7 +984,7 @@ namespace netlist
class value_t
{
public:
value_t(param_model_t &param, const pstring name)
value_t(param_model_t &param, const pstring &name)
{
m_value = param.model_value(name);
}
@ -996,7 +996,7 @@ namespace netlist
friend class value_t;
param_model_t(device_t &device, const pstring name, const pstring val)
param_model_t(device_t &device, const pstring &name, const pstring &val)
: param_str_t(device, name, val) { }
const pstring model_value_str(const pstring &entity) /*const*/;
@ -1014,7 +1014,7 @@ namespace netlist
class param_data_t : public param_str_t
{
public:
param_data_t(device_t &device, const pstring name);
param_data_t(device_t &device, const pstring &name);
std::unique_ptr<plib::pistream> stream();
protected:
@ -1030,7 +1030,7 @@ namespace netlist
{
public:
param_rom_t(device_t &device, const pstring name);
param_rom_t(device_t &device, const pstring &name);
const ST & operator[] (std::size_t n) { return m_data[n]; }
protected:
@ -1159,7 +1159,7 @@ namespace netlist
struct detail::family_setter_t
{
family_setter_t() { }
family_setter_t(core_device_t &dev, const pstring desc);
family_setter_t(core_device_t &dev, const pstring &desc);
family_setter_t(core_device_t &dev, const logic_family_desc_t *desc);
};
@ -1260,7 +1260,7 @@ namespace netlist
}
template<class C>
C *get_single_device(const pstring classname)
C *get_single_device(const pstring &classname)
{
return dynamic_cast<C *>(get_single_device(classname, check_class<C>));
}
@ -1305,7 +1305,7 @@ namespace netlist
static pstring from_utf8(const char *c) { return pstring(c, pstring::UTF8); }
static pstring from_utf8(const pstring &c) { return c; }
core_device_t *get_single_device(const pstring classname, bool (*cc)(core_device_t *));
core_device_t *get_single_device(const pstring &classname, bool (*cc)(core_device_t *));
/* mostly rw */
netlist_time m_time;
@ -1355,7 +1355,7 @@ namespace netlist
// -----------------------------------------------------------------------------
template <typename ST, std::size_t AW, std::size_t DW>
inline param_rom_t<ST, AW, DW>::param_rom_t(device_t &device, const pstring name)
inline param_rom_t<ST, AW, DW>::param_rom_t(device_t &device, const pstring &name)
: param_data_t(device, name)
{
auto f = stream();
@ -1468,7 +1468,7 @@ namespace netlist
template <typename T>
template <typename O>
state_var<T>::state_var(O &owner, const pstring name, const T &value)
state_var<T>::state_var(O &owner, const pstring &name, const T &value)
: m_value(value)
{
owner.netlist().save(owner, m_value, name);
@ -1476,7 +1476,7 @@ namespace netlist
template <typename T, std::size_t N>
template <typename O>
state_var<T[N]>::state_var(O &owner, const pstring name, const T & value)
state_var<T[N]>::state_var(O &owner, const pstring &name, const T & value)
{
owner.netlist().save(owner, m_value, name);
for (std::size_t i=0; i<N; i++)

View File

@ -30,7 +30,7 @@ pexception::~pexception() noexcept
{
}
file_e::file_e(const pstring fmt, const pstring &filename)
file_e::file_e(const pstring &fmt, const pstring &filename)
: pexception(pfmt(fmt)(filename))
{
}

View File

@ -21,7 +21,7 @@ class pexception : public std::exception
{
public:
explicit pexception(const pstring text);
pexception(const pexception &e) : std::exception(e) { m_text = e.m_text; }
pexception(const pexception &e) : std::exception(e), m_text(e.m_text) { }
virtual ~pexception() noexcept;
@ -34,7 +34,7 @@ private:
class file_e : public plib::pexception
{
public:
explicit file_e(const pstring fmt, const pstring &filename);
file_e(const pstring &fmt, const pstring &filename);
file_e(const file_e &e) : pexception(e) { }
virtual ~file_e() noexcept;
};
@ -86,7 +86,7 @@ public:
class fpexception_e : public pexception
{
public:
fpexception_e(const pstring &text);
explicit fpexception_e(const pstring &text);
fpexception_e(const fpexception_e &e) : pexception(e) { }
virtual ~fpexception_e() noexcept;
};
@ -105,7 +105,7 @@ static const unsigned FP_ALL = 0x0001f;
class fpsignalenabler
{
public:
fpsignalenabler(unsigned fpexceptions);
explicit fpsignalenabler(unsigned fpexceptions);
~fpsignalenabler();
/* is the functionality supported ? */