mirror of
https://github.com/openjdk/jdk.git
synced 2026-03-15 18:33:41 +00:00
8342860: Fix more NULL usage backsliding
Reviewed-by: kbarrett, jwaters, tschatzl, jsjolen
This commit is contained in:
parent
f6edfe58d6
commit
7d6a2f3740
@ -468,7 +468,7 @@ static void query_multipage_support() {
|
||||
|
||||
// Can we use mmap with 64K pages? (Should be available with AIX7.3 TL1)
|
||||
{
|
||||
void* p = mmap(NULL, 64*K, PROT_READ | PROT_WRITE, MAP_ANON_64K | MAP_ANONYMOUS | MAP_SHARED, -1, 0);
|
||||
void* p = mmap(nullptr, 64*K, PROT_READ | PROT_WRITE, MAP_ANON_64K | MAP_ANONYMOUS | MAP_SHARED, -1, 0);
|
||||
assert(p != (void*) -1, "mmap failed");
|
||||
if (p != (void*) -1) {
|
||||
g_multipage_support.can_use_64K_mmap_pages = (64*K == os::Aix::query_pagesize(p));
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -167,7 +167,7 @@ static bool find_ro_opt(char* mount_opts) {
|
||||
char* token;
|
||||
char* mo_ptr = mount_opts;
|
||||
// mount options are comma-separated (man proc).
|
||||
while ((token = strsep(&mo_ptr, ",")) != NULL) {
|
||||
while ((token = strsep(&mo_ptr, ",")) != nullptr) {
|
||||
if (strcmp(token, "ro") == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -816,7 +816,7 @@ void* os::dll_lookup(void* handle, const char* name) {
|
||||
void* ret = ::dlsym(handle, name);
|
||||
if (ret == nullptr) {
|
||||
const char* tmp = ::dlerror();
|
||||
// It is possible that we found a NULL symbol, hence no error.
|
||||
// It is possible that we found a null symbol, hence no error.
|
||||
if (tmp != nullptr) {
|
||||
log_debug(os)("Symbol %s not found in dll: %s", name, tmp);
|
||||
}
|
||||
|
||||
@ -4150,7 +4150,7 @@ void getWindowsInstallationType(char* buffer, int bufferSize) {
|
||||
}
|
||||
|
||||
// Query the value
|
||||
if (RegQueryValueExA(hKey, valueName, NULL, NULL, (LPBYTE)buffer, &valueLength) != ERROR_SUCCESS) {
|
||||
if (RegQueryValueExA(hKey, valueName, nullptr, nullptr, (LPBYTE)buffer, &valueLength) != ERROR_SUCCESS) {
|
||||
RegCloseKey(hKey);
|
||||
buffer[0] = '\0';
|
||||
return;
|
||||
|
||||
@ -1242,7 +1242,7 @@ static char decode_percent_encoded(const char *str, size_t& index) {
|
||||
hex[1] = str[index + 2];
|
||||
hex[2] = '\0';
|
||||
index += 2;
|
||||
return (char) strtol(hex, NULL, 16);
|
||||
return (char) strtol(hex, nullptr, 16);
|
||||
}
|
||||
return str[index];
|
||||
}
|
||||
|
||||
@ -69,7 +69,7 @@ typedef struct CDSFileMapRegion {
|
||||
size_t _ptrmap_offset; // Bitmap for relocating native pointer fields in archived heap objects.
|
||||
// (The base address is the bottom of the BM region).
|
||||
size_t _ptrmap_size_in_bits;
|
||||
char* _mapped_base; // Actually mapped address (NULL if this region is not mapped).
|
||||
char* _mapped_base; // Actually mapped address (null if this region is not mapped).
|
||||
} CDSFileMapRegion;
|
||||
|
||||
// This portion of the archive file header must remain unchanged for
|
||||
|
||||
@ -419,7 +419,7 @@ JVM_FindPrimitiveClass(JNIEnv *env, const char *utf);
|
||||
|
||||
|
||||
/*
|
||||
* Find a class from a boot class loader. Returns NULL if class not found.
|
||||
* Find a class from a boot class loader. Returns null if class not found.
|
||||
*/
|
||||
JNIEXPORT jclass JNICALL
|
||||
JVM_FindClassFromBootLoader(JNIEnv *env, const char *name);
|
||||
|
||||
@ -477,7 +477,7 @@ void ConstantPool::remove_resolved_klass_if_non_deterministic(int cp_index) {
|
||||
if (k == nullptr) {
|
||||
// We'd come here if the referenced class has been excluded via
|
||||
// SystemDictionaryShared::is_excluded_class(). As a result, ArchiveBuilder
|
||||
// has cleared the resolved_klasses()->at(...) pointer to NULL. Thus, we
|
||||
// has cleared the resolved_klasses()->at(...) pointer to null. Thus, we
|
||||
// need to revert the tag to JVM_CONSTANT_UnresolvedClass.
|
||||
can_archive = false;
|
||||
} else {
|
||||
|
||||
@ -644,7 +644,7 @@ bool ConnectionGraph::can_reduce_phi(PhiNode* ophi) const {
|
||||
//
|
||||
// 'curr_ctrl' is the control of the CastPP that we want to split through phi.
|
||||
// If the CastPP currently doesn't have a control then the CmpP/N will be
|
||||
// against the NULL constant, otherwise it will be against the constant input of
|
||||
// against the null constant, otherwise it will be against the constant input of
|
||||
// the existing CmpP/N. It's guaranteed that there will be a CmpP/N in the later
|
||||
// case because we have constraints on it and because the CastPP has a control
|
||||
// input.
|
||||
@ -672,7 +672,7 @@ Node* ConnectionGraph::specialize_cmp(Node* base, Node* curr_ctrl) {
|
||||
// means that the CastPP now will be specific for a given base instead of a Phi.
|
||||
// An If-Then-Else-Region block is inserted to control the CastPP. The control
|
||||
// of the CastPP is a copy of the current one (if there is one) or a check
|
||||
// against NULL.
|
||||
// against null.
|
||||
//
|
||||
// Before:
|
||||
//
|
||||
@ -806,10 +806,10 @@ Node* ConnectionGraph::split_castpp_load_through_phi(Node* curr_addp, Node* curr
|
||||
// After splitting the CastPP we'll put it under an If-Then-Else-Region control
|
||||
// flow. If the CastPP originally had an IfTrue/False control input then we'll
|
||||
// use a similar CmpP/N to control the new If-Then-Else-Region. Otherwise, we'll
|
||||
// juse use a CmpP/N against the NULL constant.
|
||||
// juse use a CmpP/N against the null constant.
|
||||
//
|
||||
// The If-Then-Else-Region isn't always needed. For instance, if input to
|
||||
// splitted cast was not nullable (or if it was the NULL constant) then we don't
|
||||
// splitted cast was not nullable (or if it was the null constant) then we don't
|
||||
// need (shouldn't) use a CastPP at all.
|
||||
//
|
||||
// After the casts are splitted we'll split the AddP->Loads through the Phi and
|
||||
@ -837,7 +837,7 @@ Node* ConnectionGraph::split_castpp_load_through_phi(Node* curr_addp, Node* curr
|
||||
//
|
||||
// After (Very much simplified):
|
||||
//
|
||||
// Call NULL
|
||||
// Call Null
|
||||
// \ /
|
||||
// CmpP
|
||||
// |
|
||||
@ -873,7 +873,7 @@ void ConnectionGraph::reduce_phi_on_castpp_field_load(Node* curr_castpp, Growabl
|
||||
// array, depending on the nullability status of the corresponding input in
|
||||
// ophi.
|
||||
//
|
||||
// - nullptr: Meaning that the base is actually the NULL constant and therefore
|
||||
// - nullptr: Meaning that the base is actually the null constant and therefore
|
||||
// we won't try to load from it.
|
||||
//
|
||||
// - CFG Node: Meaning that the base is a CastPP that was specialized for
|
||||
@ -890,7 +890,7 @@ void ConnectionGraph::reduce_phi_on_castpp_field_load(Node* curr_castpp, Growabl
|
||||
|
||||
if (base_t->maybe_null()) {
|
||||
if (base->is_Con()) {
|
||||
// Nothing todo as bases_for_loads[i] is already nullptr
|
||||
// Nothing todo as bases_for_loads[i] is already null
|
||||
} else {
|
||||
Node* new_castpp = specialize_castpp(curr_castpp, base, ophi->in(0)->in(i));
|
||||
bases_for_loads.at_put(i, new_castpp->in(0)); // Use the ctrl of the new node just as a flag
|
||||
|
||||
@ -7750,11 +7750,11 @@ bool LibraryCallKit::inline_intpoly_montgomeryMult_P256() {
|
||||
r = must_be_not_null(r, true);
|
||||
|
||||
Node* a_start = array_element_address(a, intcon(0), T_LONG);
|
||||
assert(a_start, "a array is NULL");
|
||||
assert(a_start, "a array is null");
|
||||
Node* b_start = array_element_address(b, intcon(0), T_LONG);
|
||||
assert(b_start, "b array is NULL");
|
||||
assert(b_start, "b array is null");
|
||||
Node* r_start = array_element_address(r, intcon(0), T_LONG);
|
||||
assert(r_start, "r array is NULL");
|
||||
assert(r_start, "r array is null");
|
||||
|
||||
Node* call = make_runtime_call(RC_LEAF | RC_NO_FP,
|
||||
OptoRuntime::intpoly_montgomeryMult_P256_Type(),
|
||||
@ -7779,9 +7779,9 @@ bool LibraryCallKit::inline_intpoly_assign() {
|
||||
b = must_be_not_null(b, true);
|
||||
|
||||
Node* a_start = array_element_address(a, intcon(0), T_LONG);
|
||||
assert(a_start, "a array is NULL");
|
||||
assert(a_start, "a array is null");
|
||||
Node* b_start = array_element_address(b, intcon(0), T_LONG);
|
||||
assert(b_start, "b array is NULL");
|
||||
assert(b_start, "b array is null");
|
||||
|
||||
Node* call = make_runtime_call(RC_LEAF | RC_NO_FP,
|
||||
OptoRuntime::intpoly_assign_Type(),
|
||||
|
||||
@ -424,7 +424,7 @@ bool DCmd::reorder_help_cmd(CmdLine line, stringStream &updated_line) {
|
||||
args.print("%s", line.args_addr());
|
||||
char* rest = args.as_string();
|
||||
char* token = strtok_r(rest, " ", &rest);
|
||||
while (token != NULL) {
|
||||
while (token != nullptr) {
|
||||
if (strcmp(token, "-h") == 0 || strcmp(token, "--help") == 0 ||
|
||||
strcmp(token, "-help") == 0) {
|
||||
updated_line.print("%s", "help ");
|
||||
|
||||
@ -39,9 +39,9 @@ static std::atomic<jmethodID> ring_buffer[BUFFER_SIZE];
|
||||
|
||||
void get_method_details(jmethodID method) {
|
||||
jclass method_class;
|
||||
char *class_name = NULL;
|
||||
char *class_name = nullptr;
|
||||
if (_jvmti->GetMethodDeclaringClass(method, &method_class) == JVMTI_ERROR_NONE) {
|
||||
if (_jvmti->GetClassSignature(method_class, &class_name, NULL) == JVMTI_ERROR_NONE) {
|
||||
if (_jvmti->GetClassSignature(method_class, &class_name, nullptr) == JVMTI_ERROR_NONE) {
|
||||
_jvmti->Deallocate((unsigned char *)class_name);
|
||||
}
|
||||
}
|
||||
@ -49,14 +49,14 @@ void get_method_details(jmethodID method) {
|
||||
|
||||
void* read_ringbuffer(void* arg) {
|
||||
JNIEnv *env;
|
||||
_jvm->AttachCurrentThreadAsDaemon((void **)&env, NULL);
|
||||
_jvm->AttachCurrentThreadAsDaemon((void **)&env, nullptr);
|
||||
for (;;) {
|
||||
jmethodID id = ring_buffer[rand() % BUFFER_SIZE].load(std::memory_order_relaxed);
|
||||
if (id != (jmethodID)0) {
|
||||
get_method_details(id);
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static void JNICALL ClassPrepareCallback(jvmtiEnv *jvmti_env,
|
||||
@ -66,8 +66,8 @@ static void JNICALL ClassPrepareCallback(jvmtiEnv *jvmti_env,
|
||||
static bool reader_created = false;
|
||||
static int ring_buffer_idx = 0;
|
||||
|
||||
char *class_name = NULL;
|
||||
if (jvmti_env->GetClassSignature(klass, &class_name, NULL) != JVMTI_ERROR_NONE) {
|
||||
char *class_name = nullptr;
|
||||
if (jvmti_env->GetClassSignature(klass, &class_name, nullptr) != JVMTI_ERROR_NONE) {
|
||||
return;
|
||||
}
|
||||
// We only care MyClass and only one thread loads it
|
||||
@ -79,7 +79,7 @@ static void JNICALL ClassPrepareCallback(jvmtiEnv *jvmti_env,
|
||||
|
||||
if (!reader_created) {
|
||||
pthread_t tid;
|
||||
pthread_create(&tid, NULL, read_ringbuffer, NULL);
|
||||
pthread_create(&tid, nullptr, read_ringbuffer, nullptr);
|
||||
reader_created = true;
|
||||
}
|
||||
|
||||
@ -119,7 +119,7 @@ JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM *jvm, char *options, void *reserved)
|
||||
}
|
||||
|
||||
// Enable the ClassPrepare event
|
||||
error = _jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_PREPARE, NULL);
|
||||
error = _jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_PREPARE, nullptr);
|
||||
if (error != JVMTI_ERROR_NONE) {
|
||||
fprintf(stderr, "Error enabling ClassPrepare event: %d\n", error);
|
||||
return JNI_ERR;
|
||||
|
||||
@ -118,13 +118,13 @@ Agent_OnAttach(JavaVM *vm, char *options, void *reserved) {
|
||||
}
|
||||
|
||||
clazz = env->FindClass("VThreadEventTest");
|
||||
if (clazz == NULL) {
|
||||
if (clazz == nullptr) {
|
||||
LOG("FindClass failed\n");
|
||||
return JNI_ERR;
|
||||
}
|
||||
|
||||
mid = env->GetStaticMethodID(clazz, "agentStarted", "()V");
|
||||
if (mid == NULL) {
|
||||
if (mid == nullptr) {
|
||||
LOG("GetStaticMethodID failed\n");
|
||||
return JNI_ERR;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user