From 333cbf53ed48206effd4963ee5ddac25d14ba7b0 Mon Sep 17 00:00:00 2001 From: Daniel Arndt Date: Mon, 26 Nov 2018 18:45:18 +0100 Subject: [PATCH] Avoid C-style cast in distributed --- source/distributed/p4est_wrappers.cc | 48 +++++++++++++++------------- source/distributed/tria.cc | 11 +++---- 2 files changed, 29 insertions(+), 30 deletions(-) diff --git a/source/distributed/p4est_wrappers.cc b/source/distributed/p4est_wrappers.cc index 44aa31b901..3e9765122c 100644 --- a/source/distributed/p4est_wrappers.cc +++ b/source/distributed/p4est_wrappers.cc @@ -84,11 +84,11 @@ namespace internal typename dealii::internal::p4est::iter::corner_info *info, void * user_data) { - int i, j; - int nsides = info->sides.elem_count; - typename dealii::internal::p4est::iter::corner_side *sides = - (typename dealii::internal::p4est::iter::corner_side - *)(info->sides.array); + int i, j; + int nsides = info->sides.elem_count; + auto *sides = reinterpret_cast< + typename dealii::internal::p4est::iter::corner_side *>( + info->sides.array); FindGhosts *fg = static_cast *>(user_data); sc_array_t *subids = fg->subids; @@ -123,8 +123,9 @@ namespace internal return; } - nsubs = (int)subids->elem_count; - subdomain_ids = (dealii::types::subdomain_id *)(subids->array); + nsubs = static_cast(subids->elem_count); + subdomain_ids = + reinterpret_cast(subids->array); for (i = 0; i < nsides; i++) { @@ -160,13 +161,12 @@ namespace internal typename dealii::internal::p4est::iter::edge_info *info, void * user_data) { - int i, j, k; - int nsides = info->sides.elem_count; - typename dealii::internal::p4est::iter::edge_side *sides = - (typename dealii::internal::p4est::iter::edge_side *)(info->sides - .array); - FindGhosts *fg = - static_cast *>(user_data); + int i, j, k; + int nsides = info->sides.elem_count; + auto *sides = reinterpret_cast< + typename dealii::internal::p4est::iter::edge_side *>( + info->sides.array); + auto * fg = static_cast *>(user_data); sc_array_t *subids = fg->subids; const dealii::parallel::distributed::Triangulation * triangulation = fg->triangulation; @@ -203,8 +203,9 @@ namespace internal return; } - nsubs = (int)subids->elem_count; - subdomain_ids = (dealii::types::subdomain_id *)(subids->array); + nsubs = static_cast(subids->elem_count); + subdomain_ids = + reinterpret_cast(subids->array); for (i = 0; i < nsides; i++) { @@ -244,11 +245,11 @@ namespace internal typename dealii::internal::p4est::iter::face_info *info, void * user_data) { - int i, j, k; - int nsides = info->sides.elem_count; - typename dealii::internal::p4est::iter::face_side *sides = - (typename dealii::internal::p4est::iter::face_side *)(info->sides - .array); + int i, j, k; + int nsides = info->sides.elem_count; + auto *sides = reinterpret_cast< + typename dealii::internal::p4est::iter::face_side *>( + info->sides.array); FindGhosts *fg = static_cast *>(user_data); sc_array_t *subids = fg->subids; @@ -288,8 +289,9 @@ namespace internal return; } - nsubs = (int)subids->elem_count; - subdomain_ids = (dealii::types::subdomain_id *)(subids->array); + nsubs = static_cast(subids->elem_count); + subdomain_ids = + reinterpret_cast(subids->array); for (i = 0; i < nsides; i++) { diff --git a/source/distributed/tria.cc b/source/distributed/tria.cc index 5e0611472a..29957e56ac 100644 --- a/source/distributed/tria.cc +++ b/source/distributed/tria.cc @@ -3594,16 +3594,13 @@ namespace parallel types::subdomain_id ghost_owner = 0; typename dealii::internal::p4est::types::topidx ghost_tree = 0; - for (unsigned int g_idx = 0; - g_idx < parallel_ghost->ghosts.elem_count; + for (int g_idx = 0; static_cast(g_idx) < + parallel_ghost->ghosts.elem_count; ++g_idx) { - while ( - g_idx >= - (unsigned int)parallel_ghost->proc_offsets[ghost_owner + 1]) + while (g_idx >= parallel_ghost->proc_offsets[ghost_owner + 1]) ++ghost_owner; - while (g_idx >= - (unsigned int)parallel_ghost->tree_offsets[ghost_tree + 1]) + while (g_idx >= parallel_ghost->tree_offsets[ghost_tree + 1]) ++ghost_tree; quadr = static_cast< -- 2.39.5