Skip to content

Commit 0d763ea

Browse files
committed
Merge pull request #611 from hjelmn/opal_coverity
btl/openib: more coverity fixes
2 parents 85f0fff + b038eb6 commit 0d763ea

File tree

3 files changed

+25
-41
lines changed

3 files changed

+25
-41
lines changed

opal/mca/btl/openib/btl_openib_component.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1544,8 +1544,8 @@ static uint64_t calculate_max_reg (const char *device_name)
15441544

15451545
} else if (!strncmp(device_name, "mlx4", 4)) {
15461546
if (0 == stat("/sys/module/mlx4_core/parameters/log_num_mtt", &statinfo)) {
1547-
mtts_per_seg = 1 << read_module_param("/sys/module/mlx4_core/parameters/log_mtts_per_seg", 1, 63);
1548-
num_mtt = 1 << read_module_param("/sys/module/mlx4_core/parameters/log_mtts_per_seg", 1, 63);
1547+
mtts_per_seg = 1ull << read_module_param("/sys/module/mlx4_core/parameters/log_mtts_per_seg", 1, 63);
1548+
num_mtt = 1ull << read_module_param("/sys/module/mlx4_core/parameters/log_mtts_per_seg", 1, 63);
15491549
if (1 == num_mtt) {
15501550
/* NTH: is 19 a minimum? when log_num_mtt is set to 0 use 19 */
15511551
num_mtt = 1 << 19;
@@ -1557,7 +1557,7 @@ static uint64_t calculate_max_reg (const char *device_name)
15571557

15581558
} else if (!strncmp(device_name, "mthca", 5)) {
15591559
if (0 == stat("/sys/module/ib_mthca/parameters/num_mtt", &statinfo)) {
1560-
mtts_per_seg = 1 << read_module_param("/sys/module/ib_mthca/parameters/log_mtts_per_seg", 1, 63);
1560+
mtts_per_seg = 1ull << read_module_param("/sys/module/ib_mthca/parameters/log_mtts_per_seg", 1, 63);
15611561
num_mtt = read_module_param("/sys/module/ib_mthca/parameters/num_mtt", 1 << 20, (uint64_t) -1);
15621562
reserved_mtt = read_module_param("/sys/module/ib_mthca/parameters/fmr_reserved_mtts", 0, (uint64_t) -1);
15631563

@@ -3544,7 +3544,7 @@ static void handle_wc(mca_btl_openib_device_t* device, const uint32_t cq,
35443544
return;
35453545

35463546
error:
3547-
if(endpoint && endpoint->endpoint_proc && endpoint->endpoint_proc->proc_opal)
3547+
if(endpoint->endpoint_proc && endpoint->endpoint_proc->proc_opal)
35483548
remote_proc = endpoint->endpoint_proc->proc_opal;
35493549

35503550
/* For iWARP, the TCP connection is tied to the QP once the QP is

opal/mca/btl/openib/btl_openib_ini.c

Lines changed: 16 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
12
/*
23
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
34
* University Research and Technology
@@ -11,7 +12,7 @@
1112
* All rights reserved.
1213
* Copyright (c) 2006-2013 Cisco Systems, Inc. All rights reserved.
1314
* Copyright (c) 2008 Mellanox Technologies. All rights reserved.
14-
* Copyright (c) 2012-2013 Los Alamos National Security, LLC. All rights
15+
* Copyright (c) 2012-2015 Los Alamos National Security, LLC. All rights
1516
* reserved.
1617
* Copyright (c) 2014 Intel, Inc. All rights reserved
1718
* Copyright (c) 2014-2015 Research Organization for Information Science
@@ -345,25 +346,20 @@ static int parse_line(parsed_section_values_t *sv)
345346

346347
/* Next we get the value */
347348
val = btl_openib_ini_yylex();
348-
if (BTL_OPENIB_INI_PARSE_SINGLE_WORD == val ||
349-
BTL_OPENIB_INI_PARSE_VALUE == val) {
350-
value = strdup(btl_openib_ini_yytext);
351-
352-
/* Now we need to see the newline */
353-
val = btl_openib_ini_yylex();
354-
if (BTL_OPENIB_INI_PARSE_NEWLINE != val &&
355-
BTL_OPENIB_INI_PARSE_DONE != val) {
356-
opal_show_help("help-mpi-btl-openib.txt", "ini file:expected newline", true);
357-
free(value);
358-
return OPAL_ERROR;
359-
}
349+
if (BTL_OPENIB_INI_PARSE_SINGLE_WORD != val && BTL_OPENIB_INI_PARSE_VALUE != val) {
350+
return OPAL_ERROR;
360351
}
361352

353+
value = strdup(btl_openib_ini_yytext);
354+
355+
/* Now we need to see the newline */
356+
val = btl_openib_ini_yylex();
357+
362358
/* If we did not get EOL or EOF, something is wrong */
363-
else if (BTL_OPENIB_INI_PARSE_DONE != val &&
364-
BTL_OPENIB_INI_PARSE_NEWLINE != val) {
365-
opal_show_help("help-mpi-btl-openib.txt", "ini file:expected newline", true);
366-
return OPAL_ERROR;
359+
if (BTL_OPENIB_INI_PARSE_NEWLINE != val && BTL_OPENIB_INI_PARSE_DONE != val) {
360+
opal_show_help("help-mpi-btl-openib.txt", "ini file:expected newline", true);
361+
free(value);
362+
return OPAL_ERROR;
367363
}
368364

369365
/* Ok, we got a good parse. Now figure out what it is and save
@@ -621,19 +617,7 @@ static int save_section(parsed_section_values_t *s)
621617
*/
622618
int opal_btl_openib_ini_intify(char *str)
623619
{
624-
while (isspace(*str)) {
625-
++str;
626-
}
627-
628-
/* If it's hex, use sscanf() */
629-
if (strlen(str) > 3 && 0 == strncasecmp("0x", str, 2)) {
630-
unsigned int i;
631-
sscanf(str, "%X", &i);
632-
return (int) i;
633-
}
634-
635-
/* Nope -- just decimal, so use atoi() */
636-
return atoi(str);
620+
return strtol (str, NULL, 0);
637621
}
638622

639623

@@ -676,13 +660,13 @@ int opal_btl_openib_ini_intify_list(char *value, uint32_t **values, int *len)
676660
/* Iterate over the values and save them */
677661
str = value;
678662
comma = strchr(str, ',');
679-
do {
663+
while (NULL != comma) {
680664
*comma = '\0';
681665
(*values)[*len] = (uint32_t) opal_btl_openib_ini_intify(str);
682666
++(*len);
683667
str = comma + 1;
684668
comma = strchr(str, ',');
685-
} while (NULL != comma);
669+
}
686670
/* Get the last value (i.e., the value after the last
687671
comma, because it won't have been snarfed in the
688672
loop) */

opal/mca/btl/openib/connect/btl_openib_connect_udcm.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Copyright (c) 2007-2013 Cisco Systems, Inc. All rights reserved.
44
* Copyright (c) 2008-2009 Mellanox Technologies. All rights reserved.
55
* Copyright (c) 2009 IBM Corporation. All rights reserved.
6-
* Copyright (c) 2011-2014 Los Alamos National Security, LLC. All rights
6+
* Copyright (c) 2011-2015 Los Alamos National Security, LLC. All rights
77
* reserved.
88
* Copyright (c) 2014-2015 Research Organization for Information Science
99
* and Technology (RIST). All rights reserved.
@@ -1804,11 +1804,11 @@ static int udcm_handle_connect(mca_btl_openib_endpoint_t *lcl_ep,
18041804
udcm_endpoint_t *udep = UDCM_ENDPOINT_DATA(lcl_ep);
18051805
int rc = OPAL_ERROR;
18061806

1807-
do {
1808-
if (NULL == udep) {
1809-
break;
1810-
}
1807+
if (NULL == udep) {
1808+
return OPAL_ERROR;
1809+
}
18111810

1811+
do {
18121812
opal_mutex_lock (&udep->udep_lock);
18131813

18141814
if (true == udep->recv_req) {

0 commit comments

Comments
 (0)