1818 * and Technology (RIST). All rights reserved.
1919 * Copyright (C) 2018 Mellanox Technologies, Ltd.
2020 * All rights reserved.
21+ * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved.
22+ * Copyright (c) 2019 IBM Corporation. All rights reserved.
2123 * $COPYRIGHT$
2224 *
2325 * Additional copyrights may follow
@@ -1920,14 +1922,14 @@ int opal_hwloc_base_cset2str(char *str, int len,
19201922 for (core_index = 0 ; core_index < num_cores ; ++ core_index ) {
19211923 if (map [socket_index ][core_index ] > 0 ) {
19221924 if (!first ) {
1923- strncat (str , ", " , len - strlen (str ));
1925+ strncat (str , ", " , len - strlen (str ) - 1 );
19241926 }
19251927 first = false;
19261928
19271929 snprintf (tmp , stmp , "socket %d[core %d[hwt %s]]" ,
19281930 socket_index , core_index ,
19291931 bitmap2rangestr (map [socket_index ][core_index ]));
1930- strncat (str , tmp , len - strlen (str ));
1932+ strncat (str , tmp , len - strlen (str ) - 1 );
19311933 }
19321934 }
19331935 }
@@ -1983,7 +1985,7 @@ int opal_hwloc_base_cset2mapstr(char *str, int len,
19831985 for (socket = hwloc_get_obj_by_type (topo , HWLOC_OBJ_SOCKET , 0 );
19841986 NULL != socket ;
19851987 socket = socket -> next_cousin ) {
1986- strncat (str , "[" , len - strlen (str ));
1988+ strncat (str , "[" , len - strlen (str ) - 1 );
19871989
19881990 /* Iterate over all existing cores in this socket */
19891991 core_index = 0 ;
@@ -1995,7 +1997,7 @@ int opal_hwloc_base_cset2mapstr(char *str, int len,
19951997 socket -> cpuset ,
19961998 HWLOC_OBJ_CORE , ++ core_index )) {
19971999 if (core_index > 0 ) {
1998- strncat (str , "/" , len - strlen (str ));
2000+ strncat (str , "/" , len - strlen (str ) - 1 );
19992001 }
20002002
20012003 /* Iterate over all existing PUs in this core */
@@ -2010,13 +2012,13 @@ int opal_hwloc_base_cset2mapstr(char *str, int len,
20102012
20112013 /* Is this PU in the cpuset? */
20122014 if (hwloc_bitmap_isset (cpuset , pu -> os_index )) {
2013- strncat (str , "B" , len - strlen (str ));
2015+ strncat (str , "B" , len - strlen (str ) - 1 );
20142016 } else {
2015- strncat (str , "." , len - strlen (str ));
2017+ strncat (str , "." , len - strlen (str ) - 1 );
20162018 }
20172019 }
20182020 }
2019- strncat (str , "]" , len - strlen (str ));
2021+ strncat (str , "]" , len - strlen (str ) - 1 );
20202022 }
20212023
20222024 return OPAL_SUCCESS ;
0 commit comments