This is an automated email from the ASF dual-hosted git repository.
dmeden pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push:
new d727f203f5 records: Accept const char* in RecSetRecordString to avoid
const_cast(calling side). (#12629)
d727f203f5 is described below
commit d727f203f5ad43683c21ad19e2f99f1d24de54df
Author: Damian Meden <[email protected]>
AuthorDate: Mon Nov 3 10:56:27 2025 +0100
records: Accept const char* in RecSetRecordString to avoid
const_cast(calling side). (#12629)
---
include/records/RecCore.h | 2 +-
src/mgmt/rpc/handlers/config/Configuration.cc | 2 +-
src/records/P_RecCore.cc | 4 ++--
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/include/records/RecCore.h b/include/records/RecCore.h
index 1b999b0ab0..d0a6ed5b4f 100644
--- a/include/records/RecCore.h
+++ b/include/records/RecCore.h
@@ -157,7 +157,7 @@ void Enable_Config_Var(std::string_view const &name,
RecContextCb record_cb, Rec
RecErrT RecSetRecordInt(const char *name, RecInt rec_int, RecSourceT source,
bool lock = true);
RecErrT RecSetRecordFloat(const char *name, RecFloat rec_float, RecSourceT
source, bool lock = true);
-RecErrT RecSetRecordString(const char *name, const RecString rec_string,
RecSourceT source, bool lock = true);
+RecErrT RecSetRecordString(const char *name, RecStringConst rec_string,
RecSourceT source, bool lock = true);
RecErrT RecSetRecordCounter(const char *name, RecCounter rec_counter,
RecSourceT source, bool lock = true);
std::optional<RecInt> RecGetRecordInt(const char *name, bool lock =
true);
diff --git a/src/mgmt/rpc/handlers/config/Configuration.cc
b/src/mgmt/rpc/handlers/config/Configuration.cc
index 66141280ac..cf3f2fc60d 100644
--- a/src/mgmt/rpc/handlers/config/Configuration.cc
+++ b/src/mgmt/rpc/handlers/config/Configuration.cc
@@ -95,7 +95,7 @@ namespace
return false;
}
} else if constexpr (std::is_same_v<T, std::string>) {
- if (RecSetRecordString(info.name.c_str(), const_cast<char
*>(info.value.c_str()), REC_SOURCE_DEFAULT) != REC_ERR_OKAY) {
+ if (RecSetRecordString(info.name.c_str(), info.value.c_str(),
REC_SOURCE_DEFAULT) != REC_ERR_OKAY) {
return false;
}
}
diff --git a/src/records/P_RecCore.cc b/src/records/P_RecCore.cc
index e0e6789095..0f5df9cf49 100644
--- a/src/records/P_RecCore.cc
+++ b/src/records/P_RecCore.cc
@@ -221,10 +221,10 @@ RecSetRecordFloat(const char *name, RecFloat rec_float,
RecSourceT source, bool
}
RecErrT
-RecSetRecordString(const char *name, const RecString rec_string, RecSourceT
source, bool lock)
+RecSetRecordString(const char *name, RecStringConst rec_string, RecSourceT
source, bool lock)
{
RecData data;
- data.rec_string = rec_string;
+ data.rec_string = const_cast<RecString>(rec_string);
return RecSetRecord(RECT_NULL, name, RECD_STRING, &data, nullptr, source,
lock);
}