Skip to content

Commit 8350b1d

Browse files
author
Kim Barrett
committed
8335294: Fix simple -Wzero-as-null-pointer-constant warnings in gc code
Reviewed-by: tschatzl, coleenp, jwaters
1 parent 5d866bf commit 8350b1d

File tree

10 files changed

+30
-31
lines changed

10 files changed

+30
-31
lines changed

src/hotspot/os/linux/gc/x/xPhysicalMemoryBacking_linux.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015, 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
@@ -389,7 +389,7 @@ XErrno XPhysicalMemoryBacking::fallocate_compat_mmap_hugetlbfs(size_t offset, si
389389
// On hugetlbfs, mapping a file segment will fail immediately, without
390390
// the need to touch the mapped pages first, if there aren't enough huge
391391
// pages available to back the mapping.
392-
void* const addr = mmap(0, length, PROT_READ|PROT_WRITE, MAP_SHARED, _fd, offset);
392+
void* const addr = mmap(nullptr, length, PROT_READ|PROT_WRITE, MAP_SHARED, _fd, offset);
393393
if (addr == MAP_FAILED) {
394394
// Failed
395395
return errno;
@@ -439,7 +439,7 @@ static bool safe_touch_mapping(void* addr, size_t length, size_t page_size) {
439439
XErrno XPhysicalMemoryBacking::fallocate_compat_mmap_tmpfs(size_t offset, size_t length) const {
440440
// On tmpfs, we need to touch the mapped pages to figure out
441441
// if there are enough pages available to back the mapping.
442-
void* const addr = mmap(0, length, PROT_READ|PROT_WRITE, MAP_SHARED, _fd, offset);
442+
void* const addr = mmap(nullptr, length, PROT_READ|PROT_WRITE, MAP_SHARED, _fd, offset);
443443
if (addr == MAP_FAILED) {
444444
// Failed
445445
return errno;

src/hotspot/os/linux/gc/z/zPhysicalMemoryBacking_linux.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015, 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
@@ -391,7 +391,7 @@ ZErrno ZPhysicalMemoryBacking::fallocate_compat_mmap_hugetlbfs(zoffset offset, s
391391
// On hugetlbfs, mapping a file segment will fail immediately, without
392392
// the need to touch the mapped pages first, if there aren't enough huge
393393
// pages available to back the mapping.
394-
void* const addr = mmap(0, length, PROT_READ|PROT_WRITE, MAP_SHARED, _fd, untype(offset));
394+
void* const addr = mmap(nullptr, length, PROT_READ|PROT_WRITE, MAP_SHARED, _fd, untype(offset));
395395
if (addr == MAP_FAILED) {
396396
// Failed
397397
return errno;
@@ -441,7 +441,7 @@ static bool safe_touch_mapping(void* addr, size_t length, size_t page_size) {
441441
ZErrno ZPhysicalMemoryBacking::fallocate_compat_mmap_tmpfs(zoffset offset, size_t length) const {
442442
// On tmpfs, we need to touch the mapped pages to figure out
443443
// if there are enough pages available to back the mapping.
444-
void* const addr = mmap(0, length, PROT_READ|PROT_WRITE, MAP_SHARED, _fd, untype(offset));
444+
void* const addr = mmap(nullptr, length, PROT_READ|PROT_WRITE, MAP_SHARED, _fd, untype(offset));
445445
if (addr == MAP_FAILED) {
446446
// Failed
447447
return errno;

src/hotspot/share/gc/parallel/parMarkBitMap.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2005, 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
@@ -62,7 +62,7 @@ ParMarkBitMap::initialize(MemRegion covered_region)
6262
return true;
6363
}
6464

65-
_heap_start = 0;
65+
_heap_start = nullptr;
6666
_heap_size = 0;
6767
if (_virtual_space != nullptr) {
6868
delete _virtual_space;

src/hotspot/share/gc/parallel/parallelScavengeHeap.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ HeapWord* ParallelScavengeHeap::block_start(const void* addr) const {
661661
"addr should be in allocated part of old gen");
662662
return old_gen()->start_array()->object_start((HeapWord*)addr);
663663
}
664-
return 0;
664+
return nullptr;
665665
}
666666

667667
bool ParallelScavengeHeap::block_is_obj(const HeapWord* addr) const {

src/hotspot/share/gc/parallel/psParallelCompact.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ ParallelCompactData::create_vspace(size_t count, size_t element_size)
237237
MemTracker::record_virtual_memory_type((address)rs.base(), mtGC);
238238

239239
PSVirtualSpace* vspace = new PSVirtualSpace(rs, page_sz);
240-
if (vspace != 0) {
240+
if (vspace != nullptr) {
241241
if (vspace->expand_by(_reserved_byte_size)) {
242242
return vspace;
243243
}
@@ -246,7 +246,7 @@ ParallelCompactData::create_vspace(size_t count, size_t element_size)
246246
rs.release();
247247
}
248248

249-
return 0;
249+
return nullptr;
250250
}
251251

252252
bool ParallelCompactData::initialize_region_data(size_t heap_size)
@@ -255,7 +255,7 @@ bool ParallelCompactData::initialize_region_data(size_t heap_size)
255255

256256
const size_t count = heap_size >> Log2RegionSize;
257257
_region_vspace = create_vspace(count, sizeof(RegionData));
258-
if (_region_vspace != 0) {
258+
if (_region_vspace != nullptr) {
259259
_region_data = (RegionData*)_region_vspace->reserved_low_addr();
260260
_region_count = count;
261261
return true;

src/hotspot/share/gc/z/zPage.inline.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015, 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
@@ -65,7 +65,6 @@ inline const char* ZPage::type_to_string() const {
6565

6666
default:
6767
fatal("Unexpected page type");
68-
return 0;
6968
}
7069
}
7170

test/hotspot/jtreg/vmTestbase/gc/gctests/nativeGC01/libnativeGC01.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2005, 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
@@ -43,7 +43,7 @@ Java_gc_gctests_nativeGC01_nativeGC01_nativeMethod01
4343
*/
4444
cls = env->GetObjectClass(obj);
4545
mid = env->GetMethodID(cls, "callbackGC", "()V");
46-
if (mid == 0) {
46+
if (mid == nullptr) {
4747
printf("couldnt locate method callbackGC()");
4848
return -1;
4949
}
@@ -56,7 +56,7 @@ Java_gc_gctests_nativeGC01_nativeGC01_nativeMethod01
5656

5757
clss = env->GetObjectClass(linked_list);
5858
mid2 = env->GetMethodID(clss, "getLength", "()I");
59-
if (mid2 == 0) {
59+
if (mid2 == nullptr) {
6060
printf("couldnt locate method getLength()");
6161
return -1;
6262
}

test/hotspot/jtreg/vmTestbase/gc/gctests/nativeGC02/libnativeGC02.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2005, 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
@@ -41,7 +41,7 @@ Java_gc_gctests_nativeGC02_nativeGC02_nativeMethod02
4141

4242
clss = env->GetObjectClass(obj);
4343
fid = env->GetFieldID(clss, "cl", "Lnsk/share/gc/CircularLinkedList;");
44-
if (fid == 0) {
44+
if (fid == nullptr) {
4545
printf("could not locate field - cl\n");
4646
return -1;
4747
}
@@ -53,7 +53,7 @@ Java_gc_gctests_nativeGC02_nativeGC02_nativeMethod02
5353

5454
cls = env->GetObjectClass(obj);
5555
mid = env->GetMethodID(cls, "callbackGC", "()V");
56-
if (mid == 0) {
56+
if (mid == nullptr) {
5757
printf("couldnt locate method callbackGC()\n");
5858
return -1;
5959
}
@@ -66,7 +66,7 @@ Java_gc_gctests_nativeGC02_nativeGC02_nativeMethod02
6666

6767
clss = env->GetObjectClass(linked_list);
6868
mid2 = env->GetMethodID(clss, "getLength", "(Lnsk/share/gc/CircularLinkedList;)I");
69-
if (mid2 == 0) {
69+
if (mid2 == nullptr) {
7070
printf("couldnt locate method getLength(CircularLinkedList)\n");
7171
return -1;
7272
}

test/hotspot/jtreg/vmTestbase/gc/gctests/nativeGC03/libnativeGC03.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Java_gc_gctests_nativeGC03_nativeGC03_nativeMethod03
4646

4747
clss = env->GetObjectClass(obj);
4848
mid = env->GetMethodID(clss, "fillArray", "()V");
49-
if (mid == 0) {
49+
if (mid == nullptr) {
5050
return;
5151
}
5252
env->CallVoidMethod(obj, mid);

test/hotspot/jtreg/vmTestbase/gc/gctests/nativeGC05/libnativeGC05.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2005, 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
@@ -28,8 +28,8 @@ extern "C" {
2828
JNIEXPORT void JNICALL
2929
Java_gc_gctests_nativeGC05_nativeGC05_kickOffRefillers
3030
(JNIEnv *env, jobject obj, jobject matrix, jobject stack) {
31-
jclass matrixClass, stackClass, pairClass = 0;
32-
jmethodID stack_pop_mid, stack_empty_mid, matrix_repopulate_mid, pair_geti_mid = 0, pair_getj_mid = 0;
31+
jclass matrixClass, stackClass, pairClass = nullptr;
32+
jmethodID stack_pop_mid, stack_empty_mid, matrix_repopulate_mid, pair_geti_mid = nullptr, pair_getj_mid = nullptr;
3333
jobject pair;
3434
jint i, j;
3535
jboolean b;
@@ -40,18 +40,18 @@ Java_gc_gctests_nativeGC05_nativeGC05_kickOffRefillers
4040

4141
/* GetMethodID's for the pop() and Repopulate() methods */
4242
stack_pop_mid = env->GetMethodID(stackClass, "pop", "()Ljava/lang/Object;");
43-
if (stack_pop_mid == 0) {
43+
if (stack_pop_mid == nullptr) {
4444
printf("could not get a methodID for Stack::pop()\n");
4545
return;
4646
}
4747
stack_empty_mid = env->GetMethodID(stackClass, "empty", "()Z");
48-
if (stack_empty_mid == 0) {
48+
if (stack_empty_mid == nullptr) {
4949
printf("could not get a methodID for Stack::empty()\n");
5050
return;
5151
}
5252

5353
matrix_repopulate_mid = env->GetMethodID(matrixClass, "repopulate", "(II)V");
54-
if (matrix_repopulate_mid == 0) {
54+
if (matrix_repopulate_mid == nullptr) {
5555
printf("could not get a methodID for Matrix::repopulate(int, int)\n");
5656
return;
5757
}
@@ -62,15 +62,15 @@ Java_gc_gctests_nativeGC05_nativeGC05_kickOffRefillers
6262
/** pair = stack.pop() */
6363
pair = env->CallObjectMethod(stack, stack_pop_mid);
6464

65-
if (pairClass == 0) {
65+
if (pairClass == nullptr) {
6666
pairClass = env->GetObjectClass(pair);
6767
pair_geti_mid = env->GetMethodID(pairClass, "getI", "()I");
68-
if (pair_geti_mid == 0) {
68+
if (pair_geti_mid == nullptr) {
6969
printf("could not get a methodID for IndexPair::getI()\n");
7070
return;
7171
}
7272
pair_getj_mid = env->GetMethodID(pairClass, "getJ", "()I");
73-
if (pair_getj_mid == 0) {
73+
if (pair_getj_mid == nullptr) {
7474
printf("could not get a methodID for IndexPair::getJ()\n");
7575
return;
7676
}

0 commit comments

Comments
 (0)