Skip to content

Commit cf93613

Browse files
authored
Cleanup - Use C++ style cast instead of the C style. Part 2 (#12159)
Also, "modernize" some code.
1 parent 5c82abd commit cf93613

File tree

10 files changed

+21
-21
lines changed

10 files changed

+21
-21
lines changed

src/api/InkAPITest.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2567,7 +2567,7 @@ REGRESSION_TEST(SDK_API_TSContDataGet)(RegressionTest *test, int /* atype ATS_UN
25672567
my_data->data1 = 1;
25682568
my_data->data2 = 2;
25692569

2570-
TSContDataSet(contp, (void *)my_data);
2570+
TSContDataSet(contp, static_cast<void *>(my_data));
25712571

25722572
TSContScheduleOnPool(contp, 0, TS_THREAD_POOL_NET);
25732573
}
@@ -3789,10 +3789,10 @@ REGRESSION_TEST(SDK_API_TSUrl)(RegressionTest *test, int /* atype ATS_UNUSED */,
37893789
const char *fragment = "yyy";
37903790
const char *fragment_get;
37913791
char *url_expected_string;
3792-
char *url_string_from_1 = (char *)nullptr;
3793-
char *url_string_from_2 = (char *)nullptr;
3794-
char *url_string_from_3 = (char *)nullptr;
3795-
char *url_string_from_print = (char *)nullptr;
3792+
char *url_string_from_1{nullptr};
3793+
char *url_string_from_2{nullptr};
3794+
char *url_string_from_3{nullptr};
3795+
char *url_string_from_print{nullptr};
37963796
int url_expected_length;
37973797
int url_length_from_1;
37983798
int url_length_from_2;
@@ -6478,7 +6478,7 @@ REGRESSION_TEST(SDK_API_TSTextLog)(RegressionTest *test, int /* atype ATS_UNUSED
64786478
same log file name. */
64796479
ats_scoped_str tmp(RecConfigReadLogDir());
64806480
snprintf(logname, sizeof(logname), "RegressionTestLog%d.log", static_cast<int>(getpid()));
6481-
snprintf(fullpath_logname, sizeof(fullpath_logname), "%s/%s", (const char *)tmp, logname);
6481+
snprintf(fullpath_logname, sizeof(fullpath_logname), "%s/%s", tmp.get(), logname);
64826482

64836483
unlink(fullpath_logname);
64846484
retVal = TSTextLogObjectCreate(logname, TS_LOG_MODE_ADD_TIMESTAMP, &ts_log);

src/api/InkIOCoreAPI.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ TSIOBufferBlockReadStart(TSIOBufferBlock blockp, TSIOBufferReader readerp, int64
568568
}
569569
}
570570

571-
return (const char *)p;
571+
return static_cast<const char *>(p);
572572
}
573573

574574
int64_t

src/iocore/aio/test_AIO.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ read_config(const char *config_filename)
371371
while (!fin.eof()) {
372372
field_name[0] = '\0';
373373
fin >> field_name;
374-
if (0) {}
374+
if (false) {}
375375
PARAM(hotset_size)
376376
PARAM(hotset_frequency)
377377
PARAM(touch_data)

src/iocore/cache/CacheHosting.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -607,10 +607,10 @@ ConfigVolumes::read_config_file()
607607
if (ec) {
608608
switch (ec.value()) {
609609
case ENOENT:
610-
Warning("Cannot open the config file: %s - %s", (const char *)config_path, strerror(ec.value()));
610+
Warning("Cannot open the config file: %s - %s", config_path.get(), strerror(ec.value()));
611611
break;
612612
default:
613-
Error("%s failed to load: %s", (const char *)config_path, strerror(ec.value()));
613+
Error("%s failed to load: %s", config_path.get(), strerror(ec.value()));
614614
return;
615615
}
616616
}

src/iocore/cache/CacheProcessor.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -928,11 +928,11 @@ cplist_reconfigure()
928928
}
929929
if (config_vol->size < 128) {
930930
Warning("the size of volume %d (%" PRId64 ") is less than the minimum required volume size %d", config_vol->number,
931-
(int64_t)config_vol->size, 128);
931+
static_cast<int64_t>(config_vol->size), 128);
932932
Warning("volume %d is not created", config_vol->number);
933933
}
934-
Dbg(dbg_ctl_cache_hosting, "Volume: %d Size: %" PRId64 " Ramcache: %d", config_vol->number, (int64_t)config_vol->size,
935-
config_vol->ramcache_enabled);
934+
Dbg(dbg_ctl_cache_hosting, "Volume: %d Size: %" PRId64 " Ramcache: %d", config_vol->number,
935+
static_cast<int64_t>(config_vol->size), config_vol->ramcache_enabled);
936936
}
937937
cplist_update();
938938

