Skip to content

Commit 43288bb

Browse files
committed
8301477: Replace NULL with nullptr in os/aix
Reviewed-by: stuefe, coleenp, tsteele
1 parent 008c5eb commit 43288bb

13 files changed

+228
-231
lines changed

src/hotspot/os/aix/attachListener_aix.cpp

+16-16
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved.
33
* Copyright (c) 2012, 2018 SAP SE. All rights reserved.
44
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
*
@@ -85,7 +85,7 @@ class AixAttachListener: AllStatic {
8585
};
8686

8787
static void set_path(char* path) {
88-
if (path == NULL) {
88+
if (path == nullptr) {
8989
_path[0] = '\0';
9090
_has_path = false;
9191
} else {
@@ -153,7 +153,7 @@ class ArgumentIterator : public StackObj {
153153
if (_pos < _end) {
154154
_pos += 1;
155155
}
156-
return NULL;
156+
return nullptr;
157157
}
158158
char* res = _pos;
159159
char* next_pos = strchr(_pos, '\0');
@@ -188,7 +188,7 @@ extern "C" {
188188
}
189189
if (AixAttachListener::has_path()) {
190190
::unlink(AixAttachListener::path());
191-
AixAttachListener::set_path(NULL);
191+
AixAttachListener::set_path(nullptr);
192192
}
193193
}
194194
}
@@ -296,7 +296,7 @@ AixAttachOperation* AixAttachListener::read_request(int s) {
296296
assert(n <= left, "buffer was too small, impossible!");
297297
buf[max_len - 1] = '\0';
298298
if (n == -1) {
299-
return NULL; // reset by peer or other error
299+
return nullptr; // reset by peer or other error
300300
}
301301
if (n == 0) {
302302
break;
@@ -314,7 +314,7 @@ AixAttachOperation* AixAttachListener::read_request(int s) {
314314
char msg[32];
315315
os::snprintf_checked(msg, sizeof(msg), "%d\n", ATTACH_ERROR_BADVERSION);
316316
write_fully(s, msg, strlen(msg));
317-
return NULL;
317+
return nullptr;
318318
}
319319
}
320320
}
@@ -324,7 +324,7 @@ AixAttachOperation* AixAttachListener::read_request(int s) {
324324
} while (left > 0 && str_count < expected_str_count);
325325

326326
if (str_count != expected_str_count) {
327-
return NULL; // incomplete request
327+
return nullptr; // incomplete request
328328
}
329329

330330
// parse request
@@ -335,20 +335,20 @@ AixAttachOperation* AixAttachListener::read_request(int s) {
335335
char* v = args.next();
336336

337337
char* name = args.next();
338-
if (name == NULL || strlen(name) > AttachOperation::name_length_max) {
339-
return NULL;
338+
if (name == nullptr || strlen(name) > AttachOperation::name_length_max) {
339+
return nullptr;
340340
}
341341

342342
AixAttachOperation* op = new AixAttachOperation(name);
343343

344344
for (int i=0; i<AttachOperation::arg_count_max; i++) {
345345
char* arg = args.next();
346-
if (arg == NULL) {
347-
op->set_arg(i, NULL);
346+
if (arg == nullptr) {
347+
op->set_arg(i, nullptr);
348348
} else {
349349
if (strlen(arg) > AttachOperation::arg_length_max) {
350350
delete op;
351-
return NULL;
351+
return nullptr;
352352
}
353353
op->set_arg(i, arg);
354354
}
@@ -377,13 +377,13 @@ AixAttachOperation* AixAttachListener::dequeue() {
377377
if (AixAttachListener::is_shutdown()) {
378378
::close(listener());
379379
set_listener(-1);
380-
return NULL;
380+
return nullptr;
381381
}
382382
s = ::accept(listener(), &addr, &len);
383383
if (s == -1) {
384384
::close(listener());
385385
set_listener(-1);
386-
return NULL; // log a warning?
386+
return nullptr; // log a warning?
387387
}
388388

389389
// get the credentials of the peer and check the effective uid/guid
@@ -404,7 +404,7 @@ AixAttachOperation* AixAttachListener::dequeue() {
404404

405405
// peer credential look okay so we read the request
406406
AixAttachOperation* op = read_request(s);
407-
if (op == NULL) {
407+
if (op == nullptr) {
408408
::close(s);
409409
continue;
410410
} else {
@@ -580,7 +580,7 @@ void AttachListener::pd_data_dump() {
580580
}
581581

582582
AttachOperationFunctionInfo* AttachListener::pd_find_operation(const char* n) {
583-
return NULL;
583+
return nullptr;
584584
}
585585

586586
jint AttachListener::pd_set_flag(AttachOperation* op, outputStream* out) {

src/hotspot/os/aix/libo4.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class libo4 {
4545
//
4646
// See libo4.h for details on this API.
4747
//
48-
// Specify NULL for numbers you are not interested in.
48+
// Specify null for numbers you are not interested in.
4949
//
5050
// Returns false if an error happened. Activate OsMisc trace for
5151
// trace output.
@@ -61,7 +61,7 @@ class libo4 {
6161
//
6262
// See libo4.h for details on this API.
6363
//
64-
// Specify NULL for numbers you are not interested in.
64+
// Specify null for numbers you are not interested in.
6565
//
6666
// Returns false if an error happened. Activate OsMisc trace for
6767
// trace output.

src/hotspot/os/aix/libodm_aix.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
33
* Copyright (c) 2015, 2019 SAP SE. All rights reserved.
44
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
*
@@ -46,7 +46,7 @@ dynamicOdm::dynamicOdm() {
4646
if (!_odm_initialize || !_odm_set_path || !_odm_mount_class || !_odm_get_obj || !_odm_terminate) {
4747
trcVerbose("Couldn't find all required odm symbols from %s", libodmname);
4848
dlclose(_libhandle);
49-
_libhandle = NULL;
49+
_libhandle = nullptr;
5050
return;
5151
}
5252
}
@@ -56,7 +56,7 @@ dynamicOdm::~dynamicOdm() {
5656
}
5757

5858

59-
void odmWrapper::clean_data() { if (_data) { free(_data); _data = NULL; } }
59+
void odmWrapper::clean_data() { if (_data) { free(_data); _data = nullptr; } }
6060

6161

6262
int odmWrapper::class_offset(const char *field, bool is_aix_5)

src/hotspot/os/aix/libodm_aix.hpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
33
* Copyright (c) 2015, 2019 SAP SE. All rights reserved.
44
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
*
@@ -53,7 +53,7 @@ class dynamicOdm {
5353
public:
5454
dynamicOdm();
5555
~dynamicOdm();
56-
bool odm_loaded() {return _libhandle != NULL; }
56+
bool odm_loaded() {return _libhandle != nullptr; }
5757
};
5858

5959

@@ -68,8 +68,8 @@ class odmWrapper : private dynamicOdm {
6868

6969
public:
7070
// Make sure everything gets initialized and cleaned up properly.
71-
explicit odmWrapper(const char* odm_class_name, const char* odm_path = NULL) : _odm_class((CLASS_SYMBOL)-1),
72-
_data(NULL), _initialized(false) {
71+
explicit odmWrapper(const char* odm_class_name, const char* odm_path = nullptr) : _odm_class((CLASS_SYMBOL)-1),
72+
_data(nullptr), _initialized(false) {
7373
if (!odm_loaded()) { return; }
7474
_initialized = ((*_odm_initialize)() != -1);
7575
if (_initialized) {
@@ -88,9 +88,9 @@ class odmWrapper : private dynamicOdm {
8888
int class_offset(const char *field, bool is_aix_5);
8989
char* data() { return _data; }
9090

91-
char* retrieve_obj(const char* name = NULL) {
91+
char* retrieve_obj(const char* name = nullptr) {
9292
clean_data();
93-
char *cnp = (char*)(void*)(*_odm_get_obj)(odm_class(), (char*) name, NULL, (name == NULL) ? ODM_NEXT : ODM_FIRST);
93+
char *cnp = (char*)(void*)(*_odm_get_obj)(odm_class(), (char*) name, nullptr, (name == nullptr) ? ODM_NEXT : ODM_FIRST);
9494
if (cnp != (char*)-1) { _data = cnp; }
9595
return data();
9696
}

src/hotspot/os/aix/libperfstat_aix.cpp

+38-38
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved.
33
* Copyright (c) 2012, 2018 SAP SE. All rights reserved.
44
* Copyright (c) 2022, IBM Corp.
55
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -30,7 +30,7 @@
3030
#include <dlfcn.h>
3131

3232
// Handle to the libperfstat.
33-
static void* g_libhandle = NULL;
33+
static void* g_libhandle = nullptr;
3434

3535
typedef int (*fun_perfstat_cpu_t) (perfstat_id_t *name, PERFSTAT_CPU_T_LATEST* userbuff,
3636
int sizeof_userbuff, int desired_number);
@@ -60,15 +60,15 @@ typedef void (*fun_perfstat_reset_t) ();
6060

6161
typedef cid_t (*fun_wpar_getcid_t) ();
6262

63-
static fun_perfstat_cpu_total_t g_fun_perfstat_cpu_total = NULL;
64-
static fun_perfstat_cpu_t g_fun_perfstat_cpu = NULL;
65-
static fun_perfstat_memory_total_t g_fun_perfstat_memory_total = NULL;
66-
static fun_perfstat_netinterface_t g_fun_perfstat_netinterface = NULL;
67-
static fun_perfstat_partition_total_t g_fun_perfstat_partition_total = NULL;
68-
static fun_perfstat_process_t g_fun_perfstat_process = NULL;
69-
static fun_perfstat_wpar_total_t g_fun_perfstat_wpar_total = NULL;
70-
static fun_perfstat_reset_t g_fun_perfstat_reset = NULL;
71-
static fun_wpar_getcid_t g_fun_wpar_getcid = NULL;
63+
static fun_perfstat_cpu_total_t g_fun_perfstat_cpu_total = nullptr;
64+
static fun_perfstat_cpu_t g_fun_perfstat_cpu = nullptr;
65+
static fun_perfstat_memory_total_t g_fun_perfstat_memory_total = nullptr;
66+
static fun_perfstat_netinterface_t g_fun_perfstat_netinterface = nullptr;
67+
static fun_perfstat_partition_total_t g_fun_perfstat_partition_total = nullptr;
68+
static fun_perfstat_process_t g_fun_perfstat_process = nullptr;
69+
static fun_perfstat_wpar_total_t g_fun_perfstat_wpar_total = nullptr;
70+
static fun_perfstat_reset_t g_fun_perfstat_reset = nullptr;
71+
static fun_wpar_getcid_t g_fun_wpar_getcid = nullptr;
7272

7373
bool libperfstat::init() {
7474

@@ -114,29 +114,29 @@ void libperfstat::cleanup() {
114114

115115
if (g_libhandle) {
116116
dlclose(g_libhandle);
117-
g_libhandle = NULL;
117+
g_libhandle = nullptr;
118118
}
119119

120-
g_fun_perfstat_cpu_total = NULL;
121-
g_fun_perfstat_memory_total = NULL;
122-
g_fun_perfstat_partition_total = NULL;
123-
g_fun_perfstat_wpar_total = NULL;
124-
g_fun_perfstat_reset = NULL;
125-
g_fun_wpar_getcid = NULL;
120+
g_fun_perfstat_cpu_total = nullptr;
121+
g_fun_perfstat_memory_total = nullptr;
122+
g_fun_perfstat_partition_total = nullptr;
123+
g_fun_perfstat_wpar_total = nullptr;
124+
g_fun_perfstat_reset = nullptr;
125+
g_fun_wpar_getcid = nullptr;
126126

127127
}
128128

129129
int libperfstat::perfstat_cpu_total(perfstat_id_t *name, PERFSTAT_CPU_TOTAL_T_LATEST* userbuff,
130130
int sizeof_userbuff, int desired_number) {
131-
if (g_fun_perfstat_cpu_total == NULL) {
131+
if (g_fun_perfstat_cpu_total == nullptr) {
132132
return -1;
133133
}
134134
return g_fun_perfstat_cpu_total(name, userbuff, sizeof_userbuff, desired_number);
135135
}
136136

137137
int libperfstat::perfstat_cpu(perfstat_id_t *name, PERFSTAT_CPU_T_LATEST* userbuff,
138138
int sizeof_userbuff, int desired_number) {
139-
if (g_fun_perfstat_cpu == NULL) {
139+
if (g_fun_perfstat_cpu == nullptr) {
140140
return -1;
141141
}
142142
return g_fun_perfstat_cpu(name, userbuff, sizeof_userbuff, desired_number);
@@ -145,7 +145,7 @@ int libperfstat::perfstat_cpu(perfstat_id_t *name, PERFSTAT_CPU_T_LATEST* userbu
145145
int libperfstat::perfstat_memory_total(perfstat_id_t *name,
146146
perfstat_memory_total_t* userbuff,
147147
int sizeof_userbuff, int desired_number) {
148-
if (g_fun_perfstat_memory_total == NULL) {
148+
if (g_fun_perfstat_memory_total == nullptr) {
149149
return -1;
150150
}
151151
return g_fun_perfstat_memory_total(name, userbuff, sizeof_userbuff, desired_number);
@@ -154,44 +154,44 @@ int libperfstat::perfstat_memory_total(perfstat_id_t *name,
154154
int libperfstat::perfstat_netinterface(perfstat_id_t *name,
155155
perfstat_netinterface_t* userbuff,
156156
int sizeof_userbuff, int desired_number) {
157-
if (g_fun_perfstat_netinterface == NULL) {
157+
if (g_fun_perfstat_netinterface == nullptr) {
158158
return -1;
159159
}
160160
return g_fun_perfstat_netinterface(name, userbuff, sizeof_userbuff, desired_number);
161161
}
162162

163163
int libperfstat::perfstat_partition_total(perfstat_id_t *name, PERFSTAT_PARTITON_TOTAL_T_LATEST* userbuff,
164164
int sizeof_userbuff, int desired_number) {
165-
if (g_fun_perfstat_partition_total == NULL) {
165+
if (g_fun_perfstat_partition_total == nullptr) {
166166
return -1;
167167
}
168168
return g_fun_perfstat_partition_total(name, userbuff, sizeof_userbuff, desired_number);
169169
}
170170

171171
int libperfstat::perfstat_process(perfstat_id_t *name, perfstat_process_t* userbuff,
172172
int sizeof_userbuff, int desired_number) {
173-
if (g_fun_perfstat_process == NULL) {
173+
if (g_fun_perfstat_process == nullptr) {
174174
return -1;
175175
}
176176
return g_fun_perfstat_process(name, userbuff, sizeof_userbuff, desired_number);
177177
}
178178

179179
int libperfstat::perfstat_wpar_total(perfstat_id_wpar_t *name, PERFSTAT_WPAR_TOTAL_T_LATEST* userbuff,
180180
int sizeof_userbuff, int desired_number) {
181-
if (g_fun_perfstat_wpar_total == NULL) {
181+
if (g_fun_perfstat_wpar_total == nullptr) {
182182
return -1;
183183
}
184184
return g_fun_perfstat_wpar_total(name, userbuff, sizeof_userbuff, desired_number);
185185
}
186186

187187
void libperfstat::perfstat_reset() {
188-
if (g_fun_perfstat_reset != NULL) {
188+
if (g_fun_perfstat_reset != nullptr) {
189189
g_fun_perfstat_reset();
190190
}
191191
}
192192

193193
cid_t libperfstat::wpar_getcid() {
194-
if (g_fun_wpar_getcid == NULL) {
194+
if (g_fun_wpar_getcid == nullptr) {
195195
return (cid_t) -1;
196196
}
197197
return g_fun_wpar_getcid();
@@ -210,10 +210,10 @@ bool libperfstat::get_cpuinfo(cpuinfo_t* pci) {
210210
PERFSTAT_CPU_TOTAL_T_LATEST psct;
211211
memset (&psct, '\0', sizeof(psct));
212212

213-
if (-1 == libperfstat::perfstat_cpu_total(NULL, &psct, sizeof(PERFSTAT_CPU_TOTAL_T_LATEST), 1)) {
214-
if (-1 == libperfstat::perfstat_cpu_total(NULL, &psct, sizeof(perfstat_cpu_total_t_71), 1)) {
215-
if (-1 == libperfstat::perfstat_cpu_total(NULL, &psct, sizeof(perfstat_cpu_total_t_61), 1)) {
216-
if (-1 == libperfstat::perfstat_cpu_total(NULL, &psct, sizeof(perfstat_cpu_total_t_53), 1)) {
213+
if (-1 == libperfstat::perfstat_cpu_total(nullptr, &psct, sizeof(PERFSTAT_CPU_TOTAL_T_LATEST), 1)) {
214+
if (-1 == libperfstat::perfstat_cpu_total(nullptr, &psct, sizeof(perfstat_cpu_total_t_71), 1)) {
215+
if (-1 == libperfstat::perfstat_cpu_total(nullptr, &psct, sizeof(perfstat_cpu_total_t_61), 1)) {
216+
if (-1 == libperfstat::perfstat_cpu_total(nullptr, &psct, sizeof(perfstat_cpu_total_t_53), 1)) {
217217
trcVerbose("perfstat_cpu_total() failed (errno=%d)", errno);
218218
return false;
219219
}
@@ -248,12 +248,12 @@ bool libperfstat::get_partitioninfo(partitioninfo_t* ppi) {
248248

249249
bool ame_details = true;
250250

251-
if (-1 == libperfstat::perfstat_partition_total(NULL, &pspt, sizeof(PERFSTAT_PARTITON_TOTAL_T_LATEST), 1)) {
252-
if (-1 == libperfstat::perfstat_partition_total(NULL, &pspt, sizeof(perfstat_partition_total_t_71), 1)) {
251+
if (-1 == libperfstat::perfstat_partition_total(nullptr, &pspt, sizeof(PERFSTAT_PARTITON_TOTAL_T_LATEST), 1)) {
252+
if (-1 == libperfstat::perfstat_partition_total(nullptr, &pspt, sizeof(perfstat_partition_total_t_71), 1)) {
253253
ame_details = false;
254-
if (-1 == libperfstat::perfstat_partition_total(NULL, &pspt, sizeof(perfstat_partition_total_t_61), 1)) {
255-
if (-1 == libperfstat::perfstat_partition_total(NULL, &pspt, sizeof(perfstat_partition_total_t_53), 1)) {
256-
if (-1 == libperfstat::perfstat_partition_total(NULL, &pspt, sizeof(perfstat_partition_total_t_53_5), 1)) {
254+
if (-1 == libperfstat::perfstat_partition_total(nullptr, &pspt, sizeof(perfstat_partition_total_t_61), 1)) {
255+
if (-1 == libperfstat::perfstat_partition_total(nullptr, &pspt, sizeof(perfstat_partition_total_t_53), 1)) {
256+
if (-1 == libperfstat::perfstat_partition_total(nullptr, &pspt, sizeof(perfstat_partition_total_t_53_5), 1)) {
257257
trcVerbose("perfstat_partition_total() failed (errno=%d)", errno);
258258
return false;
259259
}
@@ -322,8 +322,8 @@ bool libperfstat::get_wparinfo(wparinfo_t* pwi) {
322322
PERFSTAT_WPAR_TOTAL_T_LATEST pswt;
323323
memset (&pswt, '\0', sizeof(pswt));
324324

325-
if (-1 == libperfstat::perfstat_wpar_total(NULL, &pswt, sizeof(PERFSTAT_WPAR_TOTAL_T_LATEST), 1)) {
326-
if (-1 == libperfstat::perfstat_wpar_total(NULL, &pswt, sizeof(perfstat_wpar_total_t_61), 1)) {
325+
if (-1 == libperfstat::perfstat_wpar_total(nullptr, &pswt, sizeof(PERFSTAT_WPAR_TOTAL_T_LATEST), 1)) {
326+
if (-1 == libperfstat::perfstat_wpar_total(nullptr, &pswt, sizeof(perfstat_wpar_total_t_61), 1)) {
327327
trcVerbose("perfstat_wpar_total() failed (errno=%d)", errno);
328328
return false;
329329
}

0 commit comments

Comments
 (0)