RFR: 8324678: Replace NULL with nullptr in HotSpot gtests [v2]
David Holmes
dholmes at openjdk.org
Mon Jan 29 05:18:37 UTC 2024
On Fri, 26 Jan 2024 21:28:01 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,
>
> Coleen Phillimore has updated the pull request incrementally with one additional commit since the last revision:
>
> Fix nullptr in comments and strings to null. @kimbarrett changes.
Looks good.
Part of the cleanup with using `nullptr` is that we should never need to cast `nullptr` to another pointer type. I flagged a few cases below but certainly not all.
For text/comments the general rule is that when talking about the general concept of nullness then we can say "null", whereas if referring to an actual code artifact we use "nullptr". Sometimes either will be fine e.g "returns null on error", "returns nullptr on error".
Thanks.
test/hotspot/gtest/gc/shared/test_bufferNodeAllocator.cpp line 65:
> 63: ASSERT_EQ(0u, allocator.free_count());
> 64: nodes[i] = allocator.allocate();
> 65: ASSERT_EQ((BufferNode*)nullptr, nodes[i]->next());
We often find that once we use `nullptr` casts like this are not needed.
test/hotspot/gtest/logging/test_log.cpp line 64:
> 62: ResourceMark rm;
> 63: FILE* fp = os::fopen(TestLogFileName, "r");
> 64: ASSERT_NE((void*)nullptr, fp);
Cast should not be needed
test/hotspot/gtest/metaspace/metaspaceGtestCommon.hpp line 148:
> 146:
> 147: //////////////////////////////////////////////////////////
> 148: // Some helpers to avoid typing out those annoying casts for nullptr
Casts for nullptr should no longer be needed
test/hotspot/gtest/nmt/test_nmt_buffer_overflow_detection.cpp line 112:
> 110:
> 111: static void test_invalid_block_address() {
> 112: // very low, like the result of an overflow or of accessing a nullptr this pointer
s/nullptr/null
This is referring to nullness as a concept.
-------------
Marked as reviewed by dholmes (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/17577#pullrequestreview-1847827312
PR Review Comment: https://git.openjdk.org/jdk/pull/17577#discussion_r1469074814
PR Review Comment: https://git.openjdk.org/jdk/pull/17577#discussion_r1469077391
PR Review Comment: https://git.openjdk.org/jdk/pull/17577#discussion_r1469078466
PR Review Comment: https://git.openjdk.org/jdk/pull/17577#discussion_r1469083197
More information about the hotspot-dev
mailing list