src/iocore/net/Socks.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ loadSocksConfiguration(socks_conf_struct *socks_conf_stuff)
489489
SocksServerConfig::startup();
490490

491491
config_pathname = RecConfigReadConfigPath("proxy.config.socks.socks_config_file");
492-
Dbg(dbg_ctl_Socks, "Socks Config File: %s", (const char *)config_pathname);
492+
Dbg(dbg_ctl_Socks, "Socks Config File: %s", config_pathname.get());
493493

494494
if (!config_pathname) {
495495
Error("SOCKS Config: could not read config file name. SOCKS Turned off");

src/proxy/Plugin.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ plugin_expand(char *arg)
213213
char *str = nullptr;
214214

215215
if (*arg != '$') {
216-
return (char *)nullptr;
216+
return nullptr;
217217
}
218218
// skip the $ character
219219
arg += 1;

src/proxy/hdrs/URL.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,7 +1187,7 @@ url_is_strictly_compliant(const char *start, const char *end)
11871187
{
11881188
for (const char *i = start; i < end; ++i) {
11891189
if (!ParseRules::is_uri(*i)) {
1190-
Dbg(dbg_ctl_http, "Non-RFC compliant character [0x%.2X] found in URL", (unsigned char)*i);
1190+
Dbg(dbg_ctl_http, "Non-RFC compliant character [0x%.2X] found in URL", static_cast<unsigned char>(*i));
11911191
return false;
11921192
}
11931193
}
@@ -1204,11 +1204,11 @@ url_is_mostly_compliant(const char *start, const char *end)
12041204
{
12051205
for (const char *i = start; i < end; ++i) {
12061206
if (isspace(*i)) {
1207-
Dbg(dbg_ctl_http, "Whitespace character [0x%.2X] found in URL", (unsigned char)*i);
1207+
Dbg(dbg_ctl_http, "Whitespace character [0x%.2X] found in URL", static_cast<unsigned char>(*i));
12081208
return false;
12091209
}
12101210
if (!isprint(*i)) {
1211-
Dbg(dbg_ctl_http, "Non-printable character [0x%.2X] found in URL", (unsigned char)*i);
1211+
Dbg(dbg_ctl_http, "Non-printable character [0x%.2X] found in URL", static_cast<unsigned char>(*i));
12121212
return false;
12131213
}
12141214
}

src/proxy/hdrs/unit_tests/test_Huffmancode.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,12 @@ void
6969
random_test()
7070
{
7171
const int size = 1024;
72-
char *dst_start = (char *)malloc(size * 2);
72+
char *dst_start = static_cast<char *>(malloc(size * 2));
7373
char string[size];
7474
for (char &i : string) {
7575
// coverity[dont_call]
7676
long num = lrand48();
77-
i = (char)num;
77+
i = static_cast<char>(num);
7878
}
7979
const uint8_t *src = (const uint8_t *)string;
8080
uint32_t src_len = sizeof(string);

src/records/RecConfigParse.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ RecConfigOverrideFromEnvironment(const char *name, const char *value)
119119
}
120120
}
121121

122-
envval = getenv((const char *)envname);
122+
envval = getenv(envname.get());
123123
if (envval) {
124124
return envval;
125125
} else if (RecConfigOverrideFromRunroot(name)) {

0 commit comments

Comments
 (0)