Skip to content

Commit ee839b7

Browse files
author
Kim Barrett
committed
8337239: Fix simple -Wzero-as-null-pointer-constant warnings in classfile code
Reviewed-by: dholmes
1 parent 0584af2 commit ee839b7

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

src/hotspot/share/classfile/classFileParser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2296,7 +2296,7 @@ Method* ClassFileParser::parse_method(const ClassFileStream* const cfs,
22962296
u2 max_stack = 0;
22972297
u2 max_locals = 0;
22982298
u4 code_length = 0;
2299-
const u1* code_start = 0;
2299+
const u1* code_start = nullptr;
23002300
u2 exception_table_length = 0;
23012301
const unsafe_u2* exception_table_start = nullptr; // (potentially unaligned) pointer to array of u2 elements
23022302
Array<int>* exception_handlers = Universe::the_empty_int_array();

src/hotspot/share/classfile/defaultMethods.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,7 @@ static Method* new_method(
870870
Symbol* sig, AccessFlags flags, int max_stack, int params,
871871
ConstMethod::MethodType mt, TRAPS) {
872872

873-
address code_start = 0;
873+
address code_start = nullptr;
874874
int code_length = 0;
875875
InlineTableSizes sizes;
876876

src/hotspot/share/classfile/javaAssertions.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -38,25 +38,25 @@
3838

3939
bool JavaAssertions::_userDefault = false;
4040
bool JavaAssertions::_sysDefault = false;
41-
JavaAssertions::OptionList* JavaAssertions::_classes = 0;
42-
JavaAssertions::OptionList* JavaAssertions::_packages = 0;
41+
JavaAssertions::OptionList* JavaAssertions::_classes = nullptr;
42+
JavaAssertions::OptionList* JavaAssertions::_packages = nullptr;
4343

4444
JavaAssertions::OptionList::OptionList(const char* name, bool enabled,
4545
OptionList* next) {
46-
assert(name != 0, "need a name");
46+
assert(name != nullptr, "need a name");
4747
_name = name;
4848
_enabled = enabled;
4949
_next = next;
5050
}
5151

5252
int JavaAssertions::OptionList::count(OptionList* p) {
5353
int rc;
54-
for (rc = 0; p != 0; p = p->next(), ++rc) /* empty */;
54+
for (rc = 0; p != nullptr; p = p->next(), ++rc) /* empty */;
5555
return rc;
5656
}
5757

5858
void JavaAssertions::addOption(const char* name, bool enable) {
59-
assert(name != 0, "must have a name");
59+
assert(name != nullptr, "must have a name");
6060

6161
// Copy the name. The storage needs to exist for the lifetime of the vm;
6262
// it is never freed, so will be leaked (along with other option strings -
@@ -135,7 +135,7 @@ void JavaAssertions::fillJavaArrays(const OptionList* p, int len,
135135
// matches the order on the command line (the list is in reverse order, since
136136
// it was created by prepending successive items from the command line).
137137
int index;
138-
for (index = len - 1; p != 0; p = p->next(), --index) {
138+
for (index = len - 1; p != nullptr; p = p->next(), --index) {
139139
assert(index >= 0, "length does not match list");
140140
TempNewSymbol name = SymbolTable::new_symbol(p->name());
141141
Handle s = java_lang_String::externalize_classname(name, CHECK);
@@ -147,20 +147,20 @@ void JavaAssertions::fillJavaArrays(const OptionList* p, int len,
147147

148148
inline JavaAssertions::OptionList*
149149
JavaAssertions::match_class(const char* classname) {
150-
for (OptionList* p = _classes; p != 0; p = p->next()) {
150+
for (OptionList* p = _classes; p != nullptr; p = p->next()) {
151151
if (strcmp(p->name(), classname) == 0) {
152152
return p;
153153
}
154154
}
155-
return 0;
155+
return nullptr;
156156
}
157157

158158
JavaAssertions::OptionList*
159159
JavaAssertions::match_package(const char* classname) {
160160
// Search the package list for any items that apply to classname. Each
161161
// sub-package in classname is checked, from most-specific to least, until one
162162
// is found.
163-
if (_packages == 0) return 0;
163+
if (_packages == nullptr) return nullptr;
164164

165165
// Find the length of the "most-specific" package in classname. If classname
166166
// does not include a package, length will be 0 which will match items for the
@@ -170,7 +170,7 @@ JavaAssertions::match_package(const char* classname) {
170170

171171
do {
172172
assert(len == 0 || classname[len] == JVM_SIGNATURE_SLASH, "not a package name");
173-
for (OptionList* p = _packages; p != 0; p = p->next()) {
173+
for (OptionList* p = _packages; p != nullptr; p = p->next()) {
174174
if (strncmp(p->name(), classname, len) == 0 && p->name()[len] == '\0') {
175175
return p;
176176
}
@@ -181,7 +181,7 @@ JavaAssertions::match_package(const char* classname) {
181181
while (len > 0 && classname[--len] != JVM_SIGNATURE_SLASH) /* empty */;
182182
} while (len > 0);
183183

184-
return 0;
184+
return nullptr;
185185
}
186186

187187
inline void JavaAssertions::trace(const char* name,
@@ -193,7 +193,7 @@ const char* typefound, const char* namefound, bool enabled) {
193193
}
194194

195195
bool JavaAssertions::enabled(const char* classname, bool systemClass) {
196-
assert(classname != 0, "must have a classname");
196+
assert(classname != nullptr, "must have a classname");
197197

198198
// This will be slow if the number of assertion options on the command line is
199199
// large--it traverses two lists, one of them multiple times. Could use a

src/hotspot/share/classfile/symbolTable.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ class SymbolTableConfig : public AllStatic {
193193
// We cannot use arena because arena chunks are allocated by the OS. As a result, for example,
194194
// the archived symbol of "java/lang/Object" may sometimes be lower than "java/lang/String", and
195195
// sometimes be higher. This would cause non-deterministic contents in the archive.
196-
DEBUG_ONLY(static void* last = 0);
196+
DEBUG_ONLY(static void* last = nullptr);
197197
void* p = (void*)MetaspaceShared::symbol_space_alloc(alloc_size);
198198
assert(p > last, "must increase monotonically");
199199
DEBUG_ONLY(last = p);

0 commit comments

Comments
 (0)