1
1
/*
2
- * Copyright (c) 2015, 2022 , Oracle and/or its affiliates. All rights reserved.
2
+ * Copyright (c) 2015, 2023 , Oracle and/or its affiliates. All rights reserved.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* This code is free software; you can redistribute it and/or modify it
40
40
#include " runtime/semaphore.hpp"
41
41
#include " utilities/globalDefinitions.hpp"
42
42
43
- LogOutput** LogConfiguration::_outputs = NULL ;
43
+ LogOutput** LogConfiguration::_outputs = nullptr ;
44
44
size_t LogConfiguration::_n_outputs = 0 ;
45
45
46
- LogConfiguration::UpdateListenerFunction* LogConfiguration::_listener_callbacks = NULL ;
46
+ LogConfiguration::UpdateListenerFunction* LogConfiguration::_listener_callbacks = nullptr ;
47
47
size_t LogConfiguration::_n_listener_callbacks = 0 ;
48
48
49
49
// LogFileOutput is the default type of output, its type prefix should be used if no type was specified
@@ -105,7 +105,7 @@ void LogConfiguration::initialize(jlong vm_start_time) {
105
105
StdoutLog = new LogStdoutOutput ();
106
106
StderrLog = new LogStderrOutput ();
107
107
LogFileOutput::set_file_name_parameters (vm_start_time);
108
- assert (_outputs == NULL , " Should not initialize _outputs before this function, initialize called twice?" );
108
+ assert (_outputs == nullptr , " Should not initialize _outputs before this function, initialize called twice?" );
109
109
_outputs = NEW_C_HEAP_ARRAY (LogOutput*, 2 , mtLogging);
110
110
_outputs[0 ] = StdoutLog;
111
111
_outputs[1 ] = StderrLog;
@@ -114,7 +114,7 @@ void LogConfiguration::initialize(jlong vm_start_time) {
114
114
_outputs[1 ]->set_config_string (" all=off" );
115
115
116
116
// Set the default output to warning and error level for all new tagsets.
117
- for (LogTagSet* ts = LogTagSet::first (); ts != NULL ; ts = ts->next ()) {
117
+ for (LogTagSet* ts = LogTagSet::first (); ts != nullptr ; ts = ts->next ()) {
118
118
ts->set_output_level (StdoutLog, LogLevel::Default);
119
119
}
120
120
}
@@ -129,18 +129,18 @@ void LogConfiguration::finalize() {
129
129
static bool normalize_output_name (const char * full_name, char * buffer, size_t len, outputStream* errstream) {
130
130
const char * start_quote = strchr (full_name, ' "' );
131
131
const char * equals = strchr (full_name, ' =' );
132
- const bool quoted = start_quote != NULL ;
132
+ const bool quoted = start_quote != nullptr ;
133
133
const bool is_stdout_or_stderr = (strcmp (full_name, " stdout" ) == 0 || strcmp (full_name, " stderr" ) == 0 );
134
134
135
135
// ignore equals sign within quotes
136
136
if (quoted && equals > start_quote) {
137
- equals = NULL ;
137
+ equals = nullptr ;
138
138
}
139
139
140
140
const char * prefix = " " ;
141
141
size_t prefix_len = 0 ;
142
142
const char * name = full_name;
143
- if (equals != NULL ) {
143
+ if (equals != nullptr ) {
144
144
// split on equals sign
145
145
name = equals + 1 ;
146
146
prefix = full_name;
@@ -153,7 +153,7 @@ static bool normalize_output_name(const char* full_name, char* buffer, size_t le
153
153
154
154
if (quoted) {
155
155
const char * end_quote = strchr (start_quote + 1 , ' "' );
156
- if (end_quote == NULL ) {
156
+ if (end_quote == nullptr ) {
157
157
errstream->print_cr (" Output name has opening quote but is missing a terminating quote." );
158
158
return false ;
159
159
}
@@ -190,14 +190,14 @@ LogOutput* LogConfiguration::new_output(const char* name,
190
190
output = new LogFileOutput (name);
191
191
} else {
192
192
errstream->print_cr (" Unsupported log output type: %s" , name);
193
- return NULL ;
193
+ return nullptr ;
194
194
}
195
195
196
196
bool success = output->initialize (options, errstream);
197
197
if (!success) {
198
198
errstream->print_cr (" Initialization of output '%s' using options '%s' failed." , name, options);
199
199
delete output;
200
- return NULL ;
200
+ return nullptr ;
201
201
}
202
202
return output;
203
203
}
@@ -245,7 +245,7 @@ void LogConfiguration::configure_output(size_t idx, const LogSelectionList& sele
245
245
size_t on_level[LogLevel::Count] = {0 };
246
246
247
247
bool enabled = false ;
248
- for (LogTagSet* ts = LogTagSet::first (); ts != NULL ; ts = ts->next ()) {
248
+ for (LogTagSet* ts = LogTagSet::first (); ts != nullptr ; ts = ts->next ()) {
249
249
LogLevelType level = selections.level_for (*ts);
250
250
251
251
// Ignore tagsets that do not, and will not log on the output
@@ -285,7 +285,7 @@ void LogConfiguration::configure_output(size_t idx, const LogSelectionList& sele
285
285
output->set_decorators (decorators);
286
286
287
287
// Update the decorators on all tagsets to get rid of unused decorators
288
- for (LogTagSet* ts = LogTagSet::first (); ts != NULL ; ts = ts->next ()) {
288
+ for (LogTagSet* ts = LogTagSet::first (); ts != nullptr ; ts = ts->next ()) {
289
289
ts->update_decorators ();
290
290
}
291
291
@@ -303,7 +303,7 @@ void LogConfiguration::disable_outputs() {
303
303
size_t idx = _n_outputs;
304
304
305
305
// Remove all outputs from all tagsets.
306
- for (LogTagSet* ts = LogTagSet::first (); ts != NULL ; ts = ts->next ()) {
306
+ for (LogTagSet* ts = LogTagSet::first (); ts != nullptr ; ts = ts->next ()) {
307
307
ts->disable_outputs ();
308
308
}
309
309
@@ -328,7 +328,7 @@ void LogConfiguration::disable_logging() {
328
328
ConfigurationLock cl;
329
329
disable_outputs ();
330
330
// Update the decorators on all tagsets to get rid of unused decorators
331
- for (LogTagSet* ts = LogTagSet::first (); ts != NULL ; ts = ts->next ()) {
331
+ for (LogTagSet* ts = LogTagSet::first (); ts != nullptr ; ts = ts->next ()) {
332
332
ts->update_decorators ();
333
333
}
334
334
notify_update_listeners ();
@@ -376,15 +376,15 @@ bool LogConfiguration::parse_command_line_arguments(const char* opts) {
376
376
#ifdef _WINDOWS
377
377
// Skip over Windows paths such as "C:\..." and "C:/...".
378
378
// Handles both "C:\..." and "file=C:\...".
379
- if (next != NULL && next[0 ] == ' :' && (next[1 ] == ' \\ ' || next[1 ] == ' /' )) {
379
+ if (next != nullptr && next[0 ] == ' :' && (next[1 ] == ' \\ ' || next[1 ] == ' /' )) {
380
380
if (next == str + 1 || (strncmp (str, " file=" , 5 ) == 0 )) {
381
381
next = strpbrk (next + 1 , " :\" " );
382
382
}
383
383
}
384
384
#endif
385
- while (next != NULL && *next == ' "' ) {
385
+ while (next != nullptr && *next == ' "' ) {
386
386
char * end_quote = strchr (next + 1 , ' "' );
387
- if (end_quote == NULL ) {
387
+ if (end_quote == nullptr ) {
388
388
log_error (logging)(" Missing terminating quote in -Xlog option '%s'" , str);
389
389
os::free (copy);
390
390
return false ;
@@ -393,16 +393,16 @@ bool LogConfiguration::parse_command_line_arguments(const char* opts) {
393
393
next = strpbrk (end_quote + 1 , " :\" " );
394
394
}
395
395
396
- if (next != NULL ) {
396
+ if (next != nullptr ) {
397
397
*next = ' \0 ' ;
398
398
str = next + 1 ;
399
399
} else {
400
- str = NULL ;
400
+ str = nullptr ;
401
401
break ;
402
402
}
403
403
}
404
404
405
- if (str != NULL ) {
405
+ if (str != nullptr ) {
406
406
log_warning (logging)(" Ignoring excess -Xlog options: \" %s\" " , str);
407
407
}
408
408
@@ -423,13 +423,13 @@ bool LogConfiguration::parse_command_line_arguments(const char* opts) {
423
423
// (parse_log_arguments() will report an error), but we make an exception for
424
424
// both StdoutLog and StderrLog as they're initialized automatically
425
425
// very early in the boot process.
426
- if (output == NULL || strlen (output) == 0 ||
426
+ if (output == nullptr || strlen (output) == 0 ||
427
427
strcmp (" stdout" , output) == 0 || strcmp (" #0" , output) == 0 ) {
428
428
if (!stdout_configured) {
429
429
success = StdoutLog->parse_options (output_options, &ss);
430
430
stdout_configured = true ;
431
431
// We no longer need to pass output options to parse_log_arguments().
432
- output_options = NULL ;
432
+ output_options = nullptr ;
433
433
}
434
434
// else - fall-through to normal option processing which will be rejected
435
435
// with a warning
@@ -438,7 +438,7 @@ bool LogConfiguration::parse_command_line_arguments(const char* opts) {
438
438
success = StderrLog->parse_options (output_options, &ss);
439
439
stderr_configured = true ;
440
440
// We no longer need to pass output options to parse_log_arguments().
441
- output_options = NULL ;
441
+ output_options = nullptr ;
442
442
}
443
443
// else - fall-through to normal option processing which will be rejected
444
444
// with a warning
@@ -456,7 +456,7 @@ bool LogConfiguration::parse_command_line_arguments(const char* opts) {
456
456
Log (logging) log ;
457
457
char * start = errbuf;
458
458
char * end = strchr (start, ' \n ' );
459
- assert (end != NULL , " line must end with newline '%s'" , start);
459
+ assert (end != nullptr , " line must end with newline '%s'" , start);
460
460
do {
461
461
assert (start < errbuf + sizeof (errbuf) &&
462
462
end < errbuf + sizeof (errbuf),
@@ -465,8 +465,8 @@ bool LogConfiguration::parse_command_line_arguments(const char* opts) {
465
465
log .write (level, " %s" , start);
466
466
start = end + 1 ;
467
467
end = strchr (start, ' \n ' );
468
- assert (end != NULL || *start == ' \0 ' , " line must end with newline '%s'" , start);
469
- } while (end != NULL );
468
+ assert (end != nullptr || *start == ' \0 ' , " line must end with newline '%s'" , start);
469
+ } while (end != nullptr );
470
470
}
471
471
472
472
os::free (copy);
@@ -478,8 +478,8 @@ bool LogConfiguration::parse_log_arguments(const char* outputstr,
478
478
const char * decoratorstr,
479
479
const char * output_options,
480
480
outputStream* errstream) {
481
- assert (errstream != NULL , " errstream can not be NULL " );
482
- if (outputstr == NULL || strlen (outputstr) == 0 ) {
481
+ assert (errstream != nullptr , " errstream can not be nullptr " );
482
+ if (outputstr == nullptr || strlen (outputstr) == 0 ) {
483
483
outputstr = " stdout" ;
484
484
}
485
485
@@ -514,7 +514,7 @@ bool LogConfiguration::parse_log_arguments(const char* outputstr,
514
514
if (idx == SIZE_MAX) {
515
515
// Attempt to create and add the output
516
516
LogOutput* output = new_output (normalized, output_options, errstream);
517
- if (output != NULL ) {
517
+ if (output != nullptr ) {
518
518
idx = add_output (output);
519
519
added = true ;
520
520
}
@@ -525,7 +525,7 @@ bool LogConfiguration::parse_log_arguments(const char* outputstr,
525
525
return false ;
526
526
}
527
527
}
528
- if (!added && output_options != NULL && strlen (output_options) > 0 ) {
528
+ if (!added && output_options != nullptr && strlen (output_options) > 0 ) {
529
529
errstream->print_cr (" Output options for existing outputs are ignored." );
530
530
}
531
531
configure_output (idx, selections, decorators);
@@ -690,7 +690,7 @@ void LogConfiguration::rotate_all_outputs() {
690
690
}
691
691
692
692
void LogConfiguration::register_update_listener (UpdateListenerFunction cb) {
693
- assert (cb != NULL , " Should not register NULL as listener" );
693
+ assert (cb != nullptr , " Should not register nullptr as listener" );
694
694
ConfigurationLock cl;
695
695
size_t idx = _n_listener_callbacks++;
696
696
_listener_callbacks = REALLOC_C_HEAP_ARRAY (UpdateListenerFunction,
0 commit comments