Skip to content
Permalink
Browse files
8252051: Make mlvmJvmtiUtils strncpy uses GCC 10.x friendly
Reviewed-by: phh
  • Loading branch information
caojoshua authored and RealCLanger committed Oct 20, 2021
1 parent 2847e34 commit b12211907f1b3edc00c5561cda343fbf0821be4c
Showing with 4 additions and 11 deletions.
  1. +4 −11 test/hotspot/jtreg/vmTestbase/vm/mlvm/share/mlvmJvmtiUtils.c
@@ -45,11 +45,6 @@ void copyFromJString(JNIEnv * pEnv, jstring src, char ** dst) {
NSK_CPP_STUB3(ReleaseStringUTFChars, pEnv, src, pStr);
}

#if !defined(__clang_major__) && defined(__GNUC__) && (__GNUC__ >= 8)
_Pragma("GCC diagnostic push")
_Pragma("GCC diagnostic ignored \"-Wstringop-truncation\"")
#endif

struct MethodName * getMethodName(jvmtiEnv * pJvmtiEnv, jmethodID method) {
char * szName;
char * szSignature;
@@ -71,18 +66,16 @@ struct MethodName * getMethodName(jvmtiEnv * pJvmtiEnv, jmethodID method) {
}

mn = malloc(sizeof(MethodNameStruct));
strncpy(mn->methodName, szName, sizeof(mn->methodName));
strncpy(mn->classSig, szSignature, sizeof(mn->classSig));
strncpy(mn->methodName, szName, sizeof(mn->methodName) - 1);
mn->methodName[sizeof(mn->methodName) - 1] = '\0';
strncpy(mn->classSig, szSignature, sizeof(mn->classSig) - 1);
mn->classSig[sizeof(mn->classSig) - 1] = '\0';

NSK_JVMTI_VERIFY(NSK_CPP_STUB2(Deallocate, pJvmtiEnv, (void *) szName));
NSK_JVMTI_VERIFY(NSK_CPP_STUB2(Deallocate, pJvmtiEnv, (void *) szSignature));
return mn;
}

#if !defined(__clang_major__) && defined(__GNUC__) && (__GNUC__ >= 8)
_Pragma("GCC diagnostic pop")
#endif

char * locationToString(jvmtiEnv * pJvmtiEnv, jmethodID method, jlocation location) {
struct MethodName * pMN;
// gcc 7.3 claims that snprintf below can output between 6 and 531 bytes. Setting buffer size to 600.

1 comment on commit b122119

@openjdk-notifier

This comment has been minimized.

Copy link

@openjdk-notifier openjdk-notifier bot commented on b122119 Oct 20, 2021

Please sign in to comment.