Skip to content

Commit ecd012c

Browse files
authored
Merge pull request #9657 from awlauria/squash_warnings
Fix misc. compiler warnings.
2 parents 7c9ab0a + 9f15ca6 commit ecd012c

File tree

13 files changed

+33
-57
lines changed

13 files changed

+33
-57
lines changed

ompi/dpm/dpm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,7 @@ static int dpm_convert(opal_list_t *infos,
690690
char *ck, *ptr, *help_str = NULL;
691691
int rc;
692692
char **tmp;
693-
dpm_conflicts_t *modifiers;
693+
dpm_conflicts_t *modifiers = NULL;
694694
const char *attr;
695695

696696
/* pick the modifiers to be checked */

ompi/mca/hook/comm_method/hook_comm_method_fns.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,9 @@
2222
#include "ompi/mca/bml/base/base.h"
2323
#include "ompi/mca/mtl/base/base.h"
2424

25-
// In regular strncpy up to n bytes are copied, so if the 'to' buffer
26-
// was char string[16] and you called strncpy(string, , 16) you could
27-
// get 16 bytes of chars without a null. My preferred API is to let
28-
// n be the size of the buffer, and to let n-1 chars be copied, and
29-
// to guarantee null termination.
3025
static void
3126
mystrncpy(char *to, const char *from, int n) {
32-
strncpy(to, from, n-1);
33-
to[n-1] = 0;
27+
snprintf(to, n, "%s", from);
3428
}
3529

3630
// For converting comm_method strings to comm_method id# and back.

ompi/mca/osc/base/base.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ BEGIN_C_DECLS
3737
int ompi_osc_base_find_available(bool enable_progress_threads,
3838
bool enable_mpi_threads);
3939

40+
void ompi_osc_base_set_memory_alignment(struct opal_info_t *info,
41+
size_t *memory_alignment);
42+
4043
int ompi_osc_base_select(ompi_win_t *win,
4144
void **base,
4245
size_t size,

ompi/mca/osc/base/osc_base_frame.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include "ompi/mca/mca.h"
2323
#include "opal/util/output.h"
2424
#include "opal/mca/base/base.h"
25-
25+
#include "opal/include/opal/align.h"
2626

2727
#include "ompi/mca/osc/osc.h"
2828
#include "ompi/mca/osc/base/base.h"
@@ -36,6 +36,24 @@
3636

3737
#include "ompi/mca/osc/base/static-components.h"
3838

39+
void
40+
ompi_osc_base_set_memory_alignment(struct opal_info_t *info,
41+
size_t *memory_alignment)
42+
{
43+
int flag;
44+
opal_cstring_t *align_info_str;
45+
46+
opal_info_get(info, "mpi_minimum_memory_alignment", &align_info_str, &flag);
47+
if (flag) {
48+
long long tmp_align = atoll(align_info_str->string);
49+
OBJ_RELEASE(align_info_str);
50+
if ((long long) OPAL_ALIGN_MIN < tmp_align) {
51+
*memory_alignment = tmp_align;
52+
}
53+
}
54+
}
55+
56+
3957
int
4058
ompi_osc_base_find_available(bool enable_progress_threads,
4159
bool enable_mpi_threads)

ompi/mca/osc/rdma/osc_rdma_component.c

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
#include "opal/util/arch.h"
4949
#include "opal/util/argv.h"
5050
#include "opal/util/printf.h"
51-
#include "opal/align.h"
5251
#include "opal/util/sys_limits.h"
5352
#if OPAL_CUDA_SUPPORT
5453
#include "opal/mca/common/cuda/common_cuda.h"
@@ -1321,8 +1320,6 @@ static int ompi_osc_rdma_component_select (struct ompi_win_t *win, void **base,
13211320
int world_size = ompi_comm_size (comm);
13221321
int init_limit = 256;
13231322
int ret;
1324-
int flag;
1325-
char infoval[32];
13261323
char *name;
13271324

13281325
/* the osc/sm component is the exclusive provider for support for shared
@@ -1363,15 +1360,7 @@ static int ompi_osc_rdma_component_select (struct ompi_win_t *win, void **base,
13631360
module->size = size;
13641361
module->memory_alignment = mca_osc_rdma_component.memory_alignment;
13651362
if (NULL != info) {
1366-
opal_cstring_t *align_info_str;
1367-
opal_info_get(info, "mpi_minimum_memory_alignment", &align_info_str, &flag);
1368-
if (flag) {
1369-
ssize_t tmp_align = atoll(align_info_str->string);
1370-
OBJ_RELEASE(align_info_str);
1371-
if (OPAL_ALIGN_MIN < tmp_align) {
1372-
module->memory_alignment = tmp_align;
1373-
}
1374-
}
1363+
ompi_osc_base_set_memory_alignment(info, &module->memory_alignment);
13751364
}
13761365

13771366
/* set the module so we properly cleanup */

ompi/mca/osc/sm/osc_sm_component.c

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#include "ompi/mca/osc/base/osc_base_obj_convert.h"
3030
#include "ompi/request/request.h"
3131
#include "opal/util/sys_limits.h"
32-
#include "opal/include/opal/align.h"
32+
#include "opal/align.h"
3333
#include "opal/util/info_subscriber.h"
3434
#include "opal/util/printf.h"
3535
#include "opal/mca/mpool/base/base.h"
@@ -196,7 +196,6 @@ component_select(struct ompi_win_t *win, void **base, size_t size, int disp_unit
196196
int comm_size = ompi_comm_size (comm);
197197
bool unlink_needed = false;
198198
int ret = OMPI_ERROR;
199-
int flag;
200199
size_t memory_alignment = OPAL_ALIGN_MIN;
201200

202201
if (OMPI_SUCCESS != (ret = check_win_ok(comm, flavor))) {
@@ -216,15 +215,7 @@ component_select(struct ompi_win_t *win, void **base, size_t size, int disp_unit
216215
if (OPAL_SUCCESS != ret) goto error;
217216

218217
if (NULL != info) {
219-
opal_cstring_t *align_info_str;
220-
ret = opal_info_get(info, "mpi_minimum_memory_alignment", &align_info_str, &flag);
221-
if (flag) {
222-
ssize_t tmp_align = atoll(align_info_str->string);
223-
OBJ_RELEASE(align_info_str);
224-
if (OPAL_ALIGN_MIN < tmp_align) {
225-
memory_alignment = tmp_align;
226-
}
227-
}
218+
ompi_osc_base_set_memory_alignment(info, &memory_alignment);
228219
}
229220

230221
/* fill in the function pointer part */

ompi/mpi/fortran/mpif-h/init_f.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,7 @@
2222

2323
#include "ompi_config.h"
2424

25-
#if (OPAL_HAVE_WEAK_SYMBOLS || ! OMPI_BUILD_MPI_PROFILING)
26-
#if OPAL_CC_USE_PRAGMA_IDENT
27-
#pragma ident OMPI_IDENT_STRING
28-
#elif OPAL_CC_USE_IDENT
29-
#ident OMPI_IDENT_STRING
30-
#else
3125
const char ident[] = OMPI_IDENT_STRING;
32-
#endif
33-
#endif
34-
3526

3627
#include "ompi/mpi/fortran/mpif-h/bindings.h"
3728

ompi/mpiext/affinity/c/mpiext_affinity_str.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ static int get_rsrc_exists(char str[OMPI_AFFINITY_STRING_MAX])
182182
{
183183
bool first = true;
184184
int i, num_cores, num_pus;
185-
char tmp[BUFSIZ];
185+
char tmp[OMPI_AFFINITY_STRING_MAX];
186186
const int stmp = sizeof(tmp) - 1;
187187
hwloc_obj_t socket, core, c2;
188188

ompi/runtime/ompi_mpi_init.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,6 @@ OPAL_DECLSPEC void (*__malloc_initialize_hook) (void) =
117117
*/
118118
#include <float.h>
119119

120-
#if OPAL_CC_USE_PRAGMA_IDENT
121-
#pragma ident OMPI_IDENT_STRING
122-
#elif OPAL_CC_USE_IDENT
123-
#ident OMPI_IDENT_STRING
124-
#endif
125120
const char ompi_version_string[] = OMPI_IDENT_STRING;
126121

127122
/*

opal/mca/hwloc/base/hwloc_base_util.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,7 +1047,7 @@ static char *bitmap2rangestr(int bitmap)
10471047
} else {
10481048
snprintf(tmp, stmp, "%d-%d", range_start, range_end);
10491049
}
1050-
strncat(ret, tmp, sizeof(ret) - strlen(ret) - 1);
1050+
snprintf(ret + strlen(ret), BUFSIZ, "%s", tmp);
10511051

10521052
range_start = -999;
10531053
}
@@ -1074,7 +1074,7 @@ static char *bitmap2rangestr(int bitmap)
10741074
} else {
10751075
snprintf(tmp, stmp, "%d-%d", range_start, range_end);
10761076
}
1077-
strncat(ret, tmp, sizeof(ret) - strlen(ret) - 1);
1077+
snprintf(ret + strlen(ret), BUFSIZ, "%s", tmp);
10781078
}
10791079

10801080
return ret;

0 commit comments

Comments
 (0)