Skip to content

Commit

Permalink
8335294: Fix simple -Wzero-as-null-pointer-constant warnings in gc code
Browse files Browse the repository at this point in the history
Reviewed-by: tschatzl, coleenp, jwaters
  • Loading branch information
Kim Barrett committed Jun 29, 2024
1 parent 5d866bf commit 8350b1d
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 31 deletions.
6 changes: 3 additions & 3 deletions src/hotspot/os/linux/gc/x/xPhysicalMemoryBacking_linux.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 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
Expand Down Expand Up @@ -389,7 +389,7 @@ XErrno XPhysicalMemoryBacking::fallocate_compat_mmap_hugetlbfs(size_t offset, si
// On hugetlbfs, mapping a file segment will fail immediately, without
// the need to touch the mapped pages first, if there aren't enough huge
// pages available to back the mapping.
void* const addr = mmap(0, length, PROT_READ|PROT_WRITE, MAP_SHARED, _fd, offset);
void* const addr = mmap(nullptr, length, PROT_READ|PROT_WRITE, MAP_SHARED, _fd, offset);
if (addr == MAP_FAILED) {
// Failed
return errno;
Expand Down Expand Up @@ -439,7 +439,7 @@ static bool safe_touch_mapping(void* addr, size_t length, size_t page_size) {
XErrno XPhysicalMemoryBacking::fallocate_compat_mmap_tmpfs(size_t offset, size_t length) const {
// On tmpfs, we need to touch the mapped pages to figure out
// if there are enough pages available to back the mapping.
void* const addr = mmap(0, length, PROT_READ|PROT_WRITE, MAP_SHARED, _fd, offset);
void* const addr = mmap(nullptr, length, PROT_READ|PROT_WRITE, MAP_SHARED, _fd, offset);
if (addr == MAP_FAILED) {
// Failed
return errno;
Expand Down
6 changes: 3 additions & 3 deletions src/hotspot/os/linux/gc/z/zPhysicalMemoryBacking_linux.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 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
Expand Down Expand Up @@ -391,7 +391,7 @@ ZErrno ZPhysicalMemoryBacking::fallocate_compat_mmap_hugetlbfs(zoffset offset, s
// On hugetlbfs, mapping a file segment will fail immediately, without
// the need to touch the mapped pages first, if there aren't enough huge
// pages available to back the mapping.
void* const addr = mmap(0, length, PROT_READ|PROT_WRITE, MAP_SHARED, _fd, untype(offset));
void* const addr = mmap(nullptr, length, PROT_READ|PROT_WRITE, MAP_SHARED, _fd, untype(offset));
if (addr == MAP_FAILED) {
// Failed
return errno;
Expand Down Expand Up @@ -441,7 +441,7 @@ static bool safe_touch_mapping(void* addr, size_t length, size_t page_size) {
ZErrno ZPhysicalMemoryBacking::fallocate_compat_mmap_tmpfs(zoffset offset, size_t length) const {
// On tmpfs, we need to touch the mapped pages to figure out
// if there are enough pages available to back the mapping.
void* const addr = mmap(0, length, PROT_READ|PROT_WRITE, MAP_SHARED, _fd, untype(offset));
void* const addr = mmap(nullptr, length, PROT_READ|PROT_WRITE, MAP_SHARED, _fd, untype(offset));
if (addr == MAP_FAILED) {
// Failed
return errno;
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/gc/parallel/parMarkBitMap.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 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
Expand Down Expand Up @@ -62,7 +62,7 @@ ParMarkBitMap::initialize(MemRegion covered_region)
return true;
}

_heap_start = 0;
_heap_start = nullptr;
_heap_size = 0;
if (_virtual_space != nullptr) {
delete _virtual_space;
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/gc/parallel/parallelScavengeHeap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ HeapWord* ParallelScavengeHeap::block_start(const void* addr) const {
"addr should be in allocated part of old gen");
return old_gen()->start_array()->object_start((HeapWord*)addr);
}
return 0;
return nullptr;
}

bool ParallelScavengeHeap::block_is_obj(const HeapWord* addr) const {
Expand Down
6 changes: 3 additions & 3 deletions src/hotspot/share/gc/parallel/psParallelCompact.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ ParallelCompactData::create_vspace(size_t count, size_t element_size)
MemTracker::record_virtual_memory_type((address)rs.base(), mtGC);

PSVirtualSpace* vspace = new PSVirtualSpace(rs, page_sz);
if (vspace != 0) {
if (vspace != nullptr) {
if (vspace->expand_by(_reserved_byte_size)) {
return vspace;
}
Expand All @@ -246,7 +246,7 @@ ParallelCompactData::create_vspace(size_t count, size_t element_size)
rs.release();
}

return 0;
return nullptr;
}

bool ParallelCompactData::initialize_region_data(size_t heap_size)
Expand All @@ -255,7 +255,7 @@ bool ParallelCompactData::initialize_region_data(size_t heap_size)

const size_t count = heap_size >> Log2RegionSize;
_region_vspace = create_vspace(count, sizeof(RegionData));
if (_region_vspace != 0) {
if (_region_vspace != nullptr) {
_region_data = (RegionData*)_region_vspace->reserved_low_addr();
_region_count = count;
return true;
Expand Down
3 changes: 1 addition & 2 deletions src/hotspot/share/gc/z/zPage.inline.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 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
Expand Down Expand Up @@ -65,7 +65,6 @@ inline const char* ZPage::type_to_string() const {

default:
fatal("Unexpected page type");
return 0;
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 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
Expand Down Expand Up @@ -43,7 +43,7 @@ Java_gc_gctests_nativeGC01_nativeGC01_nativeMethod01
*/
cls = env->GetObjectClass(obj);
mid = env->GetMethodID(cls, "callbackGC", "()V");
if (mid == 0) {
if (mid == nullptr) {
printf("couldnt locate method callbackGC()");
return -1;
}
Expand All @@ -56,7 +56,7 @@ Java_gc_gctests_nativeGC01_nativeGC01_nativeMethod01

clss = env->GetObjectClass(linked_list);
mid2 = env->GetMethodID(clss, "getLength", "()I");
if (mid2 == 0) {
if (mid2 == nullptr) {
printf("couldnt locate method getLength()");
return -1;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 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
Expand Down Expand Up @@ -41,7 +41,7 @@ Java_gc_gctests_nativeGC02_nativeGC02_nativeMethod02

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

cls = env->GetObjectClass(obj);
mid = env->GetMethodID(cls, "callbackGC", "()V");
if (mid == 0) {
if (mid == nullptr) {
printf("couldnt locate method callbackGC()\n");
return -1;
}
Expand All @@ -66,7 +66,7 @@ Java_gc_gctests_nativeGC02_nativeGC02_nativeMethod02

clss = env->GetObjectClass(linked_list);
mid2 = env->GetMethodID(clss, "getLength", "(Lnsk/share/gc/CircularLinkedList;)I");
if (mid2 == 0) {
if (mid2 == nullptr) {
printf("couldnt locate method getLength(CircularLinkedList)\n");
return -1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Java_gc_gctests_nativeGC03_nativeGC03_nativeMethod03

clss = env->GetObjectClass(obj);
mid = env->GetMethodID(clss, "fillArray", "()V");
if (mid == 0) {
if (mid == nullptr) {
return;
}
env->CallVoidMethod(obj, mid);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 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
Expand Down Expand Up @@ -28,8 +28,8 @@ extern "C" {
JNIEXPORT void JNICALL
Java_gc_gctests_nativeGC05_nativeGC05_kickOffRefillers
(JNIEnv *env, jobject obj, jobject matrix, jobject stack) {
jclass matrixClass, stackClass, pairClass = 0;
jmethodID stack_pop_mid, stack_empty_mid, matrix_repopulate_mid, pair_geti_mid = 0, pair_getj_mid = 0;
jclass matrixClass, stackClass, pairClass = nullptr;
jmethodID stack_pop_mid, stack_empty_mid, matrix_repopulate_mid, pair_geti_mid = nullptr, pair_getj_mid = nullptr;
jobject pair;
jint i, j;
jboolean b;
Expand All @@ -40,18 +40,18 @@ Java_gc_gctests_nativeGC05_nativeGC05_kickOffRefillers

/* GetMethodID's for the pop() and Repopulate() methods */
stack_pop_mid = env->GetMethodID(stackClass, "pop", "()Ljava/lang/Object;");
if (stack_pop_mid == 0) {
if (stack_pop_mid == nullptr) {
printf("could not get a methodID for Stack::pop()\n");
return;
}
stack_empty_mid = env->GetMethodID(stackClass, "empty", "()Z");
if (stack_empty_mid == 0) {
if (stack_empty_mid == nullptr) {
printf("could not get a methodID for Stack::empty()\n");
return;
}

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

if (pairClass == 0) {
if (pairClass == nullptr) {
pairClass = env->GetObjectClass(pair);
pair_geti_mid = env->GetMethodID(pairClass, "getI", "()I");
if (pair_geti_mid == 0) {
if (pair_geti_mid == nullptr) {
printf("could not get a methodID for IndexPair::getI()\n");
return;
}
pair_getj_mid = env->GetMethodID(pairClass, "getJ", "()I");
if (pair_getj_mid == 0) {
if (pair_getj_mid == nullptr) {
printf("could not get a methodID for IndexPair::getJ()\n");
return;
}
Expand Down

1 comment on commit 8350b1d

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.