[Openmp-commits] [openmp] c55d6f1 - Revert "[OpenMP][libomp] Remove false positive for memory sanitizer"

Ron Lieberman via Openmp-commits openmp-commits at lists.llvm.org
Mon Feb 6 11:19:17 PST 2023


Author: Ron Lieberman
Date: 2023-02-06T13:16:37-06:00
New Revision: c55d6f169b8b804122e1433c0298a739bfd0c777

URL: https://github.com/llvm/llvm-project/commit/c55d6f169b8b804122e1433c0298a739bfd0c777
DIFF: https://github.com/llvm/llvm-project/commit/c55d6f169b8b804122e1433c0298a739bfd0c777.diff

LOG: Revert "[OpenMP][libomp] Remove false positive for memory sanitizer"

breaks amdgpu buildbot

This reverts commit 402981ee25fe135d63226a7de17dbb14c437c71b.

Added: 
    

Modified: 
    openmp/runtime/src/kmp_safe_c_api.h
    openmp/runtime/src/kmp_str.cpp

Removed: 
    


################################################################################
diff  --git a/openmp/runtime/src/kmp_safe_c_api.h b/openmp/runtime/src/kmp_safe_c_api.h
index 72f26fd9897d0..3db1ada37b07b 100644
--- a/openmp/runtime/src/kmp_safe_c_api.h
+++ b/openmp/runtime/src/kmp_safe_c_api.h
@@ -30,7 +30,6 @@
 #define KMP_SSCANF sscanf_s
 #define KMP_STRCPY_S strcpy_s
 #define KMP_STRNCPY_S strncpy_s
-#define KMP_STRNCAT_S strncat_s
 
 // Use this only when buffer size is unknown
 #define KMP_MEMCPY(dst, src, cnt) memcpy_s(dst, cnt, src, cnt)
@@ -62,7 +61,6 @@ template <typename T> struct kmp_get_rmax_t<T, true> {
 #define KMP_SSCANF sscanf
 #define KMP_STRCPY_S(dst, bsz, src) strcpy(dst, src)
 #define KMP_STRNCPY_S(dst, bsz, src, cnt) strncpy(dst, src, cnt)
-#define KMP_STRNCAT_S(dst, bsz, src, cnt) strncat(dst, src, cnt)
 #define KMP_VSNPRINTF vsnprintf
 #define KMP_STRNCPY strncpy
 #define KMP_STRLEN strlen

diff  --git a/openmp/runtime/src/kmp_str.cpp b/openmp/runtime/src/kmp_str.cpp
index 41e4148cfe3c5..e64f989fbc698 100644
--- a/openmp/runtime/src/kmp_str.cpp
+++ b/openmp/runtime/src/kmp_str.cpp
@@ -137,7 +137,8 @@ void __kmp_str_buf_cat(kmp_str_buf_t *buffer, char const *str, size_t len) {
   KMP_DEBUG_ASSERT(len >= 0);
 
   __kmp_str_buf_reserve(buffer, buffer->used + len + 1);
-  KMP_STRNCAT_S(buffer->str + buffer->used, len + 1, str, len);
+  KMP_MEMCPY(buffer->str + buffer->used, str, len);
+  buffer->str[buffer->used + len] = 0;
   __kmp_type_convert(buffer->used + len, &(buffer->used));
   KMP_STR_BUF_INVARIANT(buffer);
 } // __kmp_str_buf_cat
@@ -150,7 +151,8 @@ void __kmp_str_buf_catbuf(kmp_str_buf_t *dest, const kmp_str_buf_t *src) {
   if (!src->str || !src->used)
     return;
   __kmp_str_buf_reserve(dest, dest->used + src->used + 1);
-  KMP_STRNCAT_S(dest->str + dest->used, src->used + 1, src->str, src->used);
+  KMP_MEMCPY(dest->str + dest->used, src->str, src->used);
+  dest->str[dest->used + src->used] = 0;
   dest->used += src->used;
   KMP_STR_BUF_INVARIANT(dest);
 } // __kmp_str_buf_catbuf


        


More information about the Openmp-commits mailing list