Skip to content

Commit bc7c255

Browse files
author
Kim Barrett
committed
8337416: Fix -Wzero-as-null-pointer-constant warnings in misc. runtime code
Reviewed-by: dholmes, jwaters
1 parent 7e21d4c commit bc7c255

File tree

10 files changed

+17
-17
lines changed

10 files changed

+17
-17
lines changed

src/hotspot/share/logging/logConfiguration.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ bool LogConfiguration::parse_command_line_arguments(const char* opts) {
370370

371371
// Split the option string to its colon separated components.
372372
char* str = copy;
373-
char* substrings[4] = {0};
373+
char* substrings[4] = {};
374374
for (int i = 0 ; i < 4; i++) {
375375
substrings[i] = str;
376376

src/hotspot/share/memory/metaspace/metachunk.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ void Metachunk::verify_neighborhood() const {
253253
}
254254
}
255255

256-
volatile MetaWord dummy = 0;
256+
volatile MetaWord dummy = nullptr;
257257

258258
void Metachunk::verify() const {
259259
// Note. This should be called under CLD lock protection.

src/hotspot/share/memory/metaspace/rootChunkArea.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved.
33
* Copyright (c) 2020, 2022 SAP SE. All rights reserved.
44
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
*
@@ -59,7 +59,7 @@ RootChunkArea::~RootChunkArea() {
5959
// root chunk header. It will be partly initialized.
6060
// Note: this just allocates a memory-less header; memory itself is allocated inside VirtualSpaceNode.
6161
Metachunk* RootChunkArea::alloc_root_chunk_header(VirtualSpaceNode* node) {
62-
assert(_first_chunk == 0, "already have a root");
62+
assert(_first_chunk == nullptr, "already have a root");
6363
Metachunk* c = ChunkHeaderPool::pool()->allocate_chunk_header();
6464
c->initialize(node, const_cast<MetaWord*>(_base), chunklevel::ROOT_CHUNK_LEVEL);
6565
_first_chunk = c;

src/hotspot/share/memory/virtualspace.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ static char* reserve_memory(char* requested_address, const size_t size,
159159
// If the memory was requested at a particular address, use
160160
// os::attempt_reserve_memory_at() to avoid mapping over something
161161
// important. If the reservation fails, return null.
162-
if (requested_address != 0) {
162+
if (requested_address != nullptr) {
163163
assert(is_aligned(requested_address, alignment),
164164
"Requested address " PTR_FORMAT " must be aligned to " SIZE_FORMAT,
165165
p2i(requested_address), alignment);

src/hotspot/share/oops/constantPool.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2065,7 +2065,7 @@ static void print_cpool_bytes(jint cnt, u1 *bytes) {
20652065
size += ent_size;
20662066
}
20672067
printf("Cpool size: %d\n", size);
2068-
fflush(0);
2068+
fflush(nullptr);
20692069
return;
20702070
} /* end print_cpool_bytes */
20712071

src/hotspot/share/oops/instanceKlass.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2779,9 +2779,9 @@ void InstanceKlass::release_C_heap_structures(bool release_sub_metadata) {
27792779

27802780
#if INCLUDE_JVMTI
27812781
// Deallocate breakpoint records
2782-
if (breakpoints() != 0x0) {
2782+
if (breakpoints() != nullptr) {
27832783
methods_do(clear_all_breakpoints);
2784-
assert(breakpoints() == 0x0, "should have cleared breakpoints");
2784+
assert(breakpoints() == nullptr, "should have cleared breakpoints");
27852785
}
27862786

27872787
// deallocate the cached class file

src/hotspot/share/oops/method.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ void Method::mask_for(const methodHandle& this_mh, int bci, InterpreterOopMap* m
322322
}
323323

324324
int Method::bci_from(address bcp) const {
325-
if (is_native() && bcp == 0) {
325+
if (is_native() && bcp == nullptr) {
326326
return 0;
327327
}
328328
// Do not have a ResourceMark here because AsyncGetCallTrace stack walking code
@@ -345,7 +345,7 @@ int Method::validate_bci(int bci) const {
345345
int Method::validate_bci_from_bcp(address bcp) const {
346346
// keep bci as -1 if not a valid bci
347347
int bci = -1;
348-
if (bcp == 0 || bcp == code_base()) {
348+
if (bcp == nullptr || bcp == code_base()) {
349349
// code_size() may return 0 and we allow 0 here
350350
// the method may be native
351351
bci = 0;

src/hotspot/share/runtime/arguments.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ size_t Arguments::_default_SharedBaseAddress = SharedBaseAddress;
102102

103103
bool Arguments::_enable_preview = false;
104104

105-
LegacyGCLogging Arguments::_legacyGCLogging = { 0, 0 };
105+
LegacyGCLogging Arguments::_legacyGCLogging = { nullptr, 0 };
106106

107107
// These are not set by the JDK's built-in launchers, but they can be set by
108108
// programs that embed the JVM using JNI_CreateJavaVM. See comments around
@@ -1850,11 +1850,11 @@ bool Arguments::is_bad_option(const JavaVMOption* option, jboolean ignore,
18501850
}
18511851

18521852
static const char* user_assertion_options[] = {
1853-
"-da", "-ea", "-disableassertions", "-enableassertions", 0
1853+
"-da", "-ea", "-disableassertions", "-enableassertions", nullptr
18541854
};
18551855

18561856
static const char* system_assertion_options[] = {
1857-
"-dsa", "-esa", "-disablesystemassertions", "-enablesystemassertions", 0
1857+
"-dsa", "-esa", "-disablesystemassertions", "-enablesystemassertions", nullptr
18581858
};
18591859

18601860
bool Arguments::parse_uint(const char* value,

src/hotspot/share/runtime/javaThread.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -470,8 +470,8 @@ JavaThread::JavaThread(MEMFLAGS flags) :
470470
#endif // INCLUDE_JVMCI
471471

472472
_exception_oop(oop()),
473-
_exception_pc(0),
474-
_exception_handler_pc(0),
473+
_exception_pc(nullptr),
474+
_exception_handler_pc(nullptr),
475475
_is_method_handle_return(0),
476476

477477
_jni_active_critical(0),
@@ -483,7 +483,7 @@ JavaThread::JavaThread(MEMFLAGS flags) :
483483
_frames_to_pop_failed_realloc(0),
484484

485485
_cont_entry(nullptr),
486-
_cont_fastpath(0),
486+
_cont_fastpath(nullptr),
487487
_cont_fastpath_thread_state(1),
488488
_held_monitor_count(0),
489489
_jni_monitor_count(0),

src/hotspot/share/runtime/vframeArray.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ void vframeArrayElement::unpack_on_stack(int caller_actual_parameters,
321321
"should be held, after move_to");
322322
}
323323
if (ProfileInterpreter) {
324-
iframe()->interpreter_frame_set_mdp(0); // clear out the mdp.
324+
iframe()->interpreter_frame_set_mdp(nullptr); // clear out the mdp.
325325
}
326326
iframe()->interpreter_frame_set_bcp(bcp);
327327
if (ProfileInterpreter) {

0 commit comments

Comments
 (0)