Skip to content

Commit

Permalink
Address codacy issues
Browse files Browse the repository at this point in the history
  • Loading branch information
gsjaardema committed Sep 18, 2023
1 parent e92cea4 commit 7b1dcc2
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 40 deletions.
5 changes: 3 additions & 2 deletions packages/seacas/applications/ejoin/EJ_mapping.C
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,9 @@ void build_reverse_node_map(Ioss::Region & /*global*/, RegionVector &part_mesh,
if (cur_pos == global_node_map.end() || *cur_pos != global_node) {
auto iter = std::lower_bound(global_node_map.begin(), global_node_map.end(), global_node);
if (iter == global_node_map.end()) {
fmt::print("{}\n", fmt::group_digits(global_node));
SMART_ASSERT(iter != global_node_map.end());
fmt::print(stderr, "ERROR: Could not find global node {} in global node map.\n",
fmt::group_digits(global_node));
exit(EXIT_FAILURE);
}
cur_pos = iter;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/seacas/applications/ejoin/EJoin.C
Original file line number Diff line number Diff line change
Expand Up @@ -501,8 +501,8 @@ double ejoin(SystemInterface &interFace, std::vector<Ioss::Region *> &part_mesh,
}
else {
if (global_times.size() != times.size()) {
fmt::print(stderr, "ERROR: Time step sizes must match.");
SMART_ASSERT(global_times.size() == times.size())(global_times.size())(times.size())(p);
fmt::print(stderr, "ERROR: Time step sizes must match. (Global = {}, Part {} = {}",
global_times.size(), p, times.size());
exit(EXIT_FAILURE);
}

Expand Down
1 change: 0 additions & 1 deletion packages/seacas/applications/exodiff/create_file.C
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,6 @@ namespace {
std::vector<char *> vars(names.size());
for (unsigned i = 0; i < names.size(); ++i) {
vars[i] = const_cast<char *>(names[i].c_str());
SMART_ASSERT(vars[i] != nullptr);
}
ex_put_variable_names(file_id, type, names.size(), vars.data());
}
Expand Down
3 changes: 0 additions & 3 deletions packages/seacas/applications/exodiff/exo_entity.C
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ bool Exo_Entity::is_valid_var(size_t var_index) const
SMART_ASSERT((int)var_index < numVars);
if (truth_ == nullptr) {
get_truth_table();
SMART_ASSERT(truth_ != nullptr);
}

return (truth_[var_index] != 0);
Expand Down Expand Up @@ -101,7 +100,6 @@ std::string Exo_Entity::Load_Results(int time_step, int var_index)

if (truth_ == nullptr) {
get_truth_table();
SMART_ASSERT(truth_ != nullptr);
}

if (truth_[var_index] != 0) {
Expand Down Expand Up @@ -158,7 +156,6 @@ std::string Exo_Entity::Load_Results(int t1, int t2, double proportion, int var_

if (truth_ == nullptr) {
get_truth_table();
SMART_ASSERT(truth_ != nullptr);
}

if (truth_[var_index] != 0) {
Expand Down
20 changes: 4 additions & 16 deletions packages/seacas/applications/nem_spread/ps_restart.C
Original file line number Diff line number Diff line change
Expand Up @@ -632,34 +632,22 @@ int NemSpread<T, INT>::read_vars(int exoid, int index, INT *eb_ids, INT *eb_cnts

if (Restart_Info.NVar_Elem > 0) {
fmt::print("Reading {} element variables...\n", Restart_Info.NVar_Elem);
if (read_elem_vars(exoid, index, eb_ids, eb_cnts, eb_map_ptr, eb_cnts_local) < 0) {
fmt::print(stderr, "{}: Error distributing elemental variables.\n", __func__);
return -1;
}
read_elem_vars(exoid, index, eb_ids, eb_cnts, eb_map_ptr, eb_cnts_local);
}

if (Restart_Info.NVar_Node > 0) {
fmt::print("Reading {} nodal variables...\n", Restart_Info.NVar_Node);
if (read_nodal_vars(exoid, index) < 0) {
fmt::print(stderr, "{}: Error distributing nodal variables.\n", __func__);
return -1;
}
read_nodal_vars(exoid, index);
}

if (Restart_Info.NVar_Sset > 0) {
fmt::print("Reading {} sideset variables...\n", Restart_Info.NVar_Sset);
if (read_sset_vars(exoid, index, ss_ids, ss_cnts) < 0) {
fmt::print(stderr, "{}: Error distributing sideset variables.\n", __func__);
return -1;
}
read_sset_vars(exoid, index, ss_ids, ss_cnts);
}

if (Restart_Info.NVar_Nset > 0) {
fmt::print("Reading {} nodeset variables...\n", Restart_Info.NVar_Nset);
if (read_nset_vars(exoid, index, ns_ids, ns_cnts) < 0) {
fmt::print(stderr, "{}: Error distributing nodeset variables.\n", __func__);
return -1;
}
read_nset_vars(exoid, index, ns_ids, ns_cnts);
}

return 0;
Expand Down
2 changes: 1 addition & 1 deletion packages/seacas/libraries/exodus/src/ex_put_num_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,14 @@ int ex_put_num_map(int exoid, ex_entity_type map_type, ex_entity_id map_id, cons
ex_err_fn(exoid, __func__, errmsg, status);
EX_FUNC_LEAVE(EX_FATAL);
}
int num_maps = num_entries;

/* Keep track of the total number of maps defined using a counter stored
in a linked list keyed by exoid.
NOTE: ex__get_file_item is used to find the number of maps
for a specific file and returns that value.
*/
int cur_num_maps = ex__get_file_item(exoid, ex__get_counter_list(map_type));
int num_maps = num_entries;
if (!overwrite_map) {
if (cur_num_maps >= num_maps) {
snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: exceeded number of %ss (%d) specified in file id %d",
Expand Down
10 changes: 3 additions & 7 deletions packages/seacas/libraries/ioss/src/Ioss_Compare.C
Original file line number Diff line number Diff line change
Expand Up @@ -1182,20 +1182,16 @@ namespace {
}

template <typename T>
bool compare_sets(const std::vector<T *> &in_sets_1, const std::vector<T *> &in_sets_const_2,
bool compare_sets(const std::vector<T *> &in_sets_1, const std::vector<T *> &in_sets_2,
const Ioss::MeshCopyOptions & /* options */, std::ostringstream & /* buf */)
{
bool overall_result = true;

if (in_sets_1.size() != in_sets_const_2.size()) {
fmt::print(Ioss::WarnOut(), COUNT_MISMATCH, "set", in_sets_1.size(), in_sets_const_2.size());
if (in_sets_1.size() != in_sets_2.size()) {
fmt::print(Ioss::WarnOut(), COUNT_MISMATCH, "set", in_sets_1.size(), in_sets_2.size());
return false;
}

// COPY the const input vector so that we remove elements as they're matched without
// affecting the original data structure.
std::vector<T *> in_sets_2 = in_sets_const_2;

if (!in_sets_1.empty()) {
for (const auto &in_set_1 : in_sets_1) {
const auto &name = in_set_1->name();
Expand Down
11 changes: 8 additions & 3 deletions packages/seacas/libraries/ioss/src/exodus/Ioex_Utils.C
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ namespace {
return len;
}

size_t match(const std::string &name1, const std::string &name2)
{
return match(name1.c_str(), name2.c_str());
}

template <typename INT>
void internal_write_coordinate_frames(int exoid, const Ioss::CoordinateFrameContainer &frames,
INT /*dummy*/)
Expand Down Expand Up @@ -237,7 +242,7 @@ namespace Ioex {
const char *s = substring;
const char *t = type.c_str();

SMART_ASSERT(s != nullptr && t != nullptr);
SMART_ASSERT(s != nullptr);
while (*s != '\0' && *t != '\0') {
if (*s++ != tolower(*t++)) {
return false;
Expand Down Expand Up @@ -409,14 +414,14 @@ namespace Ioex {
// VECTOR_3D). If found, it returns the name.
//

static char displace[] = "displacement";
static const std::string displace = "displacement";

size_t max_span = 0;
for (const auto &name : fields) {
std::string lc_name(name);

Ioss::Utils::fixup_name(lc_name);
size_t span = match(lc_name.c_str(), displace);
size_t span = match(lc_name, displace);
if (span > max_span) {
const Ioss::VariableType *var_type = block->get_field(name).transformed_storage();
int comp_count = var_type->component_count();
Expand Down
6 changes: 3 additions & 3 deletions packages/seacas/libraries/ioss/src/exonull/Ioexnl_Utils.C
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ namespace Ioexnl {
const char *s = substring;
const char *t = type.c_str();

SMART_ASSERT(s != nullptr && t != nullptr);
SMART_ASSERT(s != nullptr);
while (*s != '\0' && *t != '\0') {
if (*s++ != tolower(*t++)) {
return false;
Expand Down Expand Up @@ -384,14 +384,14 @@ namespace Ioexnl {
// VECTOR_3D). If found, it returns the name.
//

static char displace[] = "displacement";
static const std::string &displace = "displacement";

size_t max_span = 0;
for (const auto &name : fields) {
std::string lc_name(name);

Ioss::Utils::fixup_name(lc_name);
size_t span = match(lc_name.c_str(), displace);
size_t span = match(lc_name.c_str(), displace.c_str());
if (span > max_span) {
const Ioss::VariableType *var_type = block->get_field(name).transformed_storage();
int comp_count = var_type->component_count();
Expand Down
3 changes: 1 addition & 2 deletions packages/seacas/libraries/ioss/src/main/io_info.C
Original file line number Diff line number Diff line change
Expand Up @@ -583,8 +583,6 @@ namespace Ioss {

void io_info_set_db_properties(const Info::Interface &interFace, Ioss::DatabaseIO *dbi)
{
std::string inpfile = interFace.filename();

if (dbi == nullptr || !dbi->ok(true)) {
std::exit(EXIT_FAILURE);
}
Expand All @@ -605,6 +603,7 @@ namespace Ioss {
if (!interFace.groupname().empty()) {
bool success = dbi->open_group(interFace.groupname());
if (!success) {
std::string inpfile = interFace.filename();
fmt::print("ERROR: Unable to open group '{}' in file '{}'\n", interFace.groupname(),
inpfile);
return;
Expand Down

0 comments on commit 7b1dcc2

Please sign in to comment.