Commit b695601c authored by incardon's avatar incardon

Fixing coverty errors

parent fdbff4c0
......@@ -230,7 +230,7 @@ public:
* \tparam Graph Graph
* \tparam pos Array of properties
*/
template<int i, typename p, typename Graph, int ... pos>
template<unsigned int dim, int i, typename p, typename Graph, int ... pos>
struct fill_prop_by_type
{
......@@ -242,7 +242,7 @@ struct fill_prop_by_type
enum
{
value = ((sizeof...(pos) != 0) * (std::is_array<pos_prop_type>::value + 1))
value = ((sizeof...(pos) != 0 && dim <= 3) * (std::is_array<pos_prop_type>::value + 1))
};
};
......@@ -254,8 +254,8 @@ struct fill_prop_by_type
* \tparam Graph Graph
* \tparam pos Array of properties
*/
template<typename p, typename Graph, int ... pos>
struct fill_prop_by_type<0, p, Graph, pos...>
template<unsigned int dim, typename p, typename Graph, int ... pos>
struct fill_prop_by_type<dim, 0, p, Graph, pos...>
{
enum
{
......@@ -286,7 +286,7 @@ public:
* \return the constructed graph
*
*/
static Graph construct(const size_t (& sz)[dim], Box<dim,T> dom, const size_t(& bc)[dim])
static Graph construct(const size_t (& sz)[dim], Box<dim,T> & dom, const size_t(& bc)[dim])
{
// Calculate the size of the hyper-cubes on each dimension
T szd[dim];
......@@ -335,7 +335,7 @@ public:
// vertex spatial properties functor
fill_prop<dim, lin_id, T, decltype(gp.vertex(g.LinId(key))), typename to_boost_vmpl<pos...>::type, fill_prop_by_type<sizeof...(pos), p, Graph, pos...>::value> flp(obj, szd, key, g, dom);
fill_prop<dim, lin_id, T, decltype(gp.vertex(g.LinId(key))), typename to_boost_vmpl<pos...>::type, fill_prop_by_type<dim,sizeof...(pos), p, Graph, pos...>::value> flp(obj, szd, key, g, dom);
// fill properties
......@@ -407,7 +407,7 @@ public:
* \return the constructed graph
*
*/
static Graph construct(const size_t ( & sz)[dim], Box<dim,T> dom, const size_t(& bc)[dim])
static Graph construct(const size_t ( & sz)[dim], Box<dim,T> & dom, const size_t(& bc)[dim])
{
// Calculate the size of the hyper-cubes on each dimension
......@@ -456,7 +456,7 @@ public:
// vertex spatial properties functor
fill_prop<dim, lin_id, T, decltype(gp.vertex(g.LinId(key))), typename to_boost_vmpl<pos...>::type, fill_prop_by_type<sizeof...(pos), p, Graph, pos...>::value> flp(obj, szd, key, g, dom);
fill_prop<dim, lin_id, T, decltype(gp.vertex(g.LinId(key))), typename to_boost_vmpl<pos...>::type, fill_prop_by_type<dim,sizeof...(pos), p, Graph, pos...>::value> flp(obj, szd, key, g, dom);
// fill properties
......@@ -537,7 +537,7 @@ public:
*
*/
template<int se, int id_prp, typename T, unsigned int dim_c, int ... pos>
static Graph construct(const size_t (&sz)[dim], Box<dim, T> dom, const size_t (& bc)[dim])
static Graph construct(const size_t (&sz)[dim], Box<dim, T> & dom, const size_t (& bc)[dim])
{
return Graph_constructor_impl<dim, id_prp, Graph, se, T, dim_c, pos...>::construct(sz, dom, bc);
}
......
......@@ -463,7 +463,7 @@ public:
mem_id lid = gk.get(0);
for (mem_id i = 1 ; i < N ; i++)
{
/* coverity[dead_error_begin */
/* coverity[dead_error_line] */
lid += gk.get(i) * sz_s[i-1];
}
......
......@@ -1487,6 +1487,10 @@ public:
CellDecomposer_sm(const SpaceBox<dim,T> & box, const size_t (&div)[dim], Matrix<dim,T> & mat, const size_t pad)
:t(Matrix<dim,T>::identity(),box.getP1()),box(box),gr_cell()
{
// set div_wp to zero
for (size_t i = 0 ; i < dim ; i++)
{div_wp[i] = 0;}
Initialize(pad);
}
......
......@@ -426,7 +426,7 @@ public:
//! Type of internal memory structure
typedef Mem_type Mem_type_type;
typedef CellNNIteratorSym<dim,CellList<dim,T,Mem_type,transform,vector_pos_type>,RUNTIME,vector_pos_type,NO_CHECK> SymNNIterator;
typedef CellNNIteratorSym<dim,CellList<dim,T,Mem_type,transform,vector_pos_type>,vector_pos_type,RUNTIME,NO_CHECK> SymNNIterator;
//! Object type that the structure store
typedef typename Mem_type::local_index_type value_type;
......@@ -1004,7 +1004,7 @@ public:
*
*/
template<unsigned int impl>
inline CellNNIteratorSym<dim,CellList<dim,T,Mem_type,transform,vector_pos_type>,(unsigned int)SYM,vector_pos_type,impl>
inline CellNNIteratorSym<dim,CellList<dim,T,Mem_type,transform,vector_pos_type>,vector_pos_type,(unsigned int)SYM,impl>
getNNIteratorSym(size_t cell, size_t p, const vector_pos_type & v)
{
#ifdef SE_CLASS1
......@@ -1012,7 +1012,7 @@ public:
{std::cerr << __FILE__ << ":" << __LINE__ << " Warning when you try to get a symmetric neighborhood iterator, you must construct the Cell-list in a symmetric way" << std::endl;}
#endif
CellNNIteratorSym<dim,CellList<dim,T,Mem_type,transform,vector_pos_type>,SYM,vector_pos_type,impl> cln(cell,p,NNc_sym,*this,v);
CellNNIteratorSym<dim,CellList<dim,T,Mem_type,transform,vector_pos_type>,vector_pos_type,SYM,impl> cln(cell,p,NNc_sym,*this,v);
return cln;
}
......@@ -1039,15 +1039,15 @@ public:
*
*/
template<unsigned int impl>
inline CellNNIteratorSymMP<dim,CellList<dim,T,Mem_type,transform>,(unsigned int)SYM,impl>
getNNIteratorSymMP(size_t cell, size_t p, const openfpm::vector<Point<dim,T>> & v_p1, const openfpm::vector<Point<dim,T>> & v_p2)
inline CellNNIteratorSymMP<dim,CellList<dim,T,Mem_type,transform,vector_pos_type>,vector_pos_type,(unsigned int)SYM,impl>
getNNIteratorSymMP(size_t cell, size_t p, const vector_pos_type & v_p1, const vector_pos_type & v_p2)
{
#ifdef SE_CLASS1
if (from_cd == false)
std::cerr << __FILE__ << ":" << __LINE__ << " Warning when you try to get a symmetric neighborhood iterator, you must construct the Cell-list in a symmetric way" << std::endl;
#endif
CellNNIteratorSymMP<dim,CellList<dim,T,Mem_type,transform>,SYM,impl> cln(cell,p,NNc_sym,*this,v_p1,v_p2);
CellNNIteratorSymMP<dim,CellList<dim,T,Mem_type,transform,vector_pos_type>,vector_pos_type,SYM,impl> cln(cell,p,NNc_sym,*this,v_p1,v_p2);
return cln;
}
......
......@@ -163,7 +163,7 @@ public:
* \tparam impl implementation specific options NO_CHECK do not do check on access, SAFE do check on access
*
*/
template<unsigned int dim, typename Cell,int NNc_size, typename vector_pos_type, unsigned int impl>
template<unsigned int dim, typename Cell, typename vector_pos_type,int NNc_size, unsigned int impl>
class CellNNIteratorSym : public CellNNIterator<dim,Cell,NNc_size,impl>
{
//! index of the particle p
......@@ -226,7 +226,7 @@ public:
* \return itself
*
*/
inline CellNNIteratorSym<dim,Cell,NNc_size,vector_pos_type,impl> & operator++()
inline CellNNIteratorSym<dim,Cell,vector_pos_type,NNc_size,impl> & operator++()
{
this->start_id++;
......@@ -252,16 +252,17 @@ public:
* \tparam impl implementation specific options NO_CHECK do not do check on access, SAFE do check on access
*
*/
template<unsigned int dim, typename Cell,int NNc_size, unsigned int impl> class CellNNIteratorSymMP : public CellNNIterator<dim,Cell,NNc_size,impl>
template<unsigned int dim, typename Cell, typename vector_pos_type , int NNc_size, unsigned int impl>
class CellNNIteratorSymMP : public CellNNIterator<dim,Cell,NNc_size,impl>
{
//! index of the particle p
size_t p;
//! Phase vector for particle p
const openfpm::vector<Point<dim,typename Cell::stype>> & v_p1;
const vector_pos_type & v_p1;
//! Phase vector for particle q
const openfpm::vector<Point<dim,typename Cell::stype>> & v_p2;
const vector_pos_type & v_p2;
/*! Select the next valid element
*
......@@ -309,8 +310,8 @@ public:
size_t p,
const NNc_array<dim,NNc_size> &NNc,
Cell & cl,
const openfpm::vector<Point<dim,typename Cell::stype>> & v_p1,
const openfpm::vector<Point<dim,typename Cell::stype>> & v_p2)
const vector_pos_type & v_p1,
const vector_pos_type & v_p2)
:CellNNIterator<dim,Cell,NNc_size,impl>(cell,NNc,cl),p(p),v_p1(v_p1),v_p2(v_p2)
{
selectValid();
......@@ -322,7 +323,7 @@ public:
* \return itself
*
*/
inline CellNNIteratorSymMP<dim,Cell,NNc_size,impl> & operator++()
inline CellNNIteratorSymMP<dim,Cell,vector_pos_type,NNc_size,impl> & operator++()
{
this->start_id++;
......
......@@ -158,7 +158,7 @@ public:
*
*/
template<unsigned int dim, typename Cell,typename vector_pos_type, unsigned int impl>
class CellNNIteratorSym<dim,Cell,RUNTIME,vector_pos_type,impl> : public CellNNIterator<dim,Cell,RUNTIME,impl>
class CellNNIteratorSym<dim,Cell,vector_pos_type,RUNTIME,impl> : public CellNNIterator<dim,Cell,RUNTIME,impl>
{
//! index of the particle p
size_t p;
......@@ -228,7 +228,7 @@ public:
* \return itself
*
*/
inline CellNNIteratorSym<dim,Cell,RUNTIME,vector_pos_type,impl> & operator++()
inline CellNNIteratorSym<dim,Cell,vector_pos_type,RUNTIME,impl> & operator++()
{
this->start_id++;
......
......@@ -80,7 +80,7 @@ struct cid_<2,cnt_type,ids_type,transform>
return e[0] + div_c[0] * e[1];
}
static inline __device__ __host__ cnt_type get_cid(const openfpm::array<ids_type,2,cnt_type> & div_c, const grid_key_dx<2,cnt_type> & e)
static inline __device__ __host__ cnt_type get_cid(const openfpm::array<ids_type,2,cnt_type> & div_c, const grid_key_dx<2,ids_type> & e)
{
return e.get(0) + div_c[0] * e.get(1);
}
......
......@@ -345,7 +345,7 @@ private:
{
if (opt == VL_CRS_SYMMETRIC)
{
create_<CellNNIteratorSym<dim,CellListImpl,RUNTIME,vector_pos_type,NO_CHECK>,VL_CRS_SYMMETRIC>(pos,pos2,dom,anom,r_cut,g_m,cl,opt);
create_<CellNNIteratorSym<dim,CellListImpl,vector_pos_type,RUNTIME,NO_CHECK>,VL_CRS_SYMMETRIC>(pos,pos2,dom,anom,r_cut,g_m,cl,opt);
}
else if (opt == VL_SYMMETRIC)
{
......
......@@ -402,7 +402,10 @@ public:
val = pos_n_zero[i] - pos_n_zero[i+1] - 1;
}
else
{
/* coverty[uninit_use] */
val = pos_n_zero[i];
}
for (long int j = 0 ; j < (long int)val; j++)
{
......
......@@ -395,6 +395,7 @@ template<unsigned int dim ,typename T> class Point
for (size_t i = 0 ; i < dim - 1 ; i++)
{
/* coverty[dead_error_line] */
str += std::to_string(static_cast<double>(get(i))) + " ";
}
str += std::to_string(static_cast<double>(get(dim-1)));
......
......@@ -166,6 +166,7 @@ void calculate_optimal_device_grid(device_grid<dim> & dg,
{dg.grids.z *= z[jz];}
for (size_t k = 3 ; k < dim ; k++)
/* coverty[dead_error_line] */
{dg.grids.z *= sz[k];}
return;
......@@ -227,6 +228,7 @@ void calculate_optimal_device_grid(device_grid<dim> & dg,
dg.threads.y *= best_fact;
dg.grids.y /= best_fact;
}
/* coverty[dead_error_line] */
else if (k_best == 2)
{
dg.threads.z *= best_fact;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment