Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 b122119
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions test/hotspot/jtreg/vmTestbase/vm/mlvm/share/mlvmJvmtiUtils.c
Expand Up @@ -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;
Expand All @@ -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.
Expand Down

1 comment on commit b122119

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.