From c933d239f5e9239aee851f119f9b87abeae1b17d Mon Sep 17 00:00:00 2001 From: Couriersud Date: Mon, 27 Feb 2017 21:46:10 +0100 Subject: Fix some cppcheck warnings. (nw) --- src/lib/netlist/build/makefile | 24 +++++++++++++++++++ src/lib/netlist/nl_base.cpp | 16 ++++++------- src/lib/netlist/nl_base.h | 46 ++++++++++++++++++------------------- src/lib/netlist/plib/pexception.cpp | 2 +- src/lib/netlist/plib/pexception.h | 8 +++---- 5 files changed, 60 insertions(+), 36 deletions(-) diff --git a/src/lib/netlist/build/makefile b/src/lib/netlist/build/makefile index 6399458d287..101442c46a3 100644 --- a/src/lib/netlist/build/makefile +++ b/src/lib/netlist/build/makefile @@ -10,6 +10,8 @@ ########################################################################### SRC = .. +VSBUILD = $(SRC)/buildVS +DOC = $(SRC)/documentation ifeq ($(subst Windows_NT,windows,$(OS)),windows) OBJ = obj/mingw @@ -130,11 +132,33 @@ NLOBJS := \ $(NLOBJ)/solver/nld_solver.o \ $(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 #------------------------------------------------- diff --git a/src/lib/netlist/nl_base.cpp b/src/lib/netlist/nl_base.cpp index 6905629ddd5..7d91c57c7c0 100644 --- a/src/lib/netlist/nl_base.cpp +++ b/src/lib/netlist/nl_base.cpp @@ -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, "") { } diff --git a/src/lib/netlist/nl_base.h b/src/lib/netlist/nl_base.h index 002d02869ed..7122f71cf0f 100644 --- a/src/lib/netlist/nl_base.h +++ b/src/lib/netlist/nl_base.h @@ -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 NETLIB_NAME(cname)(CLASS &owner, const pstring name) \ + public: template 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 NETLIB_NAME(cname)(CLASS &owner, const pstring name) \ + public: template 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 NETLIB_NAME(cname)(CLASS &owner, const pstring name, __VA_ARGS__) \ + public: template 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 //! 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 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 ¶m) { 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 ¶m) { 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 ¶m) { 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 ¶m, const pstring name) + value_t(param_model_t ¶m, 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 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 - C *get_single_device(const pstring classname) + C *get_single_device(const pstring &classname) { return dynamic_cast(get_single_device(classname, check_class)); } @@ -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 - inline param_rom_t::param_rom_t(device_t &device, const pstring name) + inline param_rom_t::param_rom_t(device_t &device, const pstring &name) : param_data_t(device, name) { auto f = stream(); @@ -1468,7 +1468,7 @@ namespace netlist template template - state_var::state_var(O &owner, const pstring name, const T &value) + state_var::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 template - state_var::state_var(O &owner, const pstring name, const T & value) + state_var::state_var(O &owner, const pstring &name, const T & value) { owner.netlist().save(owner, m_value, name); for (std::size_t i=0; i