[OpenMP] Fixed a bug when displaying affinity

Currently the affinity format string has initial value. When users set
the format via OMP_AFFINITY_FORMAT, it will overwrite the format string. However,
when copying the format, the tailing null is missing. As a result, if the user
format string is shorter than default value, the remaining part in the default
value still makes effort. This bug is not exposed because the test case doesn't
check the end of a string. It only checks whether given output "contains" the
check string.

Reviewed By: AndreyChurbanov

Differential Revision: https://reviews.llvm.org/D91309
This commit is contained in:
Shilei Tian 2020-11-12 22:27:22 -05:00
parent 8920ef06a1
commit 24d0ef0f50
2 changed files with 3 additions and 5 deletions

View File

@ -64,11 +64,9 @@ static inline void __kmp_strncpy_truncate(char *buffer, size_t buf_size,
char const *src, size_t src_size) {
if (src_size >= buf_size) {
src_size = buf_size - 1;
KMP_STRNCPY_S(buffer, buf_size, src, src_size);
buffer[buf_size - 1] = '\0';
} else {
KMP_STRNCPY_S(buffer, buf_size, src, src_size);
}
KMP_STRNCPY_S(buffer, buf_size, src, src_size);
buffer[src_size] = '\0';
}
#endif // KMP_SAFE_C_API_H

View File

@ -13,4 +13,4 @@ int main(int argc, char** argv) {
return 0;
}
// CHECK-8: num_threads=8 TESTER-ENV: tl:1 tn:[0-7] nt:8
// CHECK-8: num_threads=8 TESTER-ENV: tl:1 tn:[0-7] nt:8$