1919 * Copyright (C) 2018 Mellanox Technologies, Ltd.
2020 * All rights reserved.
2121 * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved.
22+ * Copyright (c) 2019 IBM Corporation. All rights reserved.
2223 * $COPYRIGHT$
2324 *
2425 * Additional copyrights may follow
@@ -1728,14 +1729,14 @@ int opal_hwloc_base_cset2str(char *str, int len,
17281729 for (core_index = 0 ; core_index < num_cores ; ++ core_index ) {
17291730 if (map [socket_index ][core_index ] > 0 ) {
17301731 if (!first ) {
1731- strncat (str , ", " , len - strlen (str ));
1732+ strncat (str , ", " , len - strlen (str ) - 1 );
17321733 }
17331734 first = false;
17341735
17351736 snprintf (tmp , stmp , "socket %d[core %d[hwt %s]]" ,
17361737 socket_index , core_index ,
17371738 bitmap2rangestr (map [socket_index ][core_index ]));
1738- strncat (str , tmp , len - strlen (str ));
1739+ strncat (str , tmp , len - strlen (str ) - 1 );
17391740 }
17401741 }
17411742 }
@@ -1791,7 +1792,7 @@ int opal_hwloc_base_cset2mapstr(char *str, int len,
17911792 for (socket = hwloc_get_obj_by_type (topo , HWLOC_OBJ_SOCKET , 0 );
17921793 NULL != socket ;
17931794 socket = socket -> next_cousin ) {
1794- strncat (str , "[" , len - strlen (str ));
1795+ strncat (str , "[" , len - strlen (str ) - 1 );
17951796
17961797 /* Iterate over all existing cores in this socket */
17971798 core_index = 0 ;
@@ -1803,7 +1804,7 @@ int opal_hwloc_base_cset2mapstr(char *str, int len,
18031804 socket -> cpuset ,
18041805 HWLOC_OBJ_CORE , ++ core_index )) {
18051806 if (core_index > 0 ) {
1806- strncat (str , "/" , len - strlen (str ));
1807+ strncat (str , "/" , len - strlen (str ) - 1 );
18071808 }
18081809
18091810 /* Iterate over all existing PUs in this core */
@@ -1818,13 +1819,13 @@ int opal_hwloc_base_cset2mapstr(char *str, int len,
18181819
18191820 /* Is this PU in the cpuset? */
18201821 if (hwloc_bitmap_isset (cpuset , pu -> os_index )) {
1821- strncat (str , "B" , len - strlen (str ));
1822+ strncat (str , "B" , len - strlen (str ) - 1 );
18221823 } else {
1823- strncat (str , "." , len - strlen (str ));
1824+ strncat (str , "." , len - strlen (str ) - 1 );
18241825 }
18251826 }
18261827 }
1827- strncat (str , "]" , len - strlen (str ));
1828+ strncat (str , "]" , len - strlen (str ) - 1 );
18281829 }
18291830
18301831 return OPAL_SUCCESS ;
0 commit comments