Skip to content

Commit d6ce32f

Browse files
committed
Address use of c-style casts warnings
1 parent d6a2d7a commit d6ce32f

File tree

22 files changed

+149
-146
lines changed

22 files changed

+149
-146
lines changed

packages/seacas/applications/conjoin/CJ_Internals.C

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright(C) 1999-, 20242024, , National Technology & Engineering Solutions
2+
* Copyright(C) 1999-, 20242024, , , National Technology & Engineering Solutions
33
* of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
44
* NTESS, the U.S. Government retains certain rights in this software.
55
*
@@ -311,7 +311,7 @@ int Excn::Internals::put_metadata(const Mesh<INT> &mesh, const CommunicationMeta
311311
int varid = 0;
312312
{
313313
std::array dim{timedim};
314-
if ((status = nc_def_var(exodusFilePtr, VAR_WHOLE_TIME, nc_flt_code(exodusFilePtr), 1,
314+
if ((status = nc_def_var(exodusFilePtr, VAR_WHOLE_TIME, static_cast<nc_flt_code>(exodusFilePtr), 1,
315315
Data(dim), &varid)) != NC_NOERR) {
316316
std::string errmsg = fmt::format(
317317
"Error: failed to define whole time step variable in file id {}", exodusFilePtr);

packages/seacas/applications/conjoin/Conjoin.C

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ namespace {
6868
static const T tolerance = 100.0 * std::numeric_limits<T>::epsilon();
6969
return std::fabs(v1 - v2) <= std::fabs(v1+v2)*tolerance;
7070
#else
71-
return (float)v1 == (float)v2;
71+
return static_cast<float>(v1) == static_cast<float>(v2);
7272
#endif
7373
}
7474
} // namespace
@@ -651,7 +651,7 @@ int conjoin(Excn::SystemInterface &interFace, T /* dummy */, INT /* dummy int */
651651
fmt::print("{}", time_stamp(tsFormat));
652652
}
653653

654-
error += get_put_coordinates(global, part_count, local_mesh, (T)0);
654+
error += get_put_coordinates(global, part_count, local_mesh, static_cast<T>(0));
655655

656656
if (debug_level & 1) {
657657
fmt::print("{}", time_stamp(tsFormat));
@@ -819,11 +819,11 @@ int conjoin(Excn::SystemInterface &interFace, T /* dummy */, INT /* dummy int */
819819
fmt::print("{}Global Variables...\n", time_stamp(tsFormat));
820820
}
821821
error += ex_get_var(id, global_times[time_step].localStepNumber + 1, EX_GLOBAL, 0, 0,
822-
global_vars.count(), (void *)Data(global_values));
822+
global_vars.count(), static_cast<void *>(Data(global_values)));
823823
// Map ...
824824
for (int ig = 0; ig < global_vars.count(Excn::InOut::IN_); ig++) {
825825
if (global_vars.index_[ig] > 0) {
826-
SMART_ASSERT(ig < (int)global_values.size());
826+
SMART_ASSERT(ig < static_cast<int>(global_values.size()));
827827
output_global_values[global_vars.index_[ig] - 1] = global_values[ig];
828828
}
829829
}
@@ -1350,7 +1350,7 @@ namespace {
13501350
for (size_t n = 0; n < npe; n++) {
13511351
size_t node = part_loc_node_to_global[local_linkage[pos++] - 1];
13521352
if (debug_level & 4) {
1353-
SMART_ASSERT(block_linkage[global_pos] == (int)node + 1 ||
1353+
SMART_ASSERT(block_linkage[global_pos] == static_cast<int>(node) + 1 ||
13541354
block_linkage[global_pos] == 0);
13551355
}
13561356
block_linkage[global_pos++] = node + 1;
@@ -1667,7 +1667,7 @@ namespace {
16671667
// sorted and there are no duplicates, we just need to see if the id
16681668
// at global_node_map.size() == global_node_map.size();
16691669
INT max_id = global_node_map[global->nodeCount - 1].id;
1670-
bool is_contiguous = (int64_t)max_id == static_cast<int64_t>(global_node_map.size());
1670+
bool is_contiguous = static_cast<int64_t>(max_id) == static_cast<int64_t>(global_node_map.size());
16711671
fmt::print("Node map {} contiguous.\n", (is_contiguous ? "is" : "is not"));
16721672

16731673
// Create the map that maps from a local part node to the
@@ -1774,7 +1774,7 @@ namespace {
17741774
// sorted and there are no duplicates, we just need to see if the id
17751775
// at global_node_map.size() == global_node_map.size();
17761776
INT max_id = global_node_map[global->nodeCount - 1];
1777-
bool is_contiguous = (int64_t)max_id == static_cast<int64_t>(global_node_map.size());
1777+
bool is_contiguous = static_cast<int64_t>(max_id) == static_cast<int64_t>(global_node_map.size());
17781778
fmt::print("Node map {} contiguous.\n", (is_contiguous ? "is" : "is not"));
17791779

17801780
// Create the map that maps from a local part node to the
@@ -2048,7 +2048,7 @@ namespace {
20482048
int num_vars;
20492049
auto id = Excn::ExodusFile(p);
20502050
ex_get_variable_param(id, vars.type(), &num_vars);
2051-
if ((size_t)num_vars != vars.index_.size() - extra) {
2051+
if (static_cast<size_t>(num_vars) != vars.index_.size() - extra) {
20522052
fmt::print("ERROR: Part mesh {} has a different number of {} variables ({}) than the root "
20532053
"part mesh ({}) which is not allowed.\n",
20542054
p, vars.label(), num_vars, vars.index_.size() - extra);
@@ -2207,7 +2207,7 @@ namespace {
22072207
for (size_t ns = 0; ns < set_ids.size(); ns++) {
22082208

22092209
std::vector<INT> glob_ns_nodes(total_node_count + 1);
2210-
std::fill(glob_ns_nodes.begin(), glob_ns_nodes.end(), (INT)0);
2210+
std::fill(glob_ns_nodes.begin(), glob_ns_nodes.end(), static_cast<INT>(0));
22112211

22122212
size_t lns = glob_sets[ns].position_;
22132213
for (size_t p = 0; p < part_count; p++) {
@@ -2444,7 +2444,7 @@ namespace {
24442444
size_t global_elem =
24452445
local_mesh[p].localElementToGlobal[sets[p][lss].elems[i] - 1] + 1;
24462446
elem_side[offset + i] =
2447-
std::make_pair((INT)global_elem, (INT)sets[p][lss].sides[i]);
2447+
std::make_pair(static_cast<INT>(global_elem), static_cast<INT>(sets[p][lss].sides[i]));
24482448
}
24492449
offset += sets[p][lss].sideCount;
24502450
break;
@@ -2480,7 +2480,7 @@ namespace {
24802480
size_t global_elem =
24812481
local_mesh[p].localElementToGlobal[sets[p][lss].elems[i] - 1] + 1;
24822482
std::pair<INT, INT> es =
2483-
std::make_pair((INT)global_elem, (INT)sets[p][lss].sides[i]);
2483+
std::make_pair(static_cast<INT>(global_elem), static_cast<INT>(sets[p][lss].sides[i]));
24842484

24852485
auto iter = std::lower_bound(elem_side.begin(), elem_side.end(), es);
24862486
size_t pos = iter - elem_side.begin();
@@ -3001,7 +3001,7 @@ namespace {
30013001
{
30023002
size_t max_ent = local_mesh[0].count(Excn::ObjectType::NODE);
30033003
for (size_t p = 1; p < part_count; p++) {
3004-
if ((size_t)local_mesh[p].count(Excn::ObjectType::NODE) > max_ent) {
3004+
if (static_cast<size_t>(local_mesh[p].count(Excn::ObjectType::NODE)) > max_ent) {
30053005
max_ent = local_mesh[p].count(Excn::ObjectType::NODE);
30063006
}
30073007
}

packages/seacas/applications/epu/EP_ExodusFile.C

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ namespace {
8383
Excn::ExodusFile::ExodusFile(int processor) : myProcessor_(processor)
8484
{
8585
SMART_ASSERT(processor < processorCount_)(processor)(processorCount_);
86-
SMART_ASSERT(fileids_.size() == (size_t)processorCount_);
86+
SMART_ASSERT(fileids_.size() == static_cast<size_t>(processorCount_));
8787
if (!keepOpen_ && processor != 0) {
8888
float version = 0.0;
8989
int cpu_word_size = cpuWordSize_;

packages/seacas/applications/epu/EP_Internals.C

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright(C) 1999-2024, National Technology & Engineering Solutions
2+
* Copyright(C) 1999-2025, National Technology & Engineering Solutions
33
* of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
44
* NTESS, the U.S. Government retains certain rights in this software.
55
*
@@ -132,11 +132,11 @@ int Excn::Internals<INT>::write_meta_data(const Mesh &mesh, const std::vector<Bl
132132
const std::vector<FaceBlock<INT>> &faceblocks,
133133
const CommunicationMetaData &comm)
134134
{
135-
SMART_ASSERT((int)blocks.size() == mesh.blockCount);
136-
SMART_ASSERT((int)nodesets.size() == mesh.nodesetCount);
137-
SMART_ASSERT((int)sidesets.size() == mesh.sidesetCount);
138-
SMART_ASSERT((int)edgeblocks.size() == mesh.edgeBlockCount);
139-
SMART_ASSERT((int)faceblocks.size() == mesh.faceBlockCount);
135+
SMART_ASSERT(static_cast<int>(blocks.size()) == mesh.blockCount);
136+
SMART_ASSERT(static_cast<int>(nodesets.size()) == mesh.nodesetCount);
137+
SMART_ASSERT(static_cast<int>(sidesets.size()) == mesh.sidesetCount);
138+
SMART_ASSERT(static_cast<int>(edgeblocks.size()) == mesh.edgeBlockCount);
139+
SMART_ASSERT(static_cast<int>(faceblocks.size()) == mesh.faceBlockCount);
140140

141141
// May need to reorder the element blocks based on the 'offset_'
142142
// member. An element block contains the elements from 'offset_+1'
@@ -281,7 +281,7 @@ int Excn::Internals<INT>::write_meta_data(const Mesh &mesh, const std::vector<Bl
281281

282282
for (int i = 0; i < mesh.blockCount; i++) {
283283
if (blocks[i].attributeCount > 0) {
284-
SMART_ASSERT((size_t)blocks[i].attributeCount == blocks[i].attributeNames.size());
284+
SMART_ASSERT(static_cast<size_t>(blocks[i].attributeCount) == blocks[i].attributeNames.size());
285285
for (int j = 0; j < blocks[i].attributeCount; j++) {
286286
std::memset(names[j], '\0', name_size + 1);
287287
if (!blocks[i].attributeNames[j].empty()) {
@@ -852,7 +852,7 @@ int Excn::Internals<INT>::put_metadata(const std::vector<NodeSet<INT>> &nodesets
852852
// NOTE: exi_inc_file_item is used to find the number of node sets
853853
// for a specific file and returns that value incremented.
854854
int cur_num_node_sets =
855-
(int)exi_inc_file_item(exodusFilePtr, exi_get_counter_list(EX_NODE_SET));
855+
static_cast<int>(exi_inc_file_item(exodusFilePtr, exi_get_counter_list(EX_NODE_SET)));
856856

857857
if (nodesets[i].nodeCount == 0) {
858858
continue;
@@ -1003,7 +1003,7 @@ int Excn::Internals<INT>::put_metadata(const std::vector<SideSet<INT>> &sidesets
10031003
// NOTE: exi_inc_file_item is used to find the number of side sets
10041004
// for a specific file and returns that value incremented.
10051005
int cur_num_side_sets =
1006-
(int)exi_inc_file_item(exodusFilePtr, exi_get_counter_list(EX_SIDE_SET));
1006+
static_cast<int>(exi_inc_file_item(exodusFilePtr, exi_get_counter_list(EX_SIDE_SET)));
10071007

10081008
if (sidesets[i].sideCount == 0) {
10091009
continue;
@@ -1118,7 +1118,7 @@ int Excn::Internals<INT>::put_non_define_data(const std::vector<SideSet<INT>> &s
11181118
}
11191119

11201120
// Output sideset ids...
1121-
int num_sidesets = (int)sidesets.size();
1121+
int num_sidesets = static_cast<int>(sidesets.size());
11221122
std::vector<ex_entity_id> sideset_id(num_sidesets);
11231123
for (int i = 0; i < num_sidesets; i++) {
11241124
sideset_id[i] = sidesets[i].id;
@@ -1180,7 +1180,7 @@ int Excn::Internals<INT>::put_metadata(const std::vector<EdgeBlock<INT>> &edgebl
11801180
// NOTE: exi_inc_file_item is used to find the number of edge blocks
11811181
// for a specific file and returns that value incremented.
11821182
int cur_num_edge_blocks =
1183-
(int)exi_inc_file_item(exodusFilePtr, exi_get_counter_list(EX_EDGE_BLOCK));
1183+
static_cast<int>(exi_inc_file_item(exodusFilePtr, exi_get_counter_list(EX_EDGE_BLOCK)));
11841184

11851185
if (edgeblocks[i].edgeCount == 0) {
11861186
continue;
@@ -1255,7 +1255,7 @@ int Excn::Internals<INT>::put_non_define_data(const std::vector<EdgeBlock<INT>>
12551255
}
12561256

12571257
// Output edgeblock ids...
1258-
int num_edgeblocks = (int)edgeblocks.size();
1258+
int num_edgeblocks = static_cast<int>(edgeblocks.size());
12591259
std::vector<ex_entity_id> edgeblock_id(num_edgeblocks);
12601260
for (int i = 0; i < num_edgeblocks; i++) {
12611261
edgeblock_id[i] = edgeblocks[i].id;
@@ -1317,7 +1317,7 @@ int Excn::Internals<INT>::put_metadata(const std::vector<FaceBlock<INT>> &facebl
13171317
// NOTE: exi_inc_file_item is used to find the number of face blocks
13181318
// for a specific file and returns that value incremented.
13191319
int cur_num_face_blocks =
1320-
(int)exi_inc_file_item(exodusFilePtr, exi_get_counter_list(EX_FACE_BLOCK));
1320+
static_cast<int>(exi_inc_file_item(exodusFilePtr, exi_get_counter_list(EX_FACE_BLOCK)));
13211321

13221322
if (faceblocks[i].faceCount == 0) {
13231323
continue;
@@ -1393,7 +1393,7 @@ int Excn::Internals<INT>::put_non_define_data(const std::vector<FaceBlock<INT>>
13931393
}
13941394

13951395
// Output faceblock ids...
1396-
int num_faceblocks = (int)faceblocks.size();
1396+
int num_faceblocks = static_cast<int>(faceblocks.size());
13971397
std::vector<ex_entity_id> faceblock_id(num_faceblocks);
13981398
for (int i = 0; i < num_faceblocks; i++) {
13991399
faceblock_id[i] = faceblocks[i].id;
@@ -1433,7 +1433,7 @@ namespace {
14331433
}
14341434

14351435
if (sizeof(INT) == sizeof(int64_t)) {
1436-
status = nc_put_var_longlong(exoid, var_id, (long long int *)Data(array));
1436+
status = nc_put_var_longlong(exoid, var_id, (long long int*)Data(array));
14371437
}
14381438
else {
14391439
status = nc_put_var_int(exoid, var_id, Data(array));

packages/seacas/applications/epu/epu.C

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ namespace {
208208
template <typename INT> bool is_sequential(std::vector<INT> &map)
209209
{
210210
for (size_t i = 0; i < map.size(); i++) {
211-
if (map[i] != (INT)i + 1) {
211+
if (map[i] != static_cast<INT>(i) + 1) {
212212
return false;
213213
}
214214
}
@@ -536,9 +536,9 @@ int main(int argc, char *argv[])
536536
// if that value > max_open_file, then use square root.
537537
// if that is still too large, just do no subcycles... and implement
538538
// a recursive subcycling capability at some point...
539-
int sub_cycle_count = (int)(std::pow(processor_count, 1.0 / 3) + 0.9);
539+
int sub_cycle_count = static_cast<int>((std::pow(processor_count, 1.0 / 3) + 0.9));
540540
if (((processor_count + sub_cycle_count - 1) / sub_cycle_count) > max_open_file) {
541-
sub_cycle_count = (int)std::sqrt(processor_count);
541+
sub_cycle_count = static_cast<int>(std::sqrt(processor_count));
542542
}
543543

544544
if (((processor_count + sub_cycle_count - 1) / sub_cycle_count) < max_open_file) {
@@ -1429,7 +1429,7 @@ int epu(SystemInterface &interFace, int start_part, int part_count, int cycle)
14291429
// Map ...
14301430
for (int ig = 0; ig < global_vars.count(InOut::IN); ig++) {
14311431
if (global_vars.index_[ig] > 0) {
1432-
SMART_ASSERT(ig < (int)global_values.size());
1432+
SMART_ASSERT(ig < static_cast<int>(global_values.size()));
14331433
output_global_values[global_vars.index_[ig] - 1] = global_values[ig];
14341434
}
14351435
}
@@ -1927,7 +1927,7 @@ namespace {
19271927
}
19281928

19291929
std::array<INT, 1> ids{1};
1930-
std::array<INT, 1> cnts{(INT)gnodes.size()};
1930+
std::array<INT, 1> cnts{static_cast<INT>(gnodes.size())};
19311931
error = ex_put_cmap_params(ExodusFile::output(), Data(ids), Data(cnts), nullptr, nullptr,
19321932
output_processor);
19331933
if (error < 0) {
@@ -2124,7 +2124,7 @@ namespace {
21242124
glob_blocks[b].elementCount += temp_block.num_entry;
21252125
glob_blocks[b].nodesPerElement = temp_block.num_nodes_per_entry;
21262126
glob_blocks[b].attributeCount = temp_block.num_attribute;
2127-
glob_blocks[b].position_ = (int)b;
2127+
glob_blocks[b].position_ = static_cast<int>(b);
21282128
copy_string(glob_blocks[b].elType, temp_block.topology);
21292129
}
21302130

@@ -2444,7 +2444,7 @@ namespace {
24442444
// sorted and there are no duplicates, we just need to see if the id
24452445
// at global_element_map.size() == global_element_map.size();
24462446
bool is_contiguous = global_element_map.empty() ||
2447-
((size_t)global_element_map.back() == global_element_map.size());
2447+
(static_cast<size_t>(global_element_map.back()) == global_element_map.size());
24482448
if (rank == 0) {
24492449
fmt::print("Element id map {} contiguous.\n", (is_contiguous ? "is" : "is not"));
24502450
}
@@ -2621,7 +2621,7 @@ namespace {
26212621
// sorted and there are no duplicates, we just need to see if the id
26222622
// at global_edge_map.size() == global_edge_map.size();
26232623
bool is_contiguous =
2624-
global_edge_map.empty() || ((size_t)global_edge_map.back() == global_edge_map.size());
2624+
global_edge_map.empty() || (static_cast<size_t>(global_edge_map.back()) == global_edge_map.size());
26252625
if (rank == 0) {
26262626
fmt::print("Edge id map {} contiguous.\n", (is_contiguous ? "is" : "is not"));
26272627
}
@@ -2798,7 +2798,7 @@ namespace {
27982798
// sorted and there are no duplicates, we just need to see if the id
27992799
// at global_face_map.size() == global_face_map.size();
28002800
bool is_contiguous =
2801-
global_face_map.empty() || ((size_t)global_face_map.back() == global_face_map.size());
2801+
global_face_map.empty() || (static_cast<size_t>(global_face_map.back()) == global_face_map.size());
28022802
if (rank == 0) {
28032803
fmt::print("Face id map {} contiguous.\n", (is_contiguous ? "is" : "is not"));
28042804
}
@@ -2969,7 +2969,7 @@ namespace {
29692969
// sorted and there are no duplicates, we just need to see if the id
29702970
// at global_node_map.size() == global_node_map.size();
29712971
bool is_contiguous =
2972-
global_node_map.empty() || ((size_t)global_node_map.back() == global_node_map.size());
2972+
global_node_map.empty() || (static_cast<size_t>(global_node_map.back()) == global_node_map.size());
29732973
if (rank == 0) {
29742974
fmt::print("Node map {} contiguous.\n", (is_contiguous ? "is" : "is not"));
29752975
}
@@ -3393,14 +3393,14 @@ namespace {
33933393
// output nodeset
33943394
// NOTE: global_node above is 1-based.
33953395
glob_sets[ns].nodeCount =
3396-
std::accumulate(glob_ns_nodes.begin(), glob_ns_nodes.end(), (INT)0);
3396+
std::accumulate(glob_ns_nodes.begin(), glob_ns_nodes.end(), static_cast<INT>(0));
33973397
glob_sets[ns].nodeSetNodes.resize(glob_sets[ns].entity_count());
33983398
glob_sets[ns].dfCount = glob_sets[ns].nodeCount;
33993399

34003400
// distFactors is a vector of 'char' to allow storage of either float or double.
34013401
glob_sets[ns].distFactors.resize(glob_sets[ns].dfCount * ExodusFile::io_word_size());
34023402

3403-
T *glob_df = (T *)(Data(glob_sets[ns].distFactors));
3403+
T *glob_df = (T *)Data(glob_sets[ns].distFactors);
34043404
size_t j = 0;
34053405
for (size_t i = 1; i <= total_node_count; i++) {
34063406
if (glob_ns_nodes[i] == 1) {
@@ -3804,7 +3804,7 @@ namespace {
38043804
glob_edgeblocks[b].edgeCount += temp_block.num_entry;
38053805
glob_edgeblocks[b].nodesPerEdge = temp_block.num_nodes_per_entry;
38063806
glob_edgeblocks[b].attributeCount = temp_block.num_attribute;
3807-
glob_edgeblocks[b].position_ = (int)b;
3807+
glob_edgeblocks[b].position_ = static_cast<int>(b);
38083808
copy_string(glob_edgeblocks[b].elType, temp_block.topology);
38093809
}
38103810

@@ -4179,7 +4179,7 @@ namespace {
41794179
glob_faceblocks[b].faceCount += temp_block.num_entry;
41804180
glob_faceblocks[b].nodesPerFace = temp_block.num_nodes_per_entry;
41814181
glob_faceblocks[b].attributeCount = temp_block.num_attribute;
4182-
glob_faceblocks[b].position_ = (int)b;
4182+
glob_faceblocks[b].position_ = static_cast<int>(b);
41834183
copy_string(glob_faceblocks[b].elType, temp_block.topology);
41844184
}
41854185

0 commit comments

Comments
 (0)