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
@@ -1721,14 +1723,14 @@ int opal_hwloc_base_cset2str(char *str, int len,
17211723 for (core_index = 0 ; core_index < num_cores ; ++ core_index ) {
17221724 if (map [socket_index ][core_index ] > 0 ) {
17231725 if (!first ) {
1724- strncat (str , ", " , len - strlen (str ));
1726+ strncat (str , ", " , len - strlen (str ) - 1 );
17251727 }
17261728 first = false;
17271729
17281730 snprintf (tmp , stmp , "socket %d[core %d[hwt %s]]" ,
17291731 socket_index , core_index ,
17301732 bitmap2rangestr (map [socket_index ][core_index ]));
1731- strncat (str , tmp , len - strlen (str ));
1733+ strncat (str , tmp , len - strlen (str ) - 1 );
17321734 }
17331735 }
17341736 }
@@ -1784,7 +1786,7 @@ int opal_hwloc_base_cset2mapstr(char *str, int len,
17841786 for (socket = hwloc_get_obj_by_type (topo , HWLOC_OBJ_SOCKET , 0 );
17851787 NULL != socket ;
17861788 socket = socket -> next_cousin ) {
1787- strncat (str , "[" , len - strlen (str ));
1789+ strncat (str , "[" , len - strlen (str ) - 1 );
17881790
17891791 /* Iterate over all existing cores in this socket */
17901792 core_index = 0 ;
@@ -1796,7 +1798,7 @@ int opal_hwloc_base_cset2mapstr(char *str, int len,
17961798 socket -> cpuset ,
17971799 HWLOC_OBJ_CORE , ++ core_index )) {
17981800 if (core_index > 0 ) {
1799- strncat (str , "/" , len - strlen (str ));
1801+ strncat (str , "/" , len - strlen (str ) - 1 );
18001802 }
18011803
18021804 /* Iterate over all existing PUs in this core */
@@ -1811,13 +1813,13 @@ int opal_hwloc_base_cset2mapstr(char *str, int len,
18111813
18121814 /* Is this PU in the cpuset? */
18131815 if (hwloc_bitmap_isset (cpuset , pu -> os_index )) {
1814- strncat (str , "B" , len - strlen (str ));
1816+ strncat (str , "B" , len - strlen (str ) - 1 );
18151817 } else {
1816- strncat (str , "." , len - strlen (str ));
1818+ strncat (str , "." , len - strlen (str ) - 1 );
18171819 }
18181820 }
18191821 }
1820- strncat (str , "]" , len - strlen (str ));
1822+ strncat (str , "]" , len - strlen (str ) - 1 );
18211823 }
18221824
18231825 return OPAL_SUCCESS ;
0 commit comments