summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author couriersud <couriersud@gmx.org>2019-04-12 02:07:40 +0200
committer couriersud <couriersud@gmx.org>2019-04-12 14:00:46 +0200
commit106990d8c9b2d18e5ea29f2d4e21696c9ebb918a (patch)
treec53fda51e2248a7fb542daf7a0a3bd76072a7a1e
parent0fb11df50a00e2367da27016e0734f3c17aa966f (diff)
netlist: clang lint fixes and pedantic warning fixes. (nw)
-rw-r--r--src/lib/netlist/analog/nld_generic_models.h8
-rw-r--r--src/lib/netlist/analog/nlid_twoterm.h2
-rw-r--r--src/lib/netlist/plib/pfmtlog.cpp2
-rw-r--r--src/lib/netlist/plib/pparser.cpp2
-rw-r--r--src/lib/netlist/plib/ptime.h3
-rw-r--r--src/lib/netlist/plib/vector_ops.h6
-rw-r--r--src/lib/netlist/solver/nld_ms_sm.h16
-rw-r--r--src/lib/netlist/solver/nld_ms_w.h16
-rw-r--r--src/lib/netlist/tools/nl_convert.cpp2
9 files changed, 32 insertions, 25 deletions
diff --git a/src/lib/netlist/analog/nld_generic_models.h b/src/lib/netlist/analog/nld_generic_models.h
index c18452e1109..1edc4abd320 100644
--- a/src/lib/netlist/analog/nld_generic_models.h
+++ b/src/lib/netlist/analog/nld_generic_models.h
@@ -63,6 +63,7 @@ namespace analog
nl_double Ieq(nl_double cap, nl_double v) const
{
+ plib::unused_var(v);
//return -m_h * 0.5 * ((cap + m_c) * m_v + (cap - m_c) * v) ;
return -m_h * 0.5 * (cap + m_c) * m_v;
//return -m_h * cap * m_v;
@@ -98,10 +99,15 @@ namespace analog
capacitor_e type() const { return capacitor_e::CONSTANT_CAPACITY; }
nl_double G(nl_double cap) const { return cap * m_h + m_gmin; }
- nl_double Ieq(nl_double cap, nl_double v) const { return - G(cap) * m_v; }
+ nl_double Ieq(nl_double cap, nl_double v) const
+ {
+ plib::unused_var(v);
+ return - G(cap) * m_v;
+ }
void timestep(nl_double cap, nl_double v, nl_double step)
{
+ plib::unused_var(cap);
m_h = 1.0 / step;
m_v = v;
}
diff --git a/src/lib/netlist/analog/nlid_twoterm.h b/src/lib/netlist/analog/nlid_twoterm.h
index 5f900adb652..332c3af8900 100644
--- a/src/lib/netlist/analog/nlid_twoterm.h
+++ b/src/lib/netlist/analog/nlid_twoterm.h
@@ -36,8 +36,8 @@
#include "netlist/nl_base.h"
#include "netlist/nl_setup.h"
#include "netlist/solver/nld_solver.h"
-#include "plib/pfunction.h"
#include "nld_generic_models.h"
+#include "plib/pfunction.h"
#include <cmath>
diff --git a/src/lib/netlist/plib/pfmtlog.cpp b/src/lib/netlist/plib/pfmtlog.cpp
index af87251fbdf..a58ecd3113a 100644
--- a/src/lib/netlist/plib/pfmtlog.cpp
+++ b/src/lib/netlist/plib/pfmtlog.cpp
@@ -23,7 +23,7 @@ pfmt &pfmt::format_element(const char *l, const unsigned cfmt_spec, ...)
{
va_list ap;
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg)
- std::array<char, 2048> buf;
+ std::array<char, 2048> buf = {0};
std::size_t sl;
bool found_abs = false;
diff --git a/src/lib/netlist/plib/pparser.cpp b/src/lib/netlist/plib/pparser.cpp
index 55e4c74c778..2b7ec0001e4 100644
--- a/src/lib/netlist/plib/pparser.cpp
+++ b/src/lib/netlist/plib/pparser.cpp
@@ -516,7 +516,7 @@ pstring ppreprocessor::process_line(pstring line)
else
{
pstring arg("");
- for (int i=2; i<lti.size() - 1; i++)
+ for (std::size_t i=2; i<lti.size() - 1; i++)
arg += lti[i] + " ";
arg += lti[lti.size()-1];
m_defines.insert({lti[1], define_t(lti[1], arg)});
diff --git a/src/lib/netlist/plib/ptime.h b/src/lib/netlist/plib/ptime.h
index 250e1b8f683..6d91f14912b 100644
--- a/src/lib/netlist/plib/ptime.h
+++ b/src/lib/netlist/plib/ptime.h
@@ -10,6 +10,7 @@
#include "pconfig.h"
#include "ptypes.h"
+#include <cmath> // std::floor
#include <cstdint>
// ----------------------------------------------------------------------------------------
@@ -112,7 +113,7 @@ namespace plib
static constexpr ptime from_sec(const internal_type s) noexcept { return ptime(s, UINT64_C( 1)); }
static constexpr ptime from_hz(const internal_type hz) noexcept { return ptime(1 , hz); }
static constexpr ptime from_raw(const internal_type raw) noexcept { return ptime(raw); }
- static constexpr ptime from_double(const double t) noexcept { return ptime(static_cast<internal_type>(t * static_cast<double>(RES) + 0.5), RES); }
+ static constexpr ptime from_double(const double t) noexcept { return ptime(static_cast<internal_type>(std::floor(t * static_cast<double>(RES) + 0.5)), RES); }
static constexpr ptime zero() noexcept { return ptime(0, RES); }
static constexpr ptime quantum() noexcept { return ptime(1, RES); }
diff --git a/src/lib/netlist/plib/vector_ops.h b/src/lib/netlist/plib/vector_ops.h
index 8043c48f61c..d1d28261f5f 100644
--- a/src/lib/netlist/plib/vector_ops.h
+++ b/src/lib/netlist/plib/vector_ops.h
@@ -43,7 +43,7 @@ namespace plib
template<typename T, typename V1, typename V2>
T vec_mult(const std::size_t n, const V1 & v1, const V2 & v2 )
{
- using b8 = T[8];
+ using b8 = std::array<T, 8>;
PALIGNAS_VECTOROPT() b8 value = {0};
for (std::size_t i = 0; i < n ; i++ )
{
@@ -55,7 +55,7 @@ namespace plib
template<typename T, typename VT>
T vec_mult2(const std::size_t n, const VT &v)
{
- using b8 = T[8];
+ using b8 = std::array<T, 8>;
PALIGNAS_VECTOROPT() b8 value = {0};
for (std::size_t i = 0; i < n ; i++ )
{
@@ -77,7 +77,7 @@ namespace plib
}
else
{
- using b8 = T[8];
+ using b8 = std::array<T, 8>;
PALIGNAS_VECTOROPT() b8 value = {0};
for (std::size_t i = 0; i < n ; i++ )
value[i & 7] += v[i];
diff --git a/src/lib/netlist/solver/nld_ms_sm.h b/src/lib/netlist/solver/nld_ms_sm.h
index d85ab0044f4..5b59effecf8 100644
--- a/src/lib/netlist/solver/nld_ms_sm.h
+++ b/src/lib/netlist/solver/nld_ms_sm.h
@@ -71,7 +71,7 @@ namespace devices
void LE_invert();
template <typename T>
- void LE_compute_x(T * x);
+ void LE_compute_x(T & x);
template <typename T1, typename T2>
@@ -94,7 +94,7 @@ namespace devices
float_ext_type m_A[storage_N][m_pitch];
float_ext_type m_Ainv[storage_N][m_pitch];
float_ext_type m_W[storage_N][m_pitch];
- float_ext_type m_RHS[storage_N]; // right hand side - contains currents
+ std::array<float_ext_type, storage_N> m_RHS; // right hand side - contains currents
float_ext_type m_lA[storage_N][m_pitch];
float_ext_type m_lAinv[storage_N][m_pitch];
@@ -186,7 +186,7 @@ namespace devices
template <typename FT, int SIZE>
template <typename T>
void matrix_solver_sm_t<FT, SIZE>::LE_compute_x(
- T * x)
+ T & x)
{
const std::size_t kN = size();
@@ -208,7 +208,7 @@ namespace devices
static constexpr const bool incremental = true;
const std::size_t iN = size();
- float_type new_V[storage_N]; // = { 0.0 };
+ std::array<float_type, storage_N> new_V; // = { 0.0 };
if ((m_cnt % 50) == 0)
{
@@ -225,8 +225,8 @@ namespace devices
}
for (std::size_t row = 0; row < iN; row ++)
{
- float_type v[m_pitch] = {0};
- std::size_t cols[m_pitch];
+ std::array<float_type, m_pitch> v = {0};
+ std::array<std::size_t, m_pitch> cols;
std::size_t colcount = 0;
auto &nz = m_terms[row]->m_nz;
@@ -242,9 +242,9 @@ namespace devices
if (colcount > 0)
{
float_type lamba = 0.0;
- float_type w[m_pitch] = {0};
+ std::array<float_type, m_pitch> w = {0};
- float_type z[m_pitch];
+ std::array<float_type, m_pitch> z;
/* compute w and lamba */
for (std::size_t i = 0; i < iN; i++)
z[i] = Ainv(i, row); /* u is row'th column */
diff --git a/src/lib/netlist/solver/nld_ms_w.h b/src/lib/netlist/solver/nld_ms_w.h
index 3372b50c7c5..a01fc239938 100644
--- a/src/lib/netlist/solver/nld_ms_w.h
+++ b/src/lib/netlist/solver/nld_ms_w.h
@@ -77,7 +77,7 @@ protected:
void LE_invert();
template <typename T>
- void LE_compute_x(T * x);
+ void LE_compute_x(T & x);
template <typename T1, typename T2>
@@ -101,15 +101,15 @@ private:
float_ext_type m_A[storage_N][m_pitch];
float_ext_type m_Ainv[storage_N][m_pitch];
float_ext_type m_W[storage_N][m_pitch];
- float_ext_type m_RHS[storage_N]; // right hand side - contains currents
+ std::array<float_ext_type, storage_N> m_RHS; // right hand side - contains currents
float_ext_type m_lA[storage_N][m_pitch];
/* temporary */
float_type H[storage_N][m_pitch] ;
- unsigned rows[storage_N];
+ std::array<unsigned, storage_N> rows;
unsigned cols[storage_N][m_pitch];
- unsigned colcount[storage_N];
+ std::array<unsigned, storage_N> colcount;
unsigned m_cnt;
@@ -200,7 +200,7 @@ void matrix_solver_w_t<FT, SIZE>::LE_invert()
template <typename FT, int SIZE>
template <typename T>
void matrix_solver_w_t<FT, SIZE>::LE_compute_x(
- T * x)
+ T & x)
{
const std::size_t kN = size();
@@ -222,7 +222,7 @@ unsigned matrix_solver_w_t<FT, SIZE>::solve_non_dynamic(const bool newton_raphso
{
const auto iN = size();
- float_type new_V[storage_N]; // = { 0.0 };
+ std::array<float_type, storage_N> new_V; // = { 0.0 };
if ((m_cnt % 50) == 0)
{
@@ -260,7 +260,7 @@ unsigned matrix_solver_w_t<FT, SIZE>::solve_non_dynamic(const bool newton_raphso
/* construct w = transform(V) * y
* dim: rowcount x iN
* */
- float_type w[storage_N];
+ std::array<float_type, storage_N> w;
for (unsigned i = 0; i < rowcount; i++)
{
const unsigned r = rows[i];
@@ -310,7 +310,7 @@ unsigned matrix_solver_w_t<FT, SIZE>::solve_non_dynamic(const bool newton_raphso
}
/* Back substitution */
//inv(H) w = t w = H t
- float_type t[storage_N]; // FIXME: convert to member
+ std::array<float_type, storage_N> t; // FIXME: convert to member
for (unsigned j = rowcount; j-- > 0; )
{
float_type tmp = 0;
diff --git a/src/lib/netlist/tools/nl_convert.cpp b/src/lib/netlist/tools/nl_convert.cpp
index 16da51a4e01..1633497dd99 100644
--- a/src/lib/netlist/tools/nl_convert.cpp
+++ b/src/lib/netlist/tools/nl_convert.cpp
@@ -282,7 +282,7 @@ void nl_convert_spice_t::process_line(const pstring &line)
{
if (line != "")
{
- printf("// %s\n", line.c_str());
+ //printf("// %s\n", line.c_str());
std::vector<pstring> tt(plib::psplit(line, " ", true));
double val = 0.0;
switch (tt[0].at(0))