Skip to content

Commit 182d1b2

Browse files
committed
8301507: Replace NULL with nullptr in os_cpu/linux_riscv
Reviewed-by: kbarrett
1 parent 5d1f71d commit 182d1b2

File tree

3 files changed

+31
-31
lines changed

3 files changed

+31
-31
lines changed

src/hotspot/os_cpu/linux_riscv/javaThread_linux_riscv.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
33
* Copyright (c) 2020, 2021, Huawei Technologies Co., Ltd. All rights reserved.
44
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
*
@@ -59,18 +59,18 @@ bool JavaThread::pd_get_top_frame(frame* fr_addr, void* ucontext, bool isInJava)
5959
if (isInJava) {
6060
ucontext_t* uc = (ucontext_t*) ucontext;
6161

62-
intptr_t* ret_fp = NULL;
63-
intptr_t* ret_sp = NULL;
62+
intptr_t* ret_fp = nullptr;
63+
intptr_t* ret_sp = nullptr;
6464
address addr = os::fetch_frame_from_context(uc, &ret_sp, &ret_fp);
65-
if (addr == NULL || ret_sp == NULL ) {
65+
if (addr == nullptr || ret_sp == nullptr ) {
6666
// ucontext wasn't useful
6767
return false;
6868
}
6969

7070
frame ret_frame(ret_sp, ret_fp, addr);
7171
if (!ret_frame.safe_for_sender(this)) {
7272
#ifdef COMPILER2
73-
frame ret_frame2(ret_sp, NULL, addr);
73+
frame ret_frame2(ret_sp, nullptr, addr);
7474
if (!ret_frame2.safe_for_sender(this)) {
7575
// nothing else to try if the frame isn't good
7676
return false;

src/hotspot/os_cpu/linux_riscv/os_linux_riscv.cpp

+23-23
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1999, 2023, Oracle and/or its affiliates. All rights reserved.
33
* Copyright (c) 2020, 2022, Huawei Technologies Co., Ltd. All rights reserved.
44
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
*
@@ -108,21 +108,21 @@ address os::fetch_frame_from_context(const void* ucVoid,
108108
address epc;
109109
const ucontext_t* uc = (const ucontext_t*)ucVoid;
110110

111-
if (uc != NULL) {
111+
if (uc != nullptr) {
112112
epc = os::Posix::ucontext_get_pc(uc);
113-
if (ret_sp != NULL) {
113+
if (ret_sp != nullptr) {
114114
*ret_sp = os::Linux::ucontext_get_sp(uc);
115115
}
116-
if (ret_fp != NULL) {
116+
if (ret_fp != nullptr) {
117117
*ret_fp = os::Linux::ucontext_get_fp(uc);
118118
}
119119
} else {
120-
epc = NULL;
121-
if (ret_sp != NULL) {
122-
*ret_sp = (intptr_t *)NULL;
120+
epc = nullptr;
121+
if (ret_sp != nullptr) {
122+
*ret_sp = (intptr_t *)nullptr;
123123
}
124-
if (ret_fp != NULL) {
125-
*ret_fp = (intptr_t *)NULL;
124+
if (ret_fp != nullptr) {
125+
*ret_fp = (intptr_t *)nullptr;
126126
}
127127
}
128128

@@ -142,8 +142,8 @@ frame os::fetch_compiled_frame_from_context(const void* ucVoid) {
142142
}
143143

144144
frame os::fetch_frame_from_context(const void* ucVoid) {
145-
intptr_t* frame_sp = NULL;
146-
intptr_t* frame_fp = NULL;
145+
intptr_t* frame_sp = nullptr;
146+
intptr_t* frame_fp = nullptr;
147147
address epc = fetch_frame_from_context(ucVoid, &frame_sp, &frame_fp);
148148
if (!is_readable_pointer(epc)) {
149149
// Try to recover from calling into bad memory
@@ -162,7 +162,7 @@ frame os::get_sender_for_C_frame(frame* fr) {
162162

163163
NOINLINE frame os::current_frame() {
164164
intptr_t **sender_sp = (intptr_t **)__builtin_frame_address(0);
165-
if (sender_sp != NULL) {
165+
if (sender_sp != nullptr) {
166166
frame myframe((intptr_t*)os::current_stack_pointer(),
167167
sender_sp[frame::link_offset],
168168
CAST_FROM_FN_PTR(address, os::current_frame));
@@ -183,12 +183,12 @@ bool PosixSignals::pd_hotspot_signal_handler(int sig, siginfo_t* info,
183183
ucontext_t* uc, JavaThread* thread) {
184184

185185
// decide if this trap can be handled by a stub
186-
address stub = NULL;
186+
address stub = nullptr;
187187

188-
address pc = NULL;
188+
address pc = nullptr;
189189

190190
//%note os_trap_1
191-
if (info != NULL && uc != NULL && thread != NULL) {
191+
if (info != nullptr && uc != nullptr && thread != nullptr) {
192192
pc = (address) os::Posix::ucontext_get_pc(uc);
193193

194194
address addr = (address) info->si_addr;
@@ -226,9 +226,9 @@ bool PosixSignals::pd_hotspot_signal_handler(int sig, siginfo_t* info,
226226
// here if the underlying file has been truncated.
227227
// Do not crash the VM in such a case.
228228
CodeBlob* cb = CodeCache::find_blob(pc);
229-
CompiledMethod* nm = (cb != NULL) ? cb->as_compiled_method_or_null() : NULL;
229+
CompiledMethod* nm = (cb != nullptr) ? cb->as_compiled_method_or_null() : nullptr;
230230
bool is_unsafe_arraycopy = (thread->doing_unsafe_access() && UnsafeCopyMemory::contains_pc(pc));
231-
if ((nm != NULL && nm->has_unsafe_access()) || is_unsafe_arraycopy) {
231+
if ((nm != nullptr && nm->has_unsafe_access()) || is_unsafe_arraycopy) {
232232
address next_pc = pc + NativeCall::instruction_size;
233233
if (is_unsafe_arraycopy) {
234234
next_pc = UnsafeCopyMemory::page_error_continue_pc(pc);
@@ -249,7 +249,7 @@ bool PosixSignals::pd_hotspot_signal_handler(int sig, siginfo_t* info,
249249
// End life with a fatal error, message and detail message and the context.
250250
// Note: no need to do any post-processing here (e.g. signal chaining)
251251
va_list va_dummy;
252-
VMError::report_and_die(thread, uc, NULL, 0, msg, detail_msg, va_dummy);
252+
VMError::report_and_die(thread, uc, nullptr, 0, msg, detail_msg, va_dummy);
253253
va_end(va_dummy);
254254

255255
ShouldNotReachHere();
@@ -287,9 +287,9 @@ bool PosixSignals::pd_hotspot_signal_handler(int sig, siginfo_t* info,
287287
}
288288
}
289289

290-
if (stub != NULL) {
290+
if (stub != nullptr) {
291291
// save all thread context in case we need to restore it
292-
if (thread != NULL) {
292+
if (thread != nullptr) {
293293
thread->set_saved_exception_pc(pc);
294294
}
295295

@@ -340,7 +340,7 @@ static const char* reg_abi_names[] = {
340340
};
341341

342342
void os::print_context(outputStream *st, const void *context) {
343-
if (context == NULL) return;
343+
if (context == nullptr) return;
344344

345345
const ucontext_t *uc = (const ucontext_t*)context;
346346

@@ -352,7 +352,7 @@ void os::print_context(outputStream *st, const void *context) {
352352
}
353353

354354
void os::print_tos_pc(outputStream *st, const void *context) {
355-
if (context == NULL) return;
355+
if (context == nullptr) return;
356356

357357
const ucontext_t* uc = (const ucontext_t*)context;
358358

@@ -369,7 +369,7 @@ void os::print_tos_pc(outputStream *st, const void *context) {
369369
}
370370

371371
void os::print_register_info(outputStream *st, const void *context) {
372-
if (context == NULL) return;
372+
if (context == nullptr) return;
373373

374374
const ucontext_t *uc = (const ucontext_t*)context;
375375

src/hotspot/os_cpu/linux_riscv/vm_version_linux_riscv.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2006, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2006, 2023, Oracle and/or its affiliates. All rights reserved.
33
* Copyright (c) 2021, Huawei Technologies Co., Ltd. All rights reserved.
44
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
*
@@ -115,8 +115,8 @@ void VM_Version::get_os_cpu_info() {
115115

116116
if (FILE *f = fopen("/proc/cpuinfo", "r")) {
117117
char buf[512], *p;
118-
while (fgets(buf, sizeof (buf), f) != NULL) {
119-
if ((p = strchr(buf, ':')) != NULL) {
118+
while (fgets(buf, sizeof (buf), f) != nullptr) {
119+
if ((p = strchr(buf, ':')) != nullptr) {
120120
if (strncmp(buf, "mmu", sizeof "mmu" - 1) == 0) {
121121
if (_vm_mode[0] != '\0') {
122122
continue;

0 commit comments

Comments
 (0)