Skip to content

Commit ef5bd1b

Browse files
authored
Merge pull request #8593 from awlauria/fix_shadowing
Fix shadowing in ompi
2 parents 9647516 + 7d32da4 commit ef5bd1b

31 files changed

+135
-154
lines changed

config/opal_setup_cc.m4

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ AC_DEFUN([OPAL_SETUP_CC],[
296296
_OPAL_CHECK_SPECIFIC_CFLAGS(-Wmissing-prototypes, Wmissing_prototypes)
297297
_OPAL_CHECK_SPECIFIC_CFLAGS(-Wstrict-prototypes, Wstrict_prototypes)
298298
_OPAL_CHECK_SPECIFIC_CFLAGS(-Wcomment, Wcomment)
299+
_OPAL_CHECK_SPECIFIC_CFLAGS(-Wshadow, Wshadow)
299300
_OPAL_CHECK_SPECIFIC_CFLAGS(-Werror-implicit-function-declaration, Werror_implicit_function_declaration)
300301
_OPAL_CHECK_SPECIFIC_CFLAGS(-Wno-long-double, Wno_long_double, int main() { long double x; })
301302
_OPAL_CHECK_SPECIFIC_CFLAGS(-fno-strict-aliasing, fno_strict_aliasing, int main() { long double x; })

ompi/communicator/ft/comm_ft_detector.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -418,8 +418,7 @@ static int fd_heartbeat_request_cb(ompi_communicator_t* comm, ompi_comm_heartbea
418418
detector->hb_sstamp = 0.;
419419

420420
if( comm_detector_use_rdma_hb ) {
421-
ompi_communicator_t* comm = detector->comm;
422-
ompi_proc_t* proc = ompi_comm_peer_lookup(comm, msg->from);
421+
ompi_proc_t* proc = ompi_comm_peer_lookup(detector->comm, msg->from);
423422
assert( NULL != proc );
424423
mca_bml_base_endpoint_t* endpoint = mca_bml_base_get_endpoint(proc);
425424
assert( NULL != endpoint );
@@ -460,7 +459,7 @@ static int fd_heartbeat_request_cb(ompi_communicator_t* comm, ompi_comm_heartbea
460459

461460
static void fd_event_cb(int fd, short flags, void* pdetector)
462461
{
463-
comm_detector_t* detector = pdetector;;
462+
comm_detector_t* detector = pdetector;
464463
double stamp = PMPI_Wtime();
465464
double lastpeek = detector->hb_lastpeek;
466465
detector->hb_lastpeek = stamp;

ompi/datatype/ompi_datatype_args.c

Lines changed: 33 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -71,57 +71,45 @@ typedef struct __dt_args {
7171
#define OMPI_DATATYPE_ALIGN_PTR(PTR, TYPE)
7272
#endif /* OPAL_ALIGN_WORD_SIZE_INTEGERS */
7373

74-
/**
75-
* Some architectures require 64 bits pointers (to pointers) to
76-
* be 64 bits aligned. As in the ompi_datatype_args_t structure we have
77-
* 2 such array of pointers and one to an array of ints, if we start by
78-
* setting the 64 bits aligned one we will not have any trouble. Problem
79-
* originally reported on SPARC 64.
80-
*/
81-
#define ALLOC_ARGS(PDATA, IC, AC, DC) \
82-
do { \
83-
int length = sizeof(ompi_datatype_args_t) + (IC) * sizeof(int) + \
84-
(AC) * sizeof(ptrdiff_t) + (DC) * sizeof(MPI_Datatype); \
85-
char* buf = (char*)malloc( length ); \
86-
ompi_datatype_args_t* pArgs = (ompi_datatype_args_t*)buf; \
87-
pArgs->ci = (IC); \
88-
pArgs->ca = (AC); \
89-
pArgs->cd = (DC); \
90-
buf += sizeof(ompi_datatype_args_t); \
91-
if( pArgs->ca == 0 ) pArgs->a = NULL; \
92-
else { \
93-
pArgs->a = (ptrdiff_t*)buf; \
94-
buf += pArgs->ca * sizeof(ptrdiff_t); \
95-
} \
96-
if( pArgs->cd == 0 ) pArgs->d = NULL; \
97-
else { \
98-
pArgs->d = (ompi_datatype_t**)buf; \
99-
buf += pArgs->cd * sizeof(MPI_Datatype); \
100-
} \
101-
if( pArgs->ci == 0 ) pArgs->i = NULL; \
102-
else pArgs->i = (int*)buf; \
103-
pArgs->ref_count = 1; \
104-
pArgs->total_pack_size = (4 + (IC) + (DC)) * sizeof(int) + \
105-
(AC) * sizeof(ptrdiff_t); \
106-
(PDATA)->args = (void*)pArgs; \
107-
(PDATA)->packed_description = 0; \
108-
} while(0)
109-
110-
11174
int32_t ompi_datatype_set_args( ompi_datatype_t* pData,
11275
int32_t ci, const int32_t** i,
11376
int32_t ca, const ptrdiff_t* a,
11477
int32_t cd, ompi_datatype_t* const * d, int32_t type)
11578
{
11679
int pos;
117-
ompi_datatype_args_t* pArgs;
11880

11981
assert( NULL == pData->args );
120-
ALLOC_ARGS( pData, ci, ca, cd );
121-
122-
pArgs = (ompi_datatype_args_t*)pData->args;
82+
int length = sizeof(ompi_datatype_args_t) + ci * sizeof(int) +
83+
ca * sizeof(ptrdiff_t) + cd * sizeof(MPI_Datatype);
84+
char* buf = (char*)malloc( length );
85+
ompi_datatype_args_t* pArgs = (ompi_datatype_args_t*)buf;
86+
pArgs->ci = ci; pArgs->i = NULL;
87+
pArgs->ca = ca; pArgs->a = NULL;
88+
pArgs->cd = cd; pArgs->d = NULL;
12389
pArgs->create_type = type;
12490

91+
/**
92+
* Some architectures require 64 bits pointers (to pointers) to
93+
* be 64 bits aligned. As in the ompi_datatype_args_t structure we have
94+
* 2 such array of pointers and one to an array of ints, if we start by
95+
* setting the 64 bits aligned one we will not have any trouble. Problem
96+
* originally reported on SPARC 64.
97+
*/
98+
buf += sizeof(ompi_datatype_args_t);
99+
if( 0 != pArgs->ca ) {
100+
pArgs->a = (ptrdiff_t*)buf;
101+
buf += pArgs->ca * sizeof(ptrdiff_t);
102+
}
103+
if( 0 != pArgs->cd ) {
104+
pArgs->d = (ompi_datatype_t**)buf;
105+
buf += pArgs->cd * sizeof(MPI_Datatype);
106+
}
107+
if( 0 != pArgs->ci ) pArgs->i = (int*)buf;
108+
109+
pArgs->ref_count = 1;
110+
pArgs->total_pack_size = (4 + ci) * sizeof(int) +
111+
cd * sizeof(MPI_Datatype) +
112+
ca * sizeof(ptrdiff_t);
125113
switch(type) {
126114

127115
case MPI_COMBINER_DUP:
@@ -229,7 +217,7 @@ int32_t ompi_datatype_set_args( ompi_datatype_t* pData,
229217
pArgs->d[pos] = d[pos];
230218
if( !(ompi_datatype_is_predefined(d[pos])) ) {
231219
/* We handle a user defined datatype. We should make sure that the
232-
* user will not have the oportunity to destroy it before all derived
220+
* user will not have the opportunity to destroy it before all derived
233221
* datatypes are destroyed. As we keep pointers to every datatype
234222
* (for MPI_Type_get_content and MPI_Type_get_envelope) we have to make
235223
* sure that those datatype will be available if the user ask for them.
@@ -243,10 +231,12 @@ int32_t ompi_datatype_set_args( ompi_datatype_t* pData,
243231
pArgs->total_pack_size += sizeof(int); /* each data has an ID */
244232
}
245233

234+
pData->args = (void*)pArgs;
235+
pData->packed_description = 0;
236+
246237
return OMPI_SUCCESS;
247238
}
248239

249-
250240
int32_t ompi_datatype_print_args( const ompi_datatype_t* pData )
251241
{
252242
int32_t i;

ompi/datatype/ompi_datatype_module.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,9 @@ int32_t ompi_datatype_init( void )
544544
#define MOOG(name, index) \
545545
do { \
546546
int rc; \
547+
/* Silence 'unused' compiler warning in optimized builds, \
548+
where assert() is removed. */ \
549+
(void) rc; \
547550
ompi_mpi_##name.dt.d_f_to_c_index = index; \
548551
rc = opal_pointer_array_set_item(&ompi_datatype_f_to_c_table, \
549552
index, &ompi_mpi_##name); \

ompi/mca/coll/base/coll_base_alltoallv.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ mca_coll_base_alltoallv_intra_basic_inplace(const void *rbuf, const int *rcounts
6363
if (i == rank) {
6464
continue;
6565
}
66-
size_t size = opal_datatype_span(&rdtype->super, rcounts[i], &gap);
67-
max_size = size > max_size ? size : max_size;
66+
size_t cur_size = opal_datatype_span(&rdtype->super, rcounts[i], &gap);
67+
max_size = cur_size > max_size ? cur_size : max_size;
6868
}
6969
/* The gap will always be the same as we are working on the same datatype */
7070

ompi/mca/coll/libnbc/nbc_internal.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -549,13 +549,13 @@ static inline int NBC_Unpack(void *src, int srccount, MPI_Datatype srctype, void
549549
return OMPI_SUCCESS;
550550
}
551551

552-
/* deletes elements from dict until low watermark is reached */
553-
static inline void NBC_SchedCache_dictwipe(hb_tree *dict, int *size) {
552+
/* deletes elements from dict_in until low watermark is reached */
553+
static inline void NBC_SchedCache_dictwipe(hb_tree *dict_in, int *size) {
554554
hb_itor *itor;
555555

556-
itor = hb_itor_new(dict);
556+
itor = hb_itor_new(dict_in);
557557
for (; hb_itor_valid(itor) && (*size>NBC_SCHED_DICT_LOWER); hb_itor_next(itor)) {
558-
hb_tree_remove(dict, hb_itor_key(itor), 0);
558+
hb_tree_remove(dict_in, hb_itor_key(itor), 0);
559559
*size = *size-1;
560560
}
561561
hb_itor_destroy(itor);

ompi/mca/coll/sm/coll_sm.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ BEGIN_C_DECLS
3838
great while. Use a "goto" label for expdiency to exit loops. */
3939
#define SPIN_CONDITION_MAX 100000
4040
#define SPIN_CONDITION(cond, exit_label) \
41-
do { int i; \
41+
do { \
4242
if (cond) goto exit_label; \
43-
for (i = 0; i < SPIN_CONDITION_MAX; ++i) { \
43+
for (int spin_cond_i = 0; spin_cond_i < SPIN_CONDITION_MAX; ++spin_cond_i) { \
4444
if (cond) { goto exit_label; } \
4545
} \
4646
opal_progress(); \

ompi/mca/coll/sm/coll_sm_module.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,6 @@ int ompi_coll_sm_lazy_enable(mca_coll_base_module_t *module,
492492
static int bootstrap_comm(ompi_communicator_t *comm,
493493
mca_coll_sm_module_t *module)
494494
{
495-
int i;
496495
char *shortpath, *fullpath;
497496
mca_coll_sm_component_t *c = &mca_coll_sm_component;
498497
mca_coll_sm_comm_t *data = module->sm_comm_data;
@@ -511,7 +510,7 @@ static int bootstrap_comm(ompi_communicator_t *comm,
511510
with the lowest ORTE name to form a unique filename. */
512511
proc = ompi_group_peer_lookup(comm->c_local_group, 0);
513512
lowest_name = OMPI_CAST_RTE_NAME(&proc->super.proc_name);
514-
for (i = 1; i < comm_size; ++i) {
513+
for (int i = 1; i < comm_size; ++i) {
515514
proc = ompi_group_peer_lookup(comm->c_local_group, i);
516515
if (ompi_rte_compare_name_fields(OMPI_RTE_CMP_ALL,
517516
OMPI_CAST_RTE_NAME(&proc->super.proc_name),

ompi/mca/osc/rdma/osc_rdma_component.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -916,7 +916,6 @@ static int ompi_osc_rdma_query_alternate_btls (ompi_communicator_t *comm, ompi_o
916916
mca_btl_base_selected_module_t *item;
917917
char **btls_to_use = opal_argv_split (ompi_osc_rdma_btl_alternate_names, ',');
918918
int btls_found = 0;
919-
void *tmp;
920919

921920
btls_to_use = opal_argv_split (ompi_osc_rdma_btl_alternate_names, ',');
922921
if (NULL == btls_to_use) {

ompi/mca/osc/rdma/osc_rdma_peer.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ int ompi_osc_rdma_new_peer (struct ompi_osc_rdma_module_t *module, int peer_id,
7979
struct mca_btl_base_endpoint_t *endpoint;
8080
ompi_osc_rdma_peer_t *peer;
8181
uint8_t module_btl_index = UINT8_MAX;
82-
mca_btl_base_module_t *btl = NULL;
8382

8483
*peer_out = NULL;
8584

@@ -90,10 +89,6 @@ int ompi_osc_rdma_new_peer (struct ompi_osc_rdma_module_t *module, int peer_id,
9089
return ret;
9190
}
9291

93-
if (endpoint) {
94-
btl = ompi_osc_rdma_selected_btl (module, module_btl_index);
95-
}
96-
9792
if (MPI_WIN_FLAVOR_DYNAMIC == module->flavor) {
9893
peer = (ompi_osc_rdma_peer_t *) OBJ_NEW(ompi_osc_rdma_peer_dynamic_t);
9994
} else if (module->same_size && module->same_disp_unit) {
@@ -127,7 +122,6 @@ static int ompi_osc_rdma_peer_setup (ompi_osc_rdma_module_t *module, ompi_osc_rd
127122
ompi_osc_rdma_peer_extended_t *ex_peer = (ompi_osc_rdma_peer_extended_t *) peer;
128123
uint64_t peer_data_size;
129124
uint64_t peer_data_offset, array_pointer;
130-
mca_btl_base_module_t *array_btl;
131125
struct mca_btl_base_endpoint_t *array_endpoint;
132126
ompi_osc_rdma_region_t *array_peer_data, *node_peer_data;
133127
ompi_osc_rdma_rank_data_t rank_data;

0 commit comments

Comments
 (0)