Commit 84b943c7 authored by Dan Wu's avatar Dan Wu
Browse files

Fixed some cppcheck warnings on redundant assignment (a variable is reassigned...

Fixed some cppcheck warnings on redundant assignment (a variable is reassigned a value before the old one has been used).
parent c85ed621
......@@ -336,9 +336,7 @@ bool smooth_test(const std::string &filename, FBiGeom_Instance geom) {
@li Load a mesh file
*/
bool tags_test(FBiGeom_Instance geom) {
bool success = true;
success = tag_info_test(geom);
bool success = tag_info_test(geom);
if (!success)
return success;
......
......@@ -366,9 +366,7 @@ bool smooth_test(const std::string &filename, FBiGeom_Instance geom) {
@li Load a mesh file
*/
bool tags_test(FBiGeom_Instance geom) {
bool success = true;
success = tag_info_test(geom);
bool success = tag_info_test(geom);
if (!success)
return success;
......
......@@ -310,9 +310,7 @@ bool gLoad_test(const std::string &filename, FBiGeom_Instance geom)
*/
bool tags_test(FBiGeom_Instance geom)
{
bool success = true;
success = tag_info_test(geom);
bool success = tag_info_test(geom);
if (!success) return success;
success = tag_get_set_test(geom);
......
......@@ -248,14 +248,13 @@ namespace moab {
ErrorCode AdaptiveKDTree::init()
{
std::vector<Tag> ctl;
ErrorCode rval = MB_SUCCESS;
#ifndef MB_AD_KD_TREE_USE_SINGLE_TAG
// create two tags, one for axis direction and one for axis coordinate
std::string n1(treeName), n2(treeName);
n1 += "_coord";
n2 += "_norm";
rval = make_tag(moab(), n1, MB_TAG_DENSE, MB_TYPE_DOUBLE, 1, 0, planeTag, ctl);
ErrorCode rval = make_tag(moab(), n1, MB_TAG_DENSE, MB_TYPE_DOUBLE, 1, 0, planeTag, ctl);
if (MB_SUCCESS != rval) return rval;
rval = make_tag(moab(), n2, MB_TAG_DENSE, MB_TYPE_INT, 1, 0, axisTag, ctl);
if (MB_SUCCESS != rval) return rval;
......@@ -263,11 +262,11 @@ namespace moab {
#elif defined(MB_AD_KD_TREE_USE_TWO_DOUBLE_TAG)
// create tag to hold two doubles, one for location and one for axis
std::string double_tag_name = std::string(treeName) + std::string("_coord_norm");
rval = make_tag(moab(), double_tag_name, MB_TAG_DENSE, MB_TYPE_DOUBLE, 2, 0, planeTag, ctl);
ErrorCode rval = make_tag(moab(), double_tag_name, MB_TAG_DENSE, MB_TYPE_DOUBLE, 2, 0, planeTag, ctl);
if (MB_SUCCESS != rval) return rval;
#else
// create opaque tag to hold struct Plane
rval = make_tag(moab(), tagname, MB_TAG_DENSE, MB_TYPE_OPAQUE, sizeof(Plane), 0, planeTag, ctl);
ErrorCode rval = make_tag(moab(), tagname, MB_TAG_DENSE, MB_TYPE_OPAQUE, sizeof(Plane), 0, planeTag, ctl);
if (MB_SUCCESS != rval) return rval;
#ifdef MOAB_HAVE_HDF5
......
......@@ -583,12 +583,10 @@ ErrorCode Core::serial_load_file( const char* file_name,
MB_SET_GLB_ERR(MB_FILE_DOES_NOT_EXIST, file_name << ": Cannot read directory/folder");
}
ErrorCode rval = MB_FAILURE;
const ReaderWriterSet* set = reader_writer_set();
Range initial_ents;
rval = get_entities_by_handle( 0, initial_ents );MB_CHK_ERR(rval);
ErrorCode rval = get_entities_by_handle( 0, initial_ents );MB_CHK_ERR(rval);
std::vector<Tag> initial_tags;
rval = tag_get_tags( initial_tags );MB_CHK_ERR(rval);
......@@ -3726,6 +3724,7 @@ ErrorCode Core::print_entity_tags(std::string indent_prefix, const EntityHandle
if (MB_SUCCESS != result || tp != this_type) continue;
DataType this_data_type;
result = this->tag_get_data_type(*vit, this_data_type);
if (MB_SUCCESS != result) continue;
int this_size;
result = this->tag_get_length(*vit, this_size);
if (MB_SUCCESS != result) continue;
......
......@@ -1109,7 +1109,7 @@ ErrorCode DualTool::construct_new_hyperplane(const int dim,
result = mbImpl->tag_set_data(globalId_tag(), &new_hyperplane, 1, &id); RR;
Tag hp_tag = (1 == dim ? dualCurve_tag() : dualSurface_tag());
result = mbImpl->tag_set_data(hp_tag, &new_hyperplane, 1, &new_hyperplane);
result = mbImpl->tag_set_data(hp_tag, &new_hyperplane, 1, &new_hyperplane); RR;
// assign a category name to these sets
static const char dual_category_names[2][CATEGORY_TAG_SIZE] =
......@@ -1694,9 +1694,11 @@ void DualTool::print_cell(EntityHandle cell)
assert(num_connect < 20);
result = mbImpl->tag_get_data(dualEntityTag, connect, num_connect, primals);
if (MB_SUCCESS != result) return;
ids.resize(num_connect);
result = mbImpl->tag_get_data(globalIdTag, primals,
num_connect, &ids[0]);
if (MB_SUCCESS != result) return;
for (int i = 0; i < num_connect; i++) {
if (!first) std::cout << "-";
EntityType this_type = mbImpl->type_from_handle(primals[i]);
......@@ -2570,8 +2572,11 @@ ErrorCode DualTool::list_entities(const Range &entities) const
EntityHandle chord = 0, sheet = 0;
int id;
result = mbImpl->tag_get_data(dualCurve_tag(), &(*iter), 1, &chord);
if (MB_SUCCESS != result) return result;
result = mbImpl->tag_get_data(dualSurface_tag(), &(*iter), 1, &sheet);
if (MB_SUCCESS != result) return result;
result = mbImpl->tag_get_data(globalId_tag(), &(*iter), 1, &id);
if (MB_SUCCESS != result) return result;
if (0 != chord)
std::cout << "(Dual chord " << id << ")" << std::endl;
......
......@@ -668,7 +668,7 @@ ErrorCode MeshTopoUtil::split_entities_manifold(EntityHandle *entities,
up_elem2 = tmp_elem;
}
tmp_result = mbImpl->remove_adjacencies(entities[i], &up_elem1, 1);
mbImpl->remove_adjacencies(entities[i], &up_elem1, 1);
// (ok if there's an error, that just means there wasn't an explicit adj)
tmp_result = mbImpl->add_adjacencies(new_entity, &up_elem1, 1, false); TC;
......
......@@ -419,14 +419,20 @@ void SmoothCurve::compute_tangents_for_each_edge()
// current edge will start after first one
currentEdge = entities[i];
rval = _mb->tag_get_data(tangentsTag, &currentEdge, 1, &TC[0]);//
if (rval != MB_SUCCESS)
return; // some error should be thrown
// now compute the new tangent at common vertex; reset tangents for previous edge and current edge
// a little bit of CPU and memory waste, but this is life
CartVect T = 0.5 * TC[0] + 0.5 * TP[1]; //
T.normalize();
TP[1] = T;
rval = _mb->tag_set_data(tangentsTag, &previousEdge, 1, &TP[0]);//
if (rval != MB_SUCCESS)
return; // some error should be thrown
TC[0] = T;
rval = _mb->tag_set_data(tangentsTag, &currentEdge, 1, &TC[0]);//
if (rval != MB_SUCCESS)
return; // some error should be thrown
// now set the next edge
previousEdge = currentEdge;
TP[0] = TC[0];
......
......@@ -213,6 +213,7 @@ int SmoothFace::init_gradient()
sprintf(name, "GRADIENT%lu", setId);// name should be something like GRADIENT29, where 29 is the set ID of the face
rval = _mb->tag_get_handle(name, 3, MB_TYPE_DOUBLE, _gradientTag,
MB_TAG_DENSE|MB_TAG_CREAT, &defNormal);
assert(rval == MB_SUCCESS);
double defPlane[4] = { 0., 0., 1., 0. };
// also define a plane tag ; this will be for each triangle
......@@ -220,6 +221,7 @@ int SmoothFace::init_gradient()
sprintf(namePlaneTag, "PLANE%lu", setId);
rval = _mb->tag_get_handle("PLANE", 4, MB_TYPE_DOUBLE, _planeTag,
MB_TAG_DENSE|MB_TAG_CREAT, &defPlane);
assert(rval == MB_SUCCESS);
// the fourth double is for weight, accumulated at each vertex so far
// maybe not needed in the end
for (Range::iterator it = _triangles.begin(); it != _triangles.end(); ++it)
......@@ -1115,6 +1117,7 @@ ErrorCode SmoothFace::project_to_facets_main(CartVect &this_point, bool trim,
// we will start with a list of facets anyway, the best among them wins
ErrorCode rval = _my_geomTopoTool->obb_tree()->closest_to_location(
(double*) &this_point, _obb_root, tolerance, facets_out);
if (MB_SUCCESS != rval) return rval;
int interpOrder = 4;
double compareTol = 1.e-5;
......@@ -1216,7 +1219,7 @@ ErrorCode SmoothFace::project_to_facets(std::vector<EntityHandle> & facet_list,
//Function Name: project_to_patch
//
//Member Type: PUBLIC
//Descriptoin: Project a point to a bezier patch. Pass in the areacoord
//Description: Project a point to a bezier patch. Pass in the areacoord
// of the point projected to the linear facet. Function
// assumes that the point is contained within the patch -
// if not, it will project to one of its edges.
......@@ -1574,8 +1577,6 @@ ErrorCode SmoothFace::project_to_facet(EntityHandle facet, CartVect &pt,
CartVect &areacoord, CartVect &close_point, bool &outside_facet,
double compare_tol)
{
ErrorCode stat = MB_SUCCESS;
const EntityHandle * conn3;
int nnodes;
_mb->get_connectivity(facet, conn3, nnodes);
......@@ -1586,7 +1587,7 @@ ErrorCode SmoothFace::project_to_facet(EntityHandle facet, CartVect &pt,
_mb->get_coords(conn3, 3, (double*) &p[0]);
int edge_id = -1;
stat = project_to_patch(facet, areacoord, pt, close_point, NULL,
ErrorCode stat = project_to_patch(facet, areacoord, pt, close_point, NULL,
outside_facet, compare_tol, edge_id);
/* }
break;
......
......@@ -976,13 +976,11 @@ ErrorCode ScdNCHelper::read_scd_variables_to_nonset_allocate(std::vector<ReadNC:
std::vector<int>& dimLens = _readNC->dimLens;
DebugOutput& dbgOut = _readNC->dbgOut;
ErrorCode rval = MB_SUCCESS;
Range* range = NULL;
// Get vertices
Range verts;
rval = mbImpl->get_entities_by_dimension(_fileSet, 0, verts);MB_CHK_SET_ERR(rval, "Trouble getting vertices in current file set");
ErrorCode rval = mbImpl->get_entities_by_dimension(_fileSet, 0, verts);MB_CHK_SET_ERR(rval, "Trouble getting vertices in current file set");
assert("Should only have a single vertex subrange, since they were read in one shot" &&
verts.psize() == 1);
......
......@@ -384,13 +384,11 @@ ErrorCode NCHelperGCRM::read_ucd_variables_to_nonset_allocate(std::vector<ReadNC
bool& noEdges = _readNC->noEdges;
DebugOutput& dbgOut = _readNC->dbgOut;
ErrorCode rval = MB_SUCCESS;
Range* range = NULL;
// Get vertices
Range verts;
rval = mbImpl->get_entities_by_dimension(_fileSet, 0, verts);MB_CHK_SET_ERR(rval, "Trouble getting vertices in current file set");
ErrorCode rval = mbImpl->get_entities_by_dimension(_fileSet, 0, verts);MB_CHK_SET_ERR(rval, "Trouble getting vertices in current file set");
assert("Should only have a single vertex subrange, since they were read in one shot" && verts.psize() == 1);
// Get edges
......
......@@ -549,13 +549,11 @@ ErrorCode NCHelperHOMME::read_ucd_variables_to_nonset_allocate(std::vector<ReadN
std::vector<int>& dimLens = _readNC->dimLens;
DebugOutput& dbgOut = _readNC->dbgOut;
ErrorCode rval = MB_SUCCESS;
Range* range = NULL;
// Get vertices
Range verts;
rval = mbImpl->get_entities_by_dimension(_fileSet, 0, verts);MB_CHK_SET_ERR(rval, "Trouble getting vertices in current file set");
ErrorCode rval = mbImpl->get_entities_by_dimension(_fileSet, 0, verts);MB_CHK_SET_ERR(rval, "Trouble getting vertices in current file set");
assert("Should only have a single vertex subrange, since they were read in one shot" && verts.psize() == 1);
for (unsigned int i = 0; i < vdatas.size(); i++) {
......
......@@ -497,13 +497,11 @@ ErrorCode NCHelperMPAS::read_ucd_variables_to_nonset_allocate(std::vector<ReadNC
bool& noEdges = _readNC->noEdges;
DebugOutput& dbgOut = _readNC->dbgOut;
ErrorCode rval = MB_SUCCESS;
Range* range = NULL;
// Get vertices
Range verts;
rval = mbImpl->get_entities_by_dimension(_fileSet, 0, verts);MB_CHK_SET_ERR(rval, "Trouble getting vertices in current file set");
ErrorCode rval = mbImpl->get_entities_by_dimension(_fileSet, 0, verts);MB_CHK_SET_ERR(rval, "Trouble getting vertices in current file set");
assert("Should only have a single vertex subrange, since they were read in one shot" && verts.psize() == 1);
// Get edges
......
......@@ -703,6 +703,7 @@ ErrorCode ReadABAQUS::read_solid_section(EntityHandle parent_set)
EntityHandle set_handle;
status = get_set_by_name(parent_set, ABQ_ELEMENT_SET, elset_name, set_handle);
MB_RETURN_IF_FAIL;
status = mdbImpl->tag_set_data(mMatNameTag, &set_handle, 1, mat_name.c_str());
MB_RETURN_IF_FAIL;
......@@ -1557,6 +1558,7 @@ ErrorCode ReadABAQUS::create_instance_of_part(const EntityHandle file_set,
instance_id = ++num_assembly_instances[assembly_set];
status = mdbImpl->tag_set_data(mInstanceGIDTag, &instance_set, 1, &instance_id);
MB_RETURN_IF_FAIL;
// Create maps to cross-reference the part and instance versions of each entity
std::map<EntityHandle, EntityHandle> p2i_nodes, p2i_elements;
......
......@@ -746,8 +746,8 @@ ErrorCode ReadCCMIO::create_cell_from_faces(std::vector<EntityHandle> &facehs,
// Get verts in q1 opposite from v[1] and v[0] in q0
EntityHandle v0 = 0, v1 = 0;
rval = mtu.opposite_entity(q1, verts[1], v0);
rval = mtu.opposite_entity(q1, verts[0], v1);
rval = mtu.opposite_entity(q1, verts[1], v0);MB_CHK_SET_ERR(rval, "Couldn't get the opposite side entity");
rval = mtu.opposite_entity(q1, verts[0], v1);MB_CHK_SET_ERR(rval, "Couldn't get the opposite side entity");
if (v0 && v1) {
// Offset of v0 in q2, then rotate and flip
unsigned int ioff = std::find(storage.begin(), storage.end(), v0) - storage.begin();
......@@ -801,8 +801,8 @@ ErrorCode ReadCCMIO::create_cell_from_faces(std::vector<EntityHandle> &facehs,
// Get verts in q1 opposite from v[1] and v[0] in q0
EntityHandle v0 = 0, v1 = 0;
rval = mtu.opposite_entity(q1, verts[1], v0);
rval = mtu.opposite_entity(q1, verts[0], v1);
rval = mtu.opposite_entity(q1, verts[1], v0);MB_CHK_SET_ERR(rval, "Couldn't get the opposite side entity");
rval = mtu.opposite_entity(q1, verts[0], v1);MB_CHK_SET_ERR(rval, "Couldn't get the opposite side entity");
if (v0 && v1) {
// Offset of v0 in t2, then rotate and flip
storage.clear();
......
......@@ -80,7 +80,7 @@ ErrorCode ReadCGNS::load_file(const char* filename,
if (MB_SUCCESS != result)
return result;
// Create set for more convienient check for material set ids
// Create set for more convenient check for material set ids
std::set<int> blocks;
for (const int* mat_set_end = material_set_list + num_material_sets;
material_set_list != mat_set_end; ++material_set_list)
......@@ -518,7 +518,6 @@ ErrorCode ReadCGNS::create_sets(char *sectionName,
return result;
}
result = MB_SUCCESS;
EntityHandle set_handle;
Tag tag_handle;
......
......@@ -3135,6 +3135,8 @@ ErrorCode ReadHDF5::read_sparse_tag(Tag tag_handle,
id_table, base_offset,
offset_range, handle_range,
handle_vect);
if (MB_SUCCESS != rval)
return error(rval);
DataType mbtype;
rval = iFace->tag_get_data_type(tag_handle, mbtype);
......
......@@ -35,8 +35,6 @@ ReadNC::~ReadNC()
ErrorCode ReadNC::load_file(const char* file_name, const EntityHandle* file_set, const FileOptions& opts,
const ReaderIface::SubsetList* /*subset_list*/, const Tag* file_id_tag)
{
ErrorCode rval = MB_SUCCESS;
// See if opts has variable(s) specified
std::vector<std::string> var_names;
std::vector<int> tstep_nums;
......@@ -44,7 +42,7 @@ ErrorCode ReadNC::load_file(const char* file_name, const EntityHandle* file_set,
// Get and cache predefined tag handles
int dum_val = 0;
rval = mbImpl->tag_get_handle(GLOBAL_ID_TAG_NAME, 1, MB_TYPE_INTEGER, mGlobalIdTag, MB_TAG_DENSE | MB_TAG_CREAT,
ErrorCode rval = mbImpl->tag_get_handle(GLOBAL_ID_TAG_NAME, 1, MB_TYPE_INTEGER, mGlobalIdTag, MB_TAG_DENSE | MB_TAG_CREAT,
&dum_val);MB_CHK_SET_ERR(rval, "Trouble getting global ID tag");
// Store the pointer to the tag; if not null, set when global id tag
......
......@@ -54,7 +54,7 @@ namespace moab {
size_t tmp_val; \
gdfail = nc_inq_dimlen(ncFile, ncdim, &tmp_val); \
if (NC_NOERR != gdfail) { \
MB_SET_ERR(MB_FAILURE, "ReadNCDF:: couldn't get dimension length"); \
MB_SET_ERR(MB_FAILURE, "ReadNCDF:: Couldn't get dimension length"); \
} \
else \
val = tmp_val; \
......@@ -87,6 +87,9 @@ namespace moab {
if (-1 != id) { \
size_t ntmp; \
int ivfail = nc_inq_dimlen(ncFile, vals[0], &ntmp); \
if (NC_NOERR != ivfail) { \
MB_SET_ERR(MB_FAILURE, "ReadNCDF:: Couldn't get dimension length"); \
} \
vals.resize(ntmp); \
size_t ntmp1 = 0; \
ivfail = nc_get_vara_int(ncFile, id, &ntmp1, &ntmp, &vals[0]); \
......@@ -104,6 +107,9 @@ namespace moab {
if (-1 != id) { \
size_t ntmp; \
int dvfail = nc_inq_dimlen(ncFile, dum_dims[0], &ntmp); \
if (NC_NOERR != dvfail) { \
MB_SET_ERR(MB_FAILURE, "ReadNCDF:: Couldn't get dimension length"); \
} \
vals.resize(ntmp); \
size_t ntmp1 = 0; \
dvfail = nc_get_vara_double(ncFile, id, &ntmp1, &ntmp, &vals[0]); \
......@@ -156,6 +162,7 @@ ReadNCDF::ReadNCDF(Interface* impl)
assert(MB_SUCCESS == result);
result = impl->tag_get_handle("qaRecord", 0, MB_TYPE_OPAQUE, mQaRecordTag,
MB_TAG_SPARSE | MB_TAG_VARLEN | MB_TAG_CREAT);
assert(MB_SUCCESS == result);
result = impl->tag_get_handle(GLOBAL_ID_TAG_NAME, 1, MB_TYPE_INTEGER,
mGlobalIdTag, MB_TAG_SPARSE | MB_TAG_CREAT, &zero);
assert(MB_SUCCESS == result);
......
......@@ -472,6 +472,8 @@ ErrorCode Tqdcfr::load_file(const char *file_name,
// Convert blocks to nodesets/sidesets if tag is set
result = convert_nodesets_sidesets();
if (MB_SUCCESS != result)
return result;
Range after_ents;
result = mdbImpl->get_entities_by_handle(0, after_ents);
......@@ -1168,6 +1170,8 @@ ErrorCode Tqdcfr::read_group(const unsigned int group_index,
strncpy(name_tag_data, md_entry->mdStringValue.c_str(), NAME_TAG_SIZE);
result = mdbImpl->tag_set_data(entityNameTag, &grouph->setHandle, 1,
name_tag_data);
if (MB_SUCCESS != result)
return result;
// Look for extra names
md_index = model->groupMD.get_md_entry(group_index, "NumExtraNames");
......@@ -1187,6 +1191,8 @@ ErrorCode Tqdcfr::read_group(const unsigned int group_index,
NAME_TAG_SIZE, MB_TYPE_OPAQUE,
extra_name_tag, MB_TAG_SPARSE | MB_TAG_CREAT,
name_tag_data);
if (MB_SUCCESS != result)
return result;
//assert(md_entry->mdStringValue.length() + 1 <= NAME_TAG_SIZE);
memset(name_tag_data, 0, NAME_TAG_SIZE); // Make sure any extra bytes zeroed
strncpy(name_tag_data, md_entry->mdStringValue.c_str(), NAME_TAG_SIZE);
......
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