RFR: 8324678: Replace NULL with nullptr in HotSpot gtests
Kim Barrett
kbarrett at openjdk.org
Fri Jan 26 20:48:35 UTC 2024
On Thu, 25 Jan 2024 21:35:29 GMT, Coleen Phillimore <coleenp at openjdk.org> wrote:
> If this is sufficient, here's the change for NULL to nullptr, adjusting some obvious strings that had NULL in them maybe not all.
> Tested with gtest,
Mostly good. A few nullptr -> null, and a couple other nits.
test/hotspot/gtest/gc/shared/test_collectedHeap.cpp line 36:
> 34:
> 35: // Test that nullptr is not in the heap.
> 36: ASSERT_FALSE(heap->is_in(nullptr)) << "nullptr is unexpectedly in the heap";
s/"nullptr is/"null is/
test/hotspot/gtest/gc/shared/test_oopStorage_parperf.cpp line 155:
> 153: class OopStorageParIterPerf::Closure : public OopClosure {
> 154: public:
> 155: virtual void do_oop(oop* p) { guarantee(*p == nullptr, "expected nullptr"); }
s/expected nullptr/expected null/
test/hotspot/gtest/memory/test_guardedMemory.cpp line 33:
> 31:
> 32: static void guarded_memory_test_check(void* p, size_t sz, void* tag) {
> 33: ASSERT_TRUE(p != nullptr) << "nullptr pointer given to check";
s/nullptr pointer/null pointer/
test/hotspot/gtest/nmt/test_nmtpreinit.cpp line 87:
> 85: p2 = os_realloc(os_malloc(10), 20); // realloc, growing
> 86: p3 = os_realloc(os_malloc(20), 10); // realloc, shrinking
> 87: p4 = os_realloc(nullptr, 10); // realloc with nullptr pointer
s/nullptr pointer/null pointer/
test/hotspot/gtest/runtime/test_ThreadsListHandle.cpp line 216:
> 214: // Test case: after first nested ThreadsListHandle (tlh2) has been destroyed
> 215:
> 216: // Verify the current thread's hazard ptr is nullptr:
s/nullptr/null/
test/hotspot/gtest/runtime/test_ThreadsListHandle.cpp line 400:
> 398: // Test case: after double nested ThreadsListHandle (tlh3) has been destroyed
> 399:
> 400: // Verify the current thread's hazard ptr is nullptr:
s/nullptr/null/
test/hotspot/gtest/runtime/test_ThreadsListHandle.cpp line 448:
> 446: // Test case: after first nested ThreadsListHandle (tlh2) has been destroyed
> 447:
> 448: // Verify the current thread's hazard ptr is nullptr:
s/nullptr/null/
test/hotspot/gtest/runtime/test_ThreadsListHandle.cpp line 568:
> 566: // Test case: after first back-to-back nested ThreadsListHandle (tlh2a) has been destroyed
> 567:
> 568: // Verify the current thread's hazard ptr is nullptr:
s/nullptr/null/
test/hotspot/gtest/runtime/test_ThreadsListHandle.cpp line 646:
> 644: // Test case: after second back-to-back nested ThreadsListHandle (tlh2b) has been destroyed
> 645:
> 646: // Verify the current thread's hazard ptr is nullptr:
s/nullptr/null/
test/hotspot/gtest/runtime/test_classLoader.cpp line 34:
> 32: bool bad_class_name = false;
> 33: TempNewSymbol retval = ClassLoader::package_from_class_name(nullptr, &bad_class_name);
> 34: ASSERT_TRUE(bad_class_name) << "Function did not set bad_class_name with nullptr class name";
s/nullptr/null/
test/hotspot/gtest/runtime/test_classLoader.cpp line 35:
> 33: TempNewSymbol retval = ClassLoader::package_from_class_name(nullptr, &bad_class_name);
> 34: ASSERT_TRUE(bad_class_name) << "Function did not set bad_class_name with nullptr class name";
> 35: ASSERT_TRUE(retval == nullptr) << "Wrong package for nullptr class name pointer";
second s/nullptr/null/
test/hotspot/gtest/runtime/test_os_linux.cpp line 203:
> 201: HugeTlbfsMemory mr(p, size);
> 202: // as the area around req_addr contains already existing mappings, the API should always
> 203: // return nullptr (as per contract, it cannot return another address)
s/nullptr/null/
test/hotspot/gtest/runtime/test_os_linux_cgroups.cpp line 66:
> 64: TestCase at_mount_root = {
> 65: "/sys/fs/cgroup", // mount_path
> 66: nullptr, // root_path, ignored
comment mis-indented
test/hotspot/gtest/runtime/test_os_linux_cgroups.cpp line 72:
> 70: TestCase sub_path = {
> 71: "/sys/fs/cgroup", // mount_path
> 72: nullptr, // root_path, ignored
comment mis-indented
test/hotspot/gtest/testutils.hpp line 57:
> 55: // Mimicking the official ASSERT_xx and EXPECT_xx counterparts of the googletest suite.
> 56: // (ASSERT|EXPECT)_NOT_NULL: check that the given pointer is not nullptr
> 57: // (ASSERT|EXPECT)_NULL: check that the given pointer is nullptr
both s/nullptr/null/
-------------
Changes requested by kbarrett (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/17577#pullrequestreview-1846506243
PR Review Comment: https://git.openjdk.org/jdk/pull/17577#discussion_r1468120668
PR Review Comment: https://git.openjdk.org/jdk/pull/17577#discussion_r1468120079
PR Review Comment: https://git.openjdk.org/jdk/pull/17577#discussion_r1468122196
PR Review Comment: https://git.openjdk.org/jdk/pull/17577#discussion_r1468123394
PR Review Comment: https://git.openjdk.org/jdk/pull/17577#discussion_r1468124477
PR Review Comment: https://git.openjdk.org/jdk/pull/17577#discussion_r1468124724
PR Review Comment: https://git.openjdk.org/jdk/pull/17577#discussion_r1468124981
PR Review Comment: https://git.openjdk.org/jdk/pull/17577#discussion_r1468125145
PR Review Comment: https://git.openjdk.org/jdk/pull/17577#discussion_r1468125309
PR Review Comment: https://git.openjdk.org/jdk/pull/17577#discussion_r1468125813
PR Review Comment: https://git.openjdk.org/jdk/pull/17577#discussion_r1468125982
PR Review Comment: https://git.openjdk.org/jdk/pull/17577#discussion_r1468126719
PR Review Comment: https://git.openjdk.org/jdk/pull/17577#discussion_r1468127182
PR Review Comment: https://git.openjdk.org/jdk/pull/17577#discussion_r1468127265
PR Review Comment: https://git.openjdk.org/jdk/pull/17577#discussion_r1468128708
More information about the hotspot-dev
mailing list