Skip to content

Commit c88e081

Browse files
author
Kim Barrett
committedDec 16, 2024
8346160: Fix -Wzero-as-null-pointer-constant warnings from explicit casts
Reviewed-by: stefank, dholmes
1 parent ab1dbd4 commit c88e081

File tree

5 files changed

+6
-6
lines changed

5 files changed

+6
-6
lines changed
 

‎src/hotspot/os/aix/attachListener_aix.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
#include <unistd.h>
4040

4141
#ifndef UNIX_PATH_MAX
42-
#define UNIX_PATH_MAX sizeof(((struct sockaddr_un *)0)->sun_path)
42+
#define UNIX_PATH_MAX sizeof(sockaddr_un::sun_path)
4343
#endif
4444

4545
// The attach mechanism on AIX uses a UNIX domain socket. An attach listener

‎src/hotspot/os/posix/attachListener_posix.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
#ifndef AIX
4444

4545
#ifndef UNIX_PATH_MAX
46-
#define UNIX_PATH_MAX sizeof(((struct sockaddr_un *)0)->sun_path)
46+
#define UNIX_PATH_MAX sizeof(sockaddr_un::sun_path)
4747
#endif
4848

4949
// The attach mechanism on Linux and BSD uses a UNIX domain socket. An attach

‎src/hotspot/os/posix/perfMemory_posix.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1053,7 +1053,7 @@ static char* mmap_create_shared(size_t size) {
10531053
return nullptr;
10541054
}
10551055

1056-
mapAddress = (char*)::mmap((char*)0, size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
1056+
mapAddress = (char*)::mmap(nullptr, size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
10571057

10581058
result = ::close(fd);
10591059
assert(result != OS_ERR, "could not close file");
@@ -1208,7 +1208,7 @@ static void mmap_attach_shared(int vmid, char** addr, size_t* sizep, TRAPS) {
12081208

12091209
assert(size > 0, "unexpected size <= 0");
12101210

1211-
char* mapAddress = (char*)::mmap((char*)0, size, mmap_prot, MAP_SHARED, fd, 0);
1211+
char* mapAddress = (char*)::mmap(nullptr, size, mmap_prot, MAP_SHARED, fd, 0);
12121212

12131213
int result = ::close(fd);
12141214
assert(result != OS_ERR, "could not close file");

‎src/hotspot/share/oops/compressedKlass.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ void CompressedKlassPointers::initialize(address addr, size_t len) {
278278
if (!set_klass_decode_mode()) {
279279

280280
// Give fatal error if this is a specified address
281-
if ((address)CompressedClassSpaceBaseAddress == _base) {
281+
if (CompressedClassSpaceBaseAddress == (size_t)_base) {
282282
vm_exit_during_initialization(
283283
err_msg("CompressedClassSpaceBaseAddress=" PTR_FORMAT " given with shift %d, cannot be used to encode class pointers",
284284
CompressedClassSpaceBaseAddress, _shift));

‎src/hotspot/share/utilities/vmError.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ static const char* env_list[] = {
133133
// defined on Windows
134134
"OS", "PROCESSOR_IDENTIFIER", "_ALT_JAVA_HOME_DIR", "TMP", "TEMP",
135135

136-
(const char *)0
136+
nullptr // End marker.
137137
};
138138

139139
// A simple parser for -XX:OnError, usage:

0 commit comments

Comments
 (0)
Please sign in to comment.