[Openmp-commits] [openmp] r267470 - Fix buffer problem with printing long Hwloc affinity mask

Jonathan Peyton via Openmp-commits openmp-commits at lists.llvm.org
Mon Apr 25 14:08:31 PDT 2016


Author: jlpeyton
Date: Mon Apr 25 16:08:31 2016
New Revision: 267470

URL: http://llvm.org/viewvc/llvm-project?rev=267470&view=rev
Log:
Fix buffer problem with printing long Hwloc affinity mask

This change has the hwloc_bitmap_list_snprintf() function use the entire buffer
to print the mask.  There is no need to shorten the buffer length by 7.  It only
needs to be shortened by one byte.

Modified:
    openmp/trunk/runtime/src/kmp_affinity.cpp

Modified: openmp/trunk/runtime/src/kmp_affinity.cpp
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_affinity.cpp?rev=267470&r1=267469&r2=267470&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_affinity.cpp (original)
+++ openmp/trunk/runtime/src/kmp_affinity.cpp Mon Apr 25 16:08:31 2016
@@ -77,7 +77,7 @@ __kmp_affinity_print_mask(char *buf, int
         // Need to truncate the affinity mask string and add ellipsis.
         // To do this, we first write out the '{' + str(mask)
         buf[0] = '{';
-        hwloc_bitmap_list_snprintf(buf+1, buf_len-7, (hwloc_bitmap_t)mask);
+        hwloc_bitmap_list_snprintf(buf+1, buf_len-1, (hwloc_bitmap_t)mask);
         // then, what we do here is go to the 7th to last character, then go backwards until we are NOT
         // on a digit then write "...}\0".  This way it is a clean ellipsis addition and we don't
         // overwrite part of an affinity number. i.e., we avoid something like { 45, 67, 8...} and get




More information about the Openmp-commits mailing list