From 65e4e57509a9c507115a444c57d596c8d2ebe159 Mon Sep 17 00:00:00 2001 From: Michael Spang Date: Mon, 4 Dec 2023 15:51:02 -0500 Subject: [PATCH] Fix improperly mutable pointers to string constants The declaration const char * kStringConstant = "value"; declares a mutable pointer to const C string, and so the following assignment is legal: kStringConstant = "other value"; Obviously this is not desired. Declaring as "const char * const" avoids this, but this declares an unnecessary pointer. Change these declarations to "const(expr) char []". These edits were made by the following command: find . \( -name '*.cpp' -o -name '*.h' \) -exec sed -i 's,^\( *\)\(static \|extern \|\)\(inline \|\)\(constexpr \|\)const char *\* * k\([A-Z][^][ ;()]*\)\( \|;\),\1\2\3\4const char k\5[]\6,g; s,^\([^()]*\)constexpr const char k\([^()]*\)\( \|;\),\1constexpr char k\2\3,g' {} + --- .../air-quality-sensor-app/linux/main.cpp | 2 +- .../all-clusters-app/linux/main-common.cpp | 2 +- .../commands/clusters/ComplexArgument.h | 4 +- .../commands/clusters/CustomArgument.h | 4 +- .../commands/clusters/WriteAttributeCommand.h | 6 +- .../chip-tool/commands/common/CHIPCommand.cpp | 14 ++-- .../chip-tool/commands/common/CHIPCommand.h | 8 +-- .../chip-tool/commands/common/Command.cpp | 6 +- .../chip-tool/commands/common/Commands.cpp | 10 +-- .../commands/common/DeviceScanner.cpp | 2 +- .../commands/common/RemoteDataModelLogger.cpp | 30 ++++---- .../interactive/InteractiveCommands.cpp | 12 ++-- .../chip-tool/commands/pairing/ToTLVCert.cpp | 4 +- examples/common/tracing/TraceDecoder.cpp | 36 +++++----- .../tracing/decoder/TraceDecoderProtocols.cpp | 2 +- .../common/tracing/decoder/bdx/Decoder.cpp | 24 +++---- .../common/tracing/decoder/echo/Decoder.cpp | 8 +-- .../decoder/interaction_model/Decoder.cpp | 26 +++---- .../decoder/logging/ToCertificateString.cpp | 8 +-- .../decoder/secure_channel/Decoder.cpp | 32 ++++----- .../common/tracing/decoder/udc/Decoder.cpp | 6 +- .../commands/common/CHIPCommandBridge.h | 6 +- .../commands/tests/TestCommandBridge.h | 2 +- examples/lighting-app/linux/main.cpp | 2 +- examples/lock-app/linux/main.cpp | 2 +- .../KeyValueStorageTest.cpp | 14 ++-- .../placeholder/linux/InteractiveServer.cpp | 24 +++---- .../placeholder/linux/include/TestCommand.h | 6 +- .../platform/nrfconnect/util/DFUTrigger.cpp | 4 +- .../platform/telink/common/src/mainCommon.cpp | 2 +- examples/rvc-app/linux/main.cpp | 2 +- .../clusters/wake-on-lan/WakeOnLanManager.cpp | 2 +- .../tv-casting-app/linux/CastingUtils.cpp | 4 +- .../suites/commands/delay/DelayCommands.cpp | 2 +- .../suites/commands/system/SystemCommands.cpp | 6 +- .../credentials/TestHarnessDACProvider.cpp | 16 ++--- .../ExampleOperationalCredentialsIssuer.cpp | 8 +-- src/controller/ExamplePersistentStorage.cpp | 12 ++-- .../AndroidOperationalCredentialsIssuer.cpp | 4 +- .../tests/TestGroupDataProvider.cpp | 6 +- src/crypto/CHIPCryptoPAL.h | 4 +- src/inet/TCPEndPoint.h | 2 +- src/inet/UDPEndPoint.h | 2 +- src/lib/asn1/tests/TestASN1.cpp | 4 +- src/lib/shell/MainLoopSilabs.cpp | 2 +- src/lib/support/PersistentStorageAudit.cpp | 12 ++-- src/lib/support/jsontlv/TlvJson.cpp | 4 +- .../tests/TestFixedBufferAllocator.cpp | 4 +- .../TestTestPersistentStorageDelegate.cpp | 12 ++-- src/platform/Darwin/DnssdContexts.cpp | 2 +- .../Darwin/DnssdHostNameRegistrar.cpp | 24 +++---- src/platform/Darwin/DnssdImpl.cpp | 2 +- src/platform/Darwin/DnssdType.cpp | 4 +- src/platform/ESP32/KeyValueStoreManagerImpl.h | 2 +- ...GenericThreadStackManagerImpl_OpenThread.h | 8 +-- src/platform/Tizen/DnssdImpl.cpp | 4 +- src/platform/Tizen/Logging.cpp | 2 +- src/platform/android/DnssdImpl.cpp | 4 +- src/platform/bouffalolab/common/BLConfig.h | 72 +++++++++---------- src/platform/mt793x/DnssdImpl.cpp | 6 +- .../mt793x/KeyValueStoreManagerImpl.h | 2 +- src/platform/nrfconnect/wifi/NrfWiFiDriver.h | 4 +- src/platform/tests/TestKeyValueStoreMgr.cpp | 30 ++++---- src/protocols/bdx/BdxMessages.h | 2 +- src/protocols/bdx/BdxUri.h | 2 +- src/protocols/echo/Echo.h | 2 +- src/protocols/interaction_model/Constants.h | 2 +- src/protocols/secure_channel/Constants.h | 2 +- src/protocols/secure_channel/PASESession.cpp | 6 +- src/protocols/secure_channel/PASESession.h | 4 +- .../UserDirectedCommissioning.h | 2 +- src/setup_payload/tests/TestHelpers.h | 2 +- src/transport/TraceMessage.h | 6 +- 73 files changed, 306 insertions(+), 306 deletions(-) diff --git a/examples/air-quality-sensor-app/linux/main.cpp b/examples/air-quality-sensor-app/linux/main.cpp index fddb23fb7b38a6..9dee0c20982f0a 100644 --- a/examples/air-quality-sensor-app/linux/main.cpp +++ b/examples/air-quality-sensor-app/linux/main.cpp @@ -35,7 +35,7 @@ using namespace chip::app; using namespace chip::app::Clusters; namespace { -constexpr const char kChipEventFifoPathPrefix[] = "/tmp/chip_air_quality_fifo_"; +constexpr char kChipEventFifoPathPrefix[] = "/tmp/chip_air_quality_fifo_"; NamedPipeCommands sChipNamedPipeCommands; AirQualitySensorAppAttrUpdateDelegate sAirQualitySensorAppCommandDelegate; } // namespace diff --git a/examples/all-clusters-app/linux/main-common.cpp b/examples/all-clusters-app/linux/main-common.cpp index 004827d742ae3c..f53b6aa68c8057 100644 --- a/examples/all-clusters-app/linux/main-common.cpp +++ b/examples/all-clusters-app/linux/main-common.cpp @@ -54,7 +54,7 @@ using namespace chip::DeviceLayer; namespace { -constexpr const char kChipEventFifoPathPrefix[] = "/tmp/chip_all_clusters_fifo_"; +constexpr char kChipEventFifoPathPrefix[] = "/tmp/chip_all_clusters_fifo_"; LowPowerManager sLowPowerManager; NamedPipeCommands sChipNamedPipeCommands; AllClustersCommandDelegate sAllClustersCommandDelegate; diff --git a/examples/chip-tool/commands/clusters/ComplexArgument.h b/examples/chip-tool/commands/clusters/ComplexArgument.h index fa19553d0cab62..6f92256ff735e4 100644 --- a/examples/chip-tool/commands/clusters/ComplexArgument.h +++ b/examples/chip-tool/commands/clusters/ComplexArgument.h @@ -45,8 +45,8 @@ #include "JsonParser.h" -inline constexpr uint8_t kMaxLabelLength = UINT8_MAX; -inline constexpr const char kNullString[] = "null"; +inline constexpr uint8_t kMaxLabelLength = UINT8_MAX; +inline constexpr char kNullString[] = "null"; class ComplexArgumentParser { diff --git a/examples/chip-tool/commands/clusters/CustomArgument.h b/examples/chip-tool/commands/clusters/CustomArgument.h index 81d1bbf7faa7bf..c2ab248550764d 100644 --- a/examples/chip-tool/commands/clusters/CustomArgument.h +++ b/examples/chip-tool/commands/clusters/CustomArgument.h @@ -239,8 +239,8 @@ class CustomArgument CHIP_ERROR Parse(const char * label, const char * json) { Json::Value value; - constexpr const char kHexNumPrefix[] = "0x"; - constexpr size_t kHexNumPrefixLen = ArraySize(kHexNumPrefix) - 1; + constexpr char kHexNumPrefix[] = "0x"; + constexpr size_t kHexNumPrefixLen = ArraySize(kHexNumPrefix) - 1; if (strncmp(json, kPayloadHexPrefix, kPayloadHexPrefixLen) == 0 || strncmp(json, kPayloadSignedPrefix, kPayloadSignedPrefixLen) == 0 || strncmp(json, kPayloadUnsignedPrefix, kPayloadUnsignedPrefixLen) == 0 || diff --git a/examples/chip-tool/commands/clusters/WriteAttributeCommand.h b/examples/chip-tool/commands/clusters/WriteAttributeCommand.h index 76dc64ef6201db..4fd49ac72b6c5e 100644 --- a/examples/chip-tool/commands/clusters/WriteAttributeCommand.h +++ b/examples/chip-tool/commands/clusters/WriteAttributeCommand.h @@ -23,9 +23,9 @@ #include "DataModelLogger.h" #include "ModelCommand.h" -inline constexpr const char * kWriteCommandKey = "write"; -inline constexpr const char * kWriteByIdCommandKey = "write-by-id"; -inline constexpr const char * kForceWriteCommandKey = "force-write"; +inline constexpr char kWriteCommandKey[] = "write"; +inline constexpr char kWriteByIdCommandKey[] = "write-by-id"; +inline constexpr char kForceWriteCommandKey[] = "force-write"; enum class WriteCommandType { diff --git a/examples/chip-tool/commands/common/CHIPCommand.cpp b/examples/chip-tool/commands/common/CHIPCommand.cpp index 043fbc33ac4f30..163af90fdd6f78 100644 --- a/examples/chip-tool/commands/common/CHIPCommand.cpp +++ b/examples/chip-tool/commands/common/CHIPCommand.cpp @@ -37,13 +37,13 @@ std::set CHIPCommand::sDeferredCleanups; using DeviceControllerFactory = chip::Controller::DeviceControllerFactory; -constexpr chip::FabricId kIdentityNullFabricId = chip::kUndefinedFabricId; -constexpr chip::FabricId kIdentityAlphaFabricId = 1; -constexpr chip::FabricId kIdentityBetaFabricId = 2; -constexpr chip::FabricId kIdentityGammaFabricId = 3; -constexpr chip::FabricId kIdentityOtherFabricId = 4; -constexpr const char * kPAATrustStorePathVariable = "CHIPTOOL_PAA_TRUST_STORE_PATH"; -constexpr const char * kCDTrustStorePathVariable = "CHIPTOOL_CD_TRUST_STORE_PATH"; +constexpr chip::FabricId kIdentityNullFabricId = chip::kUndefinedFabricId; +constexpr chip::FabricId kIdentityAlphaFabricId = 1; +constexpr chip::FabricId kIdentityBetaFabricId = 2; +constexpr chip::FabricId kIdentityGammaFabricId = 3; +constexpr chip::FabricId kIdentityOtherFabricId = 4; +constexpr char kPAATrustStorePathVariable[] = "CHIPTOOL_PAA_TRUST_STORE_PATH"; +constexpr char kCDTrustStorePathVariable[] = "CHIPTOOL_CD_TRUST_STORE_PATH"; const chip::Credentials::AttestationTrustStore * CHIPCommand::sTrustStore = nullptr; chip::Credentials::GroupDataProviderImpl CHIPCommand::sGroupDataProvider{ kMaxGroupsPerFabric, kMaxGroupKeysPerFabric }; diff --git a/examples/chip-tool/commands/common/CHIPCommand.h b/examples/chip-tool/commands/common/CHIPCommand.h index 0b6124600eb415..ae906166f28fa5 100644 --- a/examples/chip-tool/commands/common/CHIPCommand.h +++ b/examples/chip-tool/commands/common/CHIPCommand.h @@ -34,9 +34,9 @@ #pragma once -inline constexpr const char kIdentityAlpha[] = "alpha"; -inline constexpr const char kIdentityBeta[] = "beta"; -inline constexpr const char kIdentityGamma[] = "gamma"; +inline constexpr char kIdentityAlpha[] = "alpha"; +inline constexpr char kIdentityBeta[] = "beta"; +inline constexpr char kIdentityGamma[] = "gamma"; // The null fabric commissioner is a commissioner that isn't on a fabric. // This is a legal configuration in which the commissioner delegates // operational communication and invocation of the commssioning complete @@ -46,7 +46,7 @@ inline constexpr const char kIdentityGamma[] = "gamma"; // commissioner portion of such an architecture. The null-fabric-commissioner // can carry a commissioning flow up until the point of operational channel // (CASE) communcation. -inline constexpr const char kIdentityNull[] = "null-fabric-commissioner"; +inline constexpr char kIdentityNull[] = "null-fabric-commissioner"; class CHIPCommand : public Command { diff --git a/examples/chip-tool/commands/common/Command.cpp b/examples/chip-tool/commands/common/Command.cpp index 5e25abfe692af5..4f69a8059660e7 100644 --- a/examples/chip-tool/commands/common/Command.cpp +++ b/examples/chip-tool/commands/common/Command.cpp @@ -38,7 +38,7 @@ #include #include -constexpr const char * kOptionalArgumentPrefix = "--"; +constexpr char kOptionalArgumentPrefix[] = "--"; constexpr size_t kOptionalArgumentPrefixLength = 2; bool Command::InitArguments(int argc, char ** argv) @@ -347,8 +347,8 @@ bool Command::InitArgument(size_t argIndex, char * argValue) // By default the parameter separator is ";" in order to not collapse with the argument itself if it contains commas // (e.g a struct argument with multiple fields). In case one needs to use ";" it can be overriden with the following // environment variable. - constexpr const char * kSeparatorVariable = "CHIPTOOL_CUSTOM_ARGUMENTS_SEPARATOR"; - char * getenvSeparatorVariableResult = getenv(kSeparatorVariable); + constexpr char kSeparatorVariable[] = "CHIPTOOL_CUSTOM_ARGUMENTS_SEPARATOR"; + char * getenvSeparatorVariableResult = getenv(kSeparatorVariable); getline(ss, valueAsString, getenvSeparatorVariableResult ? getenvSeparatorVariableResult[0] : ';'); CustomArgument * customArgument = new CustomArgument(); diff --git a/examples/chip-tool/commands/common/Commands.cpp b/examples/chip-tool/commands/common/Commands.cpp index 8212656b9539ba..6a815f98e896ec 100644 --- a/examples/chip-tool/commands/common/Commands.cpp +++ b/examples/chip-tool/commands/common/Commands.cpp @@ -37,11 +37,11 @@ namespace { char kInteractiveModeName[] = ""; constexpr size_t kInteractiveModeArgumentsMaxLength = 32; -constexpr const char * kOptionalArgumentPrefix = "--"; -constexpr const char * kJsonClusterKey = "cluster"; -constexpr const char * kJsonCommandKey = "command"; -constexpr const char * kJsonCommandSpecifierKey = "command_specifier"; -constexpr const char * kJsonArgumentsKey = "arguments"; +constexpr char kOptionalArgumentPrefix[] = "--"; +constexpr char kJsonClusterKey[] = "cluster"; +constexpr char kJsonCommandKey[] = "command"; +constexpr char kJsonCommandSpecifierKey[] = "command_specifier"; +constexpr char kJsonArgumentsKey[] = "arguments"; #if !CHIP_DISABLE_PLATFORM_KVS template diff --git a/examples/chip-tool/commands/common/DeviceScanner.cpp b/examples/chip-tool/commands/common/DeviceScanner.cpp index 9a1858691758ea..29d31c1fc80565 100644 --- a/examples/chip-tool/commands/common/DeviceScanner.cpp +++ b/examples/chip-tool/commands/common/DeviceScanner.cpp @@ -23,7 +23,7 @@ using namespace chip::Dnssd; #if CONFIG_NETWORK_LAYER_BLE using namespace chip::Ble; -constexpr const char * kBleKey = "BLE"; +constexpr char kBleKey[] = "BLE"; #endif // CONFIG_NETWORK_LAYER_BLE CHIP_ERROR DeviceScanner::Start() diff --git a/examples/chip-tool/commands/common/RemoteDataModelLogger.cpp b/examples/chip-tool/commands/common/RemoteDataModelLogger.cpp index c17eee477e5fb7..37955e821e8b82 100644 --- a/examples/chip-tool/commands/common/RemoteDataModelLogger.cpp +++ b/examples/chip-tool/commands/common/RemoteDataModelLogger.cpp @@ -21,21 +21,21 @@ #include #include -constexpr const char * kEventNumberKey = "eventNumber"; -constexpr const char * kDataVersionKey = "dataVersion"; -constexpr const char * kClusterIdKey = "clusterId"; -constexpr const char * kEndpointIdKey = "endpointId"; -constexpr const char * kAttributeIdKey = "attributeId"; -constexpr const char * kEventIdKey = "eventId"; -constexpr const char * kCommandIdKey = "commandId"; -constexpr const char * kErrorIdKey = "error"; -constexpr const char * kClusterErrorIdKey = "clusterError"; -constexpr const char * kValueKey = "value"; -constexpr const char * kNodeIdKey = "nodeId"; -constexpr const char * kNOCKey = "NOC"; -constexpr const char * kICACKey = "ICAC"; -constexpr const char * kRCACKey = "RCAC"; -constexpr const char * kIPKKey = "IPK"; +constexpr char kEventNumberKey[] = "eventNumber"; +constexpr char kDataVersionKey[] = "dataVersion"; +constexpr char kClusterIdKey[] = "clusterId"; +constexpr char kEndpointIdKey[] = "endpointId"; +constexpr char kAttributeIdKey[] = "attributeId"; +constexpr char kEventIdKey[] = "eventId"; +constexpr char kCommandIdKey[] = "commandId"; +constexpr char kErrorIdKey[] = "error"; +constexpr char kClusterErrorIdKey[] = "clusterError"; +constexpr char kValueKey[] = "value"; +constexpr char kNodeIdKey[] = "nodeId"; +constexpr char kNOCKey[] = "NOC"; +constexpr char kICACKey[] = "ICAC"; +constexpr char kRCACKey[] = "RCAC"; +constexpr char kIPKKey[] = "IPK"; namespace { RemoteDataModelLoggerDelegate * gDelegate; diff --git a/examples/chip-tool/commands/interactive/InteractiveCommands.cpp b/examples/chip-tool/commands/interactive/InteractiveCommands.cpp index 40b4431df116a6..9856b9af1bbd1a 100644 --- a/examples/chip-tool/commands/interactive/InteractiveCommands.cpp +++ b/examples/chip-tool/commands/interactive/InteractiveCommands.cpp @@ -22,12 +22,12 @@ #include -constexpr const char * kInteractiveModePrompt = ">>> "; -constexpr const char * kInteractiveModeHistoryFilePath = "/tmp/chip_tool_history"; -constexpr const char * kInteractiveModeStopCommand = "quit()"; -constexpr const char * kCategoryError = "Error"; -constexpr const char * kCategoryProgress = "Info"; -constexpr const char * kCategoryDetail = "Debug"; +constexpr char kInteractiveModePrompt[] = ">>> "; +constexpr char kInteractiveModeHistoryFilePath[] = "/tmp/chip_tool_history"; +constexpr char kInteractiveModeStopCommand[] = "quit()"; +constexpr char kCategoryError[] = "Error"; +constexpr char kCategoryProgress[] = "Info"; +constexpr char kCategoryDetail[] = "Debug"; namespace { diff --git a/examples/chip-tool/commands/pairing/ToTLVCert.cpp b/examples/chip-tool/commands/pairing/ToTLVCert.cpp index f17769df64efac..2c06b7f1629171 100644 --- a/examples/chip-tool/commands/pairing/ToTLVCert.cpp +++ b/examples/chip-tool/commands/pairing/ToTLVCert.cpp @@ -21,8 +21,8 @@ #include #include -constexpr const char kBase64Header[] = "base64:"; -constexpr size_t kBase64HeaderLen = ArraySize(kBase64Header) - 1; +constexpr char kBase64Header[] = "base64:"; +constexpr size_t kBase64HeaderLen = ArraySize(kBase64Header) - 1; CHIP_ERROR ToBase64(const chip::ByteSpan & input, std::string & outputAsPrefixedBase64) { diff --git a/examples/common/tracing/TraceDecoder.cpp b/examples/common/tracing/TraceDecoder.cpp index 7aecfa2bacb08e..dec46706af16fe 100644 --- a/examples/common/tracing/TraceDecoder.cpp +++ b/examples/common/tracing/TraceDecoder.cpp @@ -35,24 +35,24 @@ namespace trace { namespace { // Json keys -constexpr const char * kProtocolIdKey = "protocol_id"; -constexpr const char * kProtocolCodeKey = "protocol_opcode"; -constexpr const char * kSessionIdKey = "session_id"; -constexpr const char * kExchangeIdKey = "exchange_id"; -constexpr const char * kMessageCounterKey = "msg_counter"; -constexpr const char * kSecurityFlagsKey = "security_flags"; -constexpr const char * kMessageFlagsKey = "msg_flags"; -constexpr const char * kSourceNodeIdKey = "source_node_id"; -constexpr const char * kDestinationNodeIdKey = "dest_node_id"; -constexpr const char * kDestinationGroupIdKey = "group_id"; -constexpr const char * kExchangeFlagsKey = "exchange_flags"; -constexpr const char * kIsInitiatorKey = "is_initiator"; -constexpr const char * kNeedsAckKey = "is_ack_requested"; -constexpr const char * kAckMsgKey = "acknowledged_msg_counter"; -constexpr const char * kPayloadDataKey = "payload_hex"; -constexpr const char * kPayloadSizeKey = "payload_size"; -constexpr const char * kDirectionKey = "direction"; -constexpr const char * kPeerAddress = "peer_address"; +constexpr char kProtocolIdKey[] = "protocol_id"; +constexpr char kProtocolCodeKey[] = "protocol_opcode"; +constexpr char kSessionIdKey[] = "session_id"; +constexpr char kExchangeIdKey[] = "exchange_id"; +constexpr char kMessageCounterKey[] = "msg_counter"; +constexpr char kSecurityFlagsKey[] = "security_flags"; +constexpr char kMessageFlagsKey[] = "msg_flags"; +constexpr char kSourceNodeIdKey[] = "source_node_id"; +constexpr char kDestinationNodeIdKey[] = "dest_node_id"; +constexpr char kDestinationGroupIdKey[] = "group_id"; +constexpr char kExchangeFlagsKey[] = "exchange_flags"; +constexpr char kIsInitiatorKey[] = "is_initiator"; +constexpr char kNeedsAckKey[] = "is_ack_requested"; +constexpr char kAckMsgKey[] = "acknowledged_msg_counter"; +constexpr char kPayloadDataKey[] = "payload_hex"; +constexpr char kPayloadSizeKey[] = "payload_size"; +constexpr char kDirectionKey[] = "direction"; +constexpr char kPeerAddress[] = "peer_address"; bool IsOutbound(const Json::Value & json) { diff --git a/examples/common/tracing/decoder/TraceDecoderProtocols.cpp b/examples/common/tracing/decoder/TraceDecoderProtocols.cpp index e6881bd4361c8c..fff7df95f65e00 100644 --- a/examples/common/tracing/decoder/TraceDecoderProtocols.cpp +++ b/examples/common/tracing/decoder/TraceDecoderProtocols.cpp @@ -30,7 +30,7 @@ namespace { -constexpr const char * kUnknown = "Unknown"; +constexpr char kUnknown[] = "Unknown"; void ENFORCE_FORMAT(1, 2) TLVPrettyPrinter(const char * aFormat, ...) { diff --git a/examples/common/tracing/decoder/bdx/Decoder.cpp b/examples/common/tracing/decoder/bdx/Decoder.cpp index e3db318449668d..7a6181fcf73bb3 100644 --- a/examples/common/tracing/decoder/bdx/Decoder.cpp +++ b/examples/common/tracing/decoder/bdx/Decoder.cpp @@ -21,19 +21,19 @@ #include namespace { -constexpr const char * kProtocolName = "Bulk Data Exchange"; +constexpr char kProtocolName[] = "Bulk Data Exchange"; -constexpr const char * kUnknown = "Unknown"; -constexpr const char * kSendInit = "Send Init"; -constexpr const char * kSendAccept = "Send Accept"; -constexpr const char * kReceiveInit = "Receive Init"; -constexpr const char * kReceiveAccept = "Receive Accept"; -constexpr const char * kBlockQuery = "Block Query"; -constexpr const char * kBlock = "Block"; -constexpr const char * kBlockEOF = "Block End Of File"; -constexpr const char * kBlockAck = "Block Ack"; -constexpr const char * kBlockAckEOF = "Block Ack End Of File"; -constexpr const char * kBlockQueryWithSkip = "Block Query With Skip"; +constexpr char kUnknown[] = "Unknown"; +constexpr char kSendInit[] = "Send Init"; +constexpr char kSendAccept[] = "Send Accept"; +constexpr char kReceiveInit[] = "Receive Init"; +constexpr char kReceiveAccept[] = "Receive Accept"; +constexpr char kBlockQuery[] = "Block Query"; +constexpr char kBlock[] = "Block"; +constexpr char kBlockEOF[] = "Block End Of File"; +constexpr char kBlockAck[] = "Block Ack"; +constexpr char kBlockAckEOF[] = "Block Ack End Of File"; +constexpr char kBlockQueryWithSkip[] = "Block Query With Skip"; } // namespace using MessageType = chip::bdx::MessageType; diff --git a/examples/common/tracing/decoder/echo/Decoder.cpp b/examples/common/tracing/decoder/echo/Decoder.cpp index 0d3240e78456c0..21e7d2a8699641 100644 --- a/examples/common/tracing/decoder/echo/Decoder.cpp +++ b/examples/common/tracing/decoder/echo/Decoder.cpp @@ -21,11 +21,11 @@ #include namespace { -constexpr const char * kProtocolName = "Echo"; +constexpr char kProtocolName[] = "Echo"; -constexpr const char * kUnknown = "Unknown"; -constexpr const char * kEchoRequest = "Echo Request"; -constexpr const char * kEchoResponse = "Echo Response"; +constexpr char kUnknown[] = "Unknown"; +constexpr char kEchoRequest[] = "Echo Request"; +constexpr char kEchoResponse[] = "Echo Response"; } // namespace using MessageType = chip::Protocols::Echo::MsgType; diff --git a/examples/common/tracing/decoder/interaction_model/Decoder.cpp b/examples/common/tracing/decoder/interaction_model/Decoder.cpp index 36f05b3c59d6ec..8563fd8a3443af 100644 --- a/examples/common/tracing/decoder/interaction_model/Decoder.cpp +++ b/examples/common/tracing/decoder/interaction_model/Decoder.cpp @@ -31,19 +31,19 @@ #include namespace { -constexpr const char * kProtocolName = "Interaction Model"; - -constexpr const char * kUnknown = "Unknown"; -constexpr const char * kStatusResponse = "Status Response"; -constexpr const char * kReadRequest = "Read Request"; -constexpr const char * kSubscribeRequest = "Subscribe Request"; -constexpr const char * kSubscribeResponse = "Subscribe Response"; -constexpr const char * kReportData = "Report Data"; -constexpr const char * kWriteRequest = "Write Request"; -constexpr const char * kWriteResponse = "Write Response"; -constexpr const char * kInvokeCommandRequest = "InvokeCommandRequest"; -constexpr const char * kInvokeCommandResponse = "InvokeCommandResponse"; -constexpr const char * kTimedRequest = "Timed Request"; +constexpr char kProtocolName[] = "Interaction Model"; + +constexpr char kUnknown[] = "Unknown"; +constexpr char kStatusResponse[] = "Status Response"; +constexpr char kReadRequest[] = "Read Request"; +constexpr char kSubscribeRequest[] = "Subscribe Request"; +constexpr char kSubscribeResponse[] = "Subscribe Response"; +constexpr char kReportData[] = "Report Data"; +constexpr char kWriteRequest[] = "Write Request"; +constexpr char kWriteResponse[] = "Write Response"; +constexpr char kInvokeCommandRequest[] = "InvokeCommandRequest"; +constexpr char kInvokeCommandResponse[] = "InvokeCommandResponse"; +constexpr char kTimedRequest[] = "Timed Request"; } // namespace diff --git a/examples/common/tracing/decoder/logging/ToCertificateString.cpp b/examples/common/tracing/decoder/logging/ToCertificateString.cpp index ee2dfe30a9bc10..468493567b46c8 100644 --- a/examples/common/tracing/decoder/logging/ToCertificateString.cpp +++ b/examples/common/tracing/decoder/logging/ToCertificateString.cpp @@ -103,16 +103,16 @@ namespace logging { const char * ToCertificateString(const ByteSpan & source, MutableCharSpan destination) { - constexpr const char * kCertificateHeader = "-----BEGIN CERTIFICATE-----"; - constexpr const char * kCertificateFooter = "-----END CERTIFICATE-----"; + constexpr char kCertificateHeader[] = "-----BEGIN CERTIFICATE-----"; + constexpr char kCertificateFooter[] = "-----END CERTIFICATE-----"; return ToCertificate(source, destination, kCertificateHeader, kCertificateFooter); } const char * ToCertificateRequestString(const ByteSpan & source, MutableCharSpan destination) { - constexpr const char * kCertificateHeader = "-----BEGIN CERTIFICATE REQUEST-----"; - constexpr const char * kCertificateFooter = "-----END CERTIFICATE REQUEST-----"; + constexpr char kCertificateHeader[] = "-----BEGIN CERTIFICATE REQUEST-----"; + constexpr char kCertificateFooter[] = "-----END CERTIFICATE REQUEST-----"; return ToCertificate(source, destination, kCertificateHeader, kCertificateFooter); } diff --git a/examples/common/tracing/decoder/secure_channel/Decoder.cpp b/examples/common/tracing/decoder/secure_channel/Decoder.cpp index 04ec5522ff8391..a6cd0b362a55e0 100644 --- a/examples/common/tracing/decoder/secure_channel/Decoder.cpp +++ b/examples/common/tracing/decoder/secure_channel/Decoder.cpp @@ -24,22 +24,22 @@ #include namespace { -constexpr const char * kProtocolName = "Secure Channel"; - -constexpr const char * kUnknown = "Unknown"; -constexpr const char * kMsgCounterSyncReq = "Message Counter Sync Request"; -constexpr const char * kMsgCounterSyncResp = "Message Counter Sync Response"; -constexpr const char * kStandaloneAck = "Standalone Ack"; -constexpr const char * kPBKDFParamRequest = "Password-Based Key Derivation Parameters Request"; -constexpr const char * kPBKDFParamResponse = "Password-Based Key Derivation Parameters Response"; -constexpr const char * kPASE_Pake1 = "Password Authenticated Session Establishment '1'"; -constexpr const char * kPASE_Pake2 = "Password Authenticated Session Establishment '2'"; -constexpr const char * kPASE_Pake3 = "Password Authenticated Session Establishment '3'"; -constexpr const char * kCASE_Sigma1 = "Certificate Authenticated Session Establishment Sigma '1'"; -constexpr const char * kCASE_Sigma2 = "Certificate Authenticated Session Establishment Sigma '2'"; -constexpr const char * kCASE_Sigma3 = "Certificate Authenticated Session Establishment Sigma '3'"; -constexpr const char * kCASE_Sigma2Resume = "Certificate Authenticated Session Establishment Sigma '2' Resume"; -constexpr const char * kStatusReport = "Status Report"; +constexpr char kProtocolName[] = "Secure Channel"; + +constexpr char kUnknown[] = "Unknown"; +constexpr char kMsgCounterSyncReq[] = "Message Counter Sync Request"; +constexpr char kMsgCounterSyncResp[] = "Message Counter Sync Response"; +constexpr char kStandaloneAck[] = "Standalone Ack"; +constexpr char kPBKDFParamRequest[] = "Password-Based Key Derivation Parameters Request"; +constexpr char kPBKDFParamResponse[] = "Password-Based Key Derivation Parameters Response"; +constexpr char kPASE_Pake1[] = "Password Authenticated Session Establishment '1'"; +constexpr char kPASE_Pake2[] = "Password Authenticated Session Establishment '2'"; +constexpr char kPASE_Pake3[] = "Password Authenticated Session Establishment '3'"; +constexpr char kCASE_Sigma1[] = "Certificate Authenticated Session Establishment Sigma '1'"; +constexpr char kCASE_Sigma2[] = "Certificate Authenticated Session Establishment Sigma '2'"; +constexpr char kCASE_Sigma3[] = "Certificate Authenticated Session Establishment Sigma '3'"; +constexpr char kCASE_Sigma2Resume[] = "Certificate Authenticated Session Establishment Sigma '2' Resume"; +constexpr char kStatusReport[] = "Status Report"; } // namespace using MessageType = chip::Protocols::SecureChannel::MsgType; diff --git a/examples/common/tracing/decoder/udc/Decoder.cpp b/examples/common/tracing/decoder/udc/Decoder.cpp index 01fb75a2ab314e..ba1964f7b993c6 100644 --- a/examples/common/tracing/decoder/udc/Decoder.cpp +++ b/examples/common/tracing/decoder/udc/Decoder.cpp @@ -21,10 +21,10 @@ #include namespace { -constexpr const char * kProtocolName = "User Directed Commissioning"; +constexpr char kProtocolName[] = "User Directed Commissioning"; -constexpr const char * kUnknown = "Unknown"; -constexpr const char * kIdentificationDeclaration = "Identification Declaration"; +constexpr char kUnknown[] = "Unknown"; +constexpr char kIdentificationDeclaration[] = "Identification Declaration"; } // namespace using MessageType = chip::Protocols::UserDirectedCommissioning::MsgType; diff --git a/examples/darwin-framework-tool/commands/common/CHIPCommandBridge.h b/examples/darwin-framework-tool/commands/common/CHIPCommandBridge.h index 4537f522081cff..842ded8f839ab7 100644 --- a/examples/darwin-framework-tool/commands/common/CHIPCommandBridge.h +++ b/examples/darwin-framework-tool/commands/common/CHIPCommandBridge.h @@ -28,9 +28,9 @@ #pragma once -inline constexpr const char kIdentityAlpha[] = "alpha"; -inline constexpr const char kIdentityBeta[] = "beta"; -inline constexpr const char kIdentityGamma[] = "gamma"; +inline constexpr char kIdentityAlpha[] = "alpha"; +inline constexpr char kIdentityBeta[] = "beta"; +inline constexpr char kIdentityGamma[] = "gamma"; class CHIPCommandBridge : public Command { public: diff --git a/examples/darwin-framework-tool/commands/tests/TestCommandBridge.h b/examples/darwin-framework-tool/commands/tests/TestCommandBridge.h index aa01ea7f4cb4fb..0c87c96cfe65d1 100644 --- a/examples/darwin-framework-tool/commands/tests/TestCommandBridge.h +++ b/examples/darwin-framework-tool/commands/tests/TestCommandBridge.h @@ -41,7 +41,7 @@ const char basePath[] = "./src/app/tests/suites/commands/delay/scripts/"; const char * getScriptsFolder() { return basePath; } } // namespace -inline constexpr const char * kDefaultKey = "default"; +inline constexpr char kDefaultKey[] = "default"; @interface TestDeviceControllerDelegate : NSObject @property TestCommandBridge * commandBridge; diff --git a/examples/lighting-app/linux/main.cpp b/examples/lighting-app/linux/main.cpp index 3bd27fddc0f95a..149898bf86360f 100644 --- a/examples/lighting-app/linux/main.cpp +++ b/examples/lighting-app/linux/main.cpp @@ -40,7 +40,7 @@ using namespace chip::app::Clusters; namespace { -constexpr const char kChipEventFifoPathPrefix[] = "/tmp/chip_lighting_fifo_"; +constexpr char kChipEventFifoPathPrefix[] = "/tmp/chip_lighting_fifo_"; NamedPipeCommands sChipNamedPipeCommands; LightingAppCommandDelegate sLightingAppCommandDelegate; } // namespace diff --git a/examples/lock-app/linux/main.cpp b/examples/lock-app/linux/main.cpp index bf4f485758485a..d45a28a8090255 100644 --- a/examples/lock-app/linux/main.cpp +++ b/examples/lock-app/linux/main.cpp @@ -27,7 +27,7 @@ using namespace chip::app; namespace { // Variables for handling named pipe commands -constexpr const char kChipEventFifoPathPrefix[] = "/tmp/chip_lock_app_fifo-"; +constexpr char kChipEventFifoPathPrefix[] = "/tmp/chip_lock_app_fifo-"; NamedPipeCommands sChipNamedPipeCommands; LockAppCommandDelegate sLockAppCommandDelegate; diff --git a/examples/persistent-storage/KeyValueStorageTest.cpp b/examples/persistent-storage/KeyValueStorageTest.cpp index 3adcd955d73b5b..c015e2002a589d 100644 --- a/examples/persistent-storage/KeyValueStorageTest.cpp +++ b/examples/persistent-storage/KeyValueStorageTest.cpp @@ -49,7 +49,7 @@ namespace { CHIP_ERROR TestEmptyString() { - const char * kTestKey = "str_key"; + const char kTestKey[] = "str_key"; const char kTestValue[] = ""; char read_value[sizeof(kTestValue)]; size_t read_size; @@ -63,7 +63,7 @@ CHIP_ERROR TestEmptyString() CHIP_ERROR TestString() { - const char * kTestKey = "str_key"; + const char kTestKey[] = "str_key"; const char kTestValue[] = "test_value"; char read_value[sizeof(kTestValue)]; size_t read_size; @@ -77,7 +77,7 @@ CHIP_ERROR TestString() CHIP_ERROR TestUint32() { - const char * kTestKey = "uint32_key"; + const char kTestKey[] = "uint32_key"; uint32_t kTestValue = 5; uint32_t read_value; ReturnErrorOnFailure(KeyValueStoreMgr().Put(kTestKey, kTestValue)); @@ -89,7 +89,7 @@ CHIP_ERROR TestUint32() CHIP_ERROR TestArray() { - const char * kTestKey = "array_key"; + const char kTestKey[] = "array_key"; uint32_t kTestValue[5] = { 1, 2, 3, 4, 5 }; uint32_t read_value[5]; ReturnErrorOnFailure(KeyValueStoreMgr().Put(kTestKey, kTestValue)); @@ -106,7 +106,7 @@ CHIP_ERROR TestStruct() uint8_t value1; uint32_t value2; }; - const char * kTestKey = "struct_key"; + const char kTestKey[] = "struct_key"; SomeStruct kTestValue{ value1 : 1, value2 : 2 }; SomeStruct read_value; ReturnErrorOnFailure(KeyValueStoreMgr().Put(kTestKey, kTestValue)); @@ -119,7 +119,7 @@ CHIP_ERROR TestStruct() CHIP_ERROR TestUpdateValue() { - const char * kTestKey = "update_key"; + const char kTestKey[] = "update_key"; uint32_t read_value; for (size_t i = 0; i < 10; i++) { @@ -133,7 +133,7 @@ CHIP_ERROR TestUpdateValue() CHIP_ERROR TestMultiRead() { - const char * kTestKey = "multi_key"; + const char kTestKey[] = "multi_key"; uint32_t kTestValue[5] = { 1, 2, 3, 4, 5 }; ReturnErrorOnFailure(KeyValueStoreMgr().Put(kTestKey, kTestValue)); for (size_t i = 0; i < 5; i++) diff --git a/examples/placeholder/linux/InteractiveServer.cpp b/examples/placeholder/linux/InteractiveServer.cpp index c1356666747a70..daebcb6dfc6cfa 100644 --- a/examples/placeholder/linux/InteractiveServer.cpp +++ b/examples/placeholder/linux/InteractiveServer.cpp @@ -26,18 +26,18 @@ using namespace chip::DeviceLayer; namespace { -constexpr const char * kClusterIdKey = "clusterId"; -constexpr const char * kEndpointIdKey = "endpointId"; -constexpr const char * kAttributeIdKey = "attributeId"; -constexpr const char * kWaitTypeKey = "waitType"; -constexpr const char * kAttributeWriteKey = "writeAttribute"; -constexpr const char * kAttributeReadKey = "readAttribute"; -constexpr const char * kCommandIdKey = "commandId"; -constexpr const char * kWaitForCommissioningCommand = "WaitForCommissioning"; -constexpr const char * kCategoryError = "Error"; -constexpr const char * kCategoryProgress = "Info"; -constexpr const char * kCategoryDetail = "Debug"; -constexpr const char * kCategoryAutomation = "Automation"; +constexpr char kClusterIdKey[] = "clusterId"; +constexpr char kEndpointIdKey[] = "endpointId"; +constexpr char kAttributeIdKey[] = "attributeId"; +constexpr char kWaitTypeKey[] = "waitType"; +constexpr char kAttributeWriteKey[] = "writeAttribute"; +constexpr char kAttributeReadKey[] = "readAttribute"; +constexpr char kCommandIdKey[] = "commandId"; +constexpr char kWaitForCommissioningCommand[] = "WaitForCommissioning"; +constexpr char kCategoryError[] = "Error"; +constexpr char kCategoryProgress[] = "Info"; +constexpr char kCategoryDetail[] = "Debug"; +constexpr char kCategoryAutomation[] = "Automation"; struct InteractiveServerResultLog { diff --git a/examples/placeholder/linux/include/TestCommand.h b/examples/placeholder/linux/include/TestCommand.h index e078345f430643..5b0d733d4736dc 100644 --- a/examples/placeholder/linux/include/TestCommand.h +++ b/examples/placeholder/linux/include/TestCommand.h @@ -35,9 +35,9 @@ #include #include -inline constexpr const char kIdentityAlpha[] = ""; -inline constexpr const char kIdentityBeta[] = ""; -inline constexpr const char kIdentityGamma[] = ""; +inline constexpr char kIdentityAlpha[] = ""; +inline constexpr char kIdentityBeta[] = ""; +inline constexpr char kIdentityGamma[] = ""; class TestCommand : public TestRunner, public PICSChecker, diff --git a/examples/platform/nrfconnect/util/DFUTrigger.cpp b/examples/platform/nrfconnect/util/DFUTrigger.cpp index c287e56097fd6b..729c3fd6453c7e 100644 --- a/examples/platform/nrfconnect/util/DFUTrigger.cpp +++ b/examples/platform/nrfconnect/util/DFUTrigger.cpp @@ -24,8 +24,8 @@ #include namespace { -constexpr const char * kGPIOController = "GPIO_0"; -constexpr gpio_pin_t kGPIOResetPin = 19; +constexpr char kGPIOController[] = "GPIO_0"; +constexpr gpio_pin_t kGPIOResetPin = 19; int cmd_dfu(const struct shell * shell, size_t argc, char ** argv) { diff --git a/examples/platform/telink/common/src/mainCommon.cpp b/examples/platform/telink/common/src/mainCommon.cpp index d73c26fac1f04d..ea13dc2f51252f 100644 --- a/examples/platform/telink/common/src/mainCommon.cpp +++ b/examples/platform/telink/common/src/mainCommon.cpp @@ -39,7 +39,7 @@ using namespace ::chip::DeviceLayer; #ifdef CONFIG_CHIP_ENABLE_POWER_ON_FACTORY_RESET static constexpr uint32_t kFactoryResetOnBootMaxCnt = 5; -static constexpr const char * kFactoryResetOnBootStoreKey = "TelinkFactoryResetOnBootCnt"; +static constexpr char kFactoryResetOnBootStoreKey[] = "TelinkFactoryResetOnBootCnt"; static constexpr uint32_t kFactoryResetUsualBootTimeoutMs = 5000; static k_timer FactoryResetUsualBootTimer; diff --git a/examples/rvc-app/linux/main.cpp b/examples/rvc-app/linux/main.cpp index 3800e8e501d168..4a332123345397 100644 --- a/examples/rvc-app/linux/main.cpp +++ b/examples/rvc-app/linux/main.cpp @@ -26,7 +26,7 @@ using namespace chip::app; using namespace chip::app::Clusters; namespace { -constexpr const char kChipEventFifoPathPrefix[] = "/tmp/chip_rvc_fifo_"; +constexpr char kChipEventFifoPathPrefix[] = "/tmp/chip_rvc_fifo_"; NamedPipeCommands sChipNamedPipeCommands; RvcAppCommandDelegate sRvcAppCommandDelegate; } // namespace diff --git a/examples/tv-app/tv-common/clusters/wake-on-lan/WakeOnLanManager.cpp b/examples/tv-app/tv-common/clusters/wake-on-lan/WakeOnLanManager.cpp index e6fb5e38e61969..53beedefcc8a98 100644 --- a/examples/tv-app/tv-common/clusters/wake-on-lan/WakeOnLanManager.cpp +++ b/examples/tv-app/tv-common/clusters/wake-on-lan/WakeOnLanManager.cpp @@ -23,7 +23,7 @@ #include #include -constexpr const char * kNullHexMACAddress = "000000000000"; +constexpr char kNullHexMACAddress[] = "000000000000"; using namespace chip; using namespace chip::app::Clusters::WakeOnLan; diff --git a/examples/tv-casting-app/linux/CastingUtils.cpp b/examples/tv-casting-app/linux/CastingUtils.cpp index c3c2df893fa3fa..02b9467d884614 100644 --- a/examples/tv-casting-app/linux/CastingUtils.cpp +++ b/examples/tv-casting-app/linux/CastingUtils.cpp @@ -26,8 +26,8 @@ using namespace chip::DeviceLayer; using namespace chip::Dnssd; // TODO: Accept these values over CLI -const char * kContentUrl = "https://www.test.com/videoid"; -const char * kContentDisplayStr = "Test video"; +const char kContentUrl[] = "https://www.test.com/videoid"; +const char kContentDisplayStr[] = "Test video"; int gInitialContextVal = 121212; CHIP_ERROR DiscoverCommissioners() diff --git a/src/app/tests/suites/commands/delay/DelayCommands.cpp b/src/app/tests/suites/commands/delay/DelayCommands.cpp index d33922924284db..abf66ea9fa1192 100644 --- a/src/app/tests/suites/commands/delay/DelayCommands.cpp +++ b/src/app/tests/suites/commands/delay/DelayCommands.cpp @@ -26,7 +26,7 @@ const char * getScriptsFolder() } } // namespace -constexpr const char * kDefaultKey = "default"; +constexpr char kDefaultKey[] = "default"; CHIP_ERROR DelayCommands::WaitForMs(const char * identity, const chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type & value) diff --git a/src/app/tests/suites/commands/system/SystemCommands.cpp b/src/app/tests/suites/commands/system/SystemCommands.cpp index d586bd1f951385..c4e8559ffdf0a1 100644 --- a/src/app/tests/suites/commands/system/SystemCommands.cpp +++ b/src/app/tests/suites/commands/system/SystemCommands.cpp @@ -28,9 +28,9 @@ const char * getScriptsFolder() } } // namespace -constexpr size_t kCommandMaxLen = 256; -constexpr size_t kArgumentMaxLen = 128; -constexpr const char * kDefaultKey = "default"; +constexpr size_t kCommandMaxLen = 256; +constexpr size_t kArgumentMaxLen = 128; +constexpr char kDefaultKey[] = "default"; CHIP_ERROR SystemCommands::Start(const char * identity, const chip::app::Clusters::SystemCommands::Commands::Start::Type & value) { diff --git a/src/app/tests/suites/credentials/TestHarnessDACProvider.cpp b/src/app/tests/suites/credentials/TestHarnessDACProvider.cpp index 18819fa93241f5..fc7e9cb0d20994 100644 --- a/src/app/tests/suites/credentials/TestHarnessDACProvider.cpp +++ b/src/app/tests/suites/credentials/TestHarnessDACProvider.cpp @@ -196,14 +196,14 @@ TestHarnessDACProvider::TestHarnessDACProvider() void TestHarnessDACProvider::Init(const char * filepath) { - constexpr const char kDacCertKey[] = "dac_cert"; - constexpr const char kDacPrivateKey[] = "dac_private_key"; - constexpr const char kDacPublicKey[] = "dac_public_key"; - constexpr const char kPaiCertKey[] = "pai_cert"; - constexpr const char kCertDecKey[] = "certification_declaration"; - constexpr const char kFirmwareInfoKey[] = "firmware_information"; - constexpr const char kIsSuccessKey[] = "is_success_case"; - constexpr const char kDescription[] = "description"; + constexpr char kDacCertKey[] = "dac_cert"; + constexpr char kDacPrivateKey[] = "dac_private_key"; + constexpr char kDacPublicKey[] = "dac_public_key"; + constexpr char kPaiCertKey[] = "pai_cert"; + constexpr char kCertDecKey[] = "certification_declaration"; + constexpr char kFirmwareInfoKey[] = "firmware_information"; + constexpr char kIsSuccessKey[] = "is_success_case"; + constexpr char kDescription[] = "description"; std::ifstream json(filepath, std::ifstream::binary); if (!json) diff --git a/src/controller/ExampleOperationalCredentialsIssuer.cpp b/src/controller/ExampleOperationalCredentialsIssuer.cpp index d3d405a5a27f83..516b3ece2b4357 100644 --- a/src/controller/ExampleOperationalCredentialsIssuer.cpp +++ b/src/controller/ExampleOperationalCredentialsIssuer.cpp @@ -30,10 +30,10 @@ namespace chip { namespace Controller { -constexpr const char kOperationalCredentialsIssuerKeypairStorage[] = "ExampleOpCredsCAKey"; -constexpr const char kOperationalCredentialsIntermediateIssuerKeypairStorage[] = "ExampleOpCredsICAKey"; -constexpr const char kOperationalCredentialsRootCertificateStorage[] = "ExampleCARootCert"; -constexpr const char kOperationalCredentialsIntermediateCertificateStorage[] = "ExampleCAIntermediateCert"; +constexpr char kOperationalCredentialsIssuerKeypairStorage[] = "ExampleOpCredsCAKey"; +constexpr char kOperationalCredentialsIntermediateIssuerKeypairStorage[] = "ExampleOpCredsICAKey"; +constexpr char kOperationalCredentialsRootCertificateStorage[] = "ExampleCARootCert"; +constexpr char kOperationalCredentialsIntermediateCertificateStorage[] = "ExampleCAIntermediateCert"; using namespace Credentials; using namespace Crypto; diff --git a/src/controller/ExamplePersistentStorage.cpp b/src/controller/ExamplePersistentStorage.cpp index 77e54549258919..90c84421f7481a 100644 --- a/src/controller/ExamplePersistentStorage.cpp +++ b/src/controller/ExamplePersistentStorage.cpp @@ -32,12 +32,12 @@ using namespace ::chip::Controller; using namespace ::chip::IniEscaping; using namespace ::chip::Logging; -constexpr const char kDefaultSectionName[] = "Default"; -constexpr const char kPortKey[] = "ListenPort"; -constexpr const char kLoggingKey[] = "LoggingLevel"; -constexpr const char kLocalNodeIdKey[] = "LocalNodeId"; -constexpr const char kCommissionerCATsKey[] = "CommissionerCATs"; -constexpr LogCategory kDefaultLoggingLevel = kLogCategory_Automation; +constexpr char kDefaultSectionName[] = "Default"; +constexpr char kPortKey[] = "ListenPort"; +constexpr char kLoggingKey[] = "LoggingLevel"; +constexpr char kLocalNodeIdKey[] = "LocalNodeId"; +constexpr char kCommissionerCATsKey[] = "CommissionerCATs"; +constexpr LogCategory kDefaultLoggingLevel = kLogCategory_Automation; const char * GetUsedDirectory(const char * directory) { diff --git a/src/controller/java/AndroidOperationalCredentialsIssuer.cpp b/src/controller/java/AndroidOperationalCredentialsIssuer.cpp index 1cfa9d28d25960..f5b1b1a3351583 100644 --- a/src/controller/java/AndroidOperationalCredentialsIssuer.cpp +++ b/src/controller/java/AndroidOperationalCredentialsIssuer.cpp @@ -35,8 +35,8 @@ namespace chip { namespace Controller { -constexpr const char kOperationalCredentialsIssuerKeypairStorage[] = "AndroidDeviceControllerKey"; -constexpr const char kOperationalCredentialsRootCertificateStorage[] = "AndroidCARootCert"; +constexpr char kOperationalCredentialsIssuerKeypairStorage[] = "AndroidDeviceControllerKey"; +constexpr char kOperationalCredentialsRootCertificateStorage[] = "AndroidCARootCert"; using namespace Credentials; using namespace Crypto; diff --git a/src/credentials/tests/TestGroupDataProvider.cpp b/src/credentials/tests/TestGroupDataProvider.cpp index 2f57e3fdb89cc4..f3f44d8195d0eb 100644 --- a/src/credentials/tests/TestGroupDataProvider.cpp +++ b/src/credentials/tests/TestGroupDataProvider.cpp @@ -42,9 +42,9 @@ namespace chip { namespace app { namespace TestGroups { -static const char * kKey1 = "abc/def"; -static const char * kValue1 = "abc/def"; -static const char * kValue2 = "abc/ghi/xyz"; +static const char kKey1[] = "abc/def"; +static const char kValue1[] = "abc/def"; +static const char kValue2[] = "abc/ghi/xyz"; static const size_t kSize1 = strlen(kValue1) + 1; static const size_t kSize2 = strlen(kValue2) + 1; diff --git a/src/crypto/CHIPCryptoPAL.h b/src/crypto/CHIPCryptoPAL.h index 60c88b5e399d49..0a2720704c352e 100644 --- a/src/crypto/CHIPCryptoPAL.h +++ b/src/crypto/CHIPCryptoPAL.h @@ -55,8 +55,8 @@ inline constexpr size_t kMaxCertificateSerialNumberLength = 20; inline constexpr size_t kMaxCertificateDistinguishedNameLength = 200; inline constexpr size_t kMaxCRLDistributionPointURLLength = 100; -inline constexpr const char * kValidCDPURIHttpPrefix = "http://"; -inline constexpr const char * kValidCDPURIHttpsPrefix = "https://"; +inline constexpr char kValidCDPURIHttpPrefix[] = "http://"; +inline constexpr char kValidCDPURIHttpsPrefix[] = "https://"; inline constexpr size_t CHIP_CRYPTO_GROUP_SIZE_BYTES = kP256_FE_Length; inline constexpr size_t CHIP_CRYPTO_PUBLIC_KEY_SIZE_BYTES = kP256_Point_Length; diff --git a/src/inet/TCPEndPoint.h b/src/inet/TCPEndPoint.h index 1caddc29859a7a..0e4c17b12d5876 100644 --- a/src/inet/TCPEndPoint.h +++ b/src/inet/TCPEndPoint.h @@ -625,7 +625,7 @@ class DLL_EXPORT TCPEndPoint : public EndPointBasis template <> struct EndPointProperties { - static constexpr const char * kName = "TCP"; + static constexpr char kName[] = "TCP"; static constexpr size_t kNumEndPoints = INET_CONFIG_NUM_TCP_ENDPOINTS; static constexpr int kSystemStatsKey = System::Stats::kInetLayer_NumTCPEps; }; diff --git a/src/inet/UDPEndPoint.h b/src/inet/UDPEndPoint.h index 04435ef17a8f0f..23f788c165e096 100644 --- a/src/inet/UDPEndPoint.h +++ b/src/inet/UDPEndPoint.h @@ -301,7 +301,7 @@ class DLL_EXPORT UDPEndPoint : public EndPointBasis template <> struct EndPointProperties { - static constexpr const char * kName = "UDP"; + static constexpr char kName[] = "UDP"; static constexpr size_t kNumEndPoints = INET_CONFIG_NUM_UDP_ENDPOINTS; static constexpr int kSystemStatsKey = System::Stats::kInetLayer_NumUDPEps; }; diff --git a/src/lib/asn1/tests/TestASN1.cpp b/src/lib/asn1/tests/TestASN1.cpp index 2552aa0b5a3427..6f4d5fe31d2d05 100644 --- a/src/lib/asn1/tests/TestASN1.cpp +++ b/src/lib/asn1/tests/TestASN1.cpp @@ -67,8 +67,8 @@ enum // clang-format off static uint8_t kTestVal_09_BitString_AsOctetString[] = { 0xE7, 0xC0 }; static uint8_t kTestVal_20_OctetString[] = { 0x01, 0x03, 0x05, 0x07, 0x10, 0x30, 0x50, 0x70, 0x00 }; -static const char * kTestVal_21_PrintableString = "Sudden death in Venice"; -static const char * kTestVal_22_UTFString = "Ond bra\xCC\x8A""d do\xCC\x88""d i Venedig"; +static const char kTestVal_21_PrintableString[] = "Sudden death in Venice"; +static const char kTestVal_22_UTFString[] = "Ond bra\xCC\x8A""d do\xCC\x88""d i Venedig"; // clang-format on // Manually copied from ASN1OID.h for testing. diff --git a/src/lib/shell/MainLoopSilabs.cpp b/src/lib/shell/MainLoopSilabs.cpp index 7c391f1a89d9ba..932d31ac39f92e 100644 --- a/src/lib/shell/MainLoopSilabs.cpp +++ b/src/lib/shell/MainLoopSilabs.cpp @@ -32,7 +32,7 @@ using chip::Shell::streamer_get; namespace { -constexpr const char kShellPrompt[] = "matterCli> "; +constexpr char kShellPrompt[] = "matterCli> "; // To track carriage returns of Windows return cases of '\r\n' bool haveCR = false; diff --git a/src/lib/support/PersistentStorageAudit.cpp b/src/lib/support/PersistentStorageAudit.cpp index cad5d8dee1e923..0c6f3788864542 100644 --- a/src/lib/support/PersistentStorageAudit.cpp +++ b/src/lib/support/PersistentStorageAudit.cpp @@ -56,7 +56,7 @@ bool ExecutePersistentStorageApiAudit(PersistentStorageDelegate & storage) } theSuite; auto * inSuite = &theSuite; - const char * kLongKeyString = "aKeyThatIsExactlyMaxKeyLengthhhh"; + const char kLongKeyString[] = "aKeyThatIsExactlyMaxKeyLengthhhh"; // Start fresh. (void) storage.SyncDeleteKeyValue("roboto"); (void) storage.SyncDeleteKeyValue("key2"); @@ -83,7 +83,7 @@ bool ExecutePersistentStorageApiAudit(PersistentStorageDelegate & storage) NL_TEST_ASSERT(inSuite, err == CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND); // Add basic key, read it back, erase it - const char * kStringValue1 = "abcd"; + const char kStringValue1[] = "abcd"; err = storage.SyncSetKeyValue("roboto", kStringValue1, static_cast(strlen(kStringValue1))); NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); @@ -104,8 +104,8 @@ bool ExecutePersistentStorageApiAudit(PersistentStorageDelegate & storage) NL_TEST_ASSERT(inSuite, size == actualSizeOfBuf); // Validate adding 2 different keys - const char * kStringValue2 = "0123abcd"; - const char * kStringValue3 = "cdef89"; + const char kStringValue2[] = "0123abcd"; + const char kStringValue3[] = "cdef89"; err = storage.SyncSetKeyValue("key2", kStringValue2, static_cast(strlen(kStringValue2))); NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); @@ -237,8 +237,8 @@ bool ExecutePersistentStorageApiAudit(PersistentStorageDelegate & storage) NL_TEST_ASSERT(inSuite, 0 == memcmp(&buf[0], &all_zeroes[0], size)); // Using key and value with base64 symbols - const char * kBase64SymbolsKey = "key+/="; - const char * kBase64SymbolValues = "value+/="; + const char kBase64SymbolsKey[] = "key+/="; + const char kBase64SymbolValues[] = "value+/="; err = storage.SyncSetKeyValue(kBase64SymbolsKey, kBase64SymbolValues, static_cast(strlen(kBase64SymbolValues))); NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); diff --git a/src/lib/support/jsontlv/TlvJson.cpp b/src/lib/support/jsontlv/TlvJson.cpp index b18331b730c833..e38c71bf88111e 100644 --- a/src/lib/support/jsontlv/TlvJson.cpp +++ b/src/lib/support/jsontlv/TlvJson.cpp @@ -67,8 +67,8 @@ struct KeyContext // static constexpr uint16_t kMaxStringLen = 1280; -constexpr const char kBase64Header[] = "base64:"; -constexpr size_t kBase64HeaderLen = ArraySize(kBase64Header) - 1; +constexpr char kBase64Header[] = "base64:"; +constexpr size_t kBase64HeaderLen = ArraySize(kBase64Header) - 1; namespace chip { diff --git a/src/lib/support/tests/TestFixedBufferAllocator.cpp b/src/lib/support/tests/TestFixedBufferAllocator.cpp index be494536819af6..be438a4315036d 100644 --- a/src/lib/support/tests/TestFixedBufferAllocator.cpp +++ b/src/lib/support/tests/TestFixedBufferAllocator.cpp @@ -32,7 +32,7 @@ void TestClone(nlTestSuite * inSuite, void * inContext) uint8_t buffer[128]; FixedBufferAllocator alloc(buffer); - const char * kTestString = "Test string"; + const char kTestString[] = "Test string"; const char * allocatedString = alloc.Clone(kTestString); NL_TEST_EXIT_ON_FAILED_ASSERT(inSuite, allocatedString != nullptr); @@ -56,7 +56,7 @@ void TestOutOfMemory(nlTestSuite * inSuite, void * inContext) uint8_t buffer[16]; FixedBufferAllocator alloc(buffer); - const char * kTestData = "0123456789abcdef"; + const char kTestData[] = "0123456789abcdef"; // Allocating 16 bytes still works... NL_TEST_ASSERT(inSuite, alloc.Clone(kTestData, 16) != nullptr); diff --git a/src/lib/support/tests/TestTestPersistentStorageDelegate.cpp b/src/lib/support/tests/TestTestPersistentStorageDelegate.cpp index 622520b320a5eb..929a58a06ca55e 100644 --- a/src/lib/support/tests/TestTestPersistentStorageDelegate.cpp +++ b/src/lib/support/tests/TestTestPersistentStorageDelegate.cpp @@ -72,7 +72,7 @@ void TestBasicApi(nlTestSuite * inSuite, void * inContext) NL_TEST_ASSERT(inSuite, err == CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND); // Add basic key, read it back, erase it - const char * kStringValue1 = "abcd"; + const char kStringValue1[] = "abcd"; err = storage.SyncSetKeyValue("roboto", kStringValue1, static_cast(strlen(kStringValue1))); NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); @@ -93,8 +93,8 @@ void TestBasicApi(nlTestSuite * inSuite, void * inContext) NL_TEST_ASSERT(inSuite, size == actualSizeOfBuf); // Validate adding 2 different keys - const char * kStringValue2 = "0123abcd"; - const char * kStringValue3 = "cdef89"; + const char kStringValue2[] = "0123abcd"; + const char kStringValue3[] = "cdef89"; err = storage.SyncSetKeyValue("key2", kStringValue2, static_cast(strlen(kStringValue2))); NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); @@ -231,8 +231,8 @@ void TestBasicApi(nlTestSuite * inSuite, void * inContext) NL_TEST_ASSERT(inSuite, 0 == memcmp(&buf[0], &all_zeroes[0], size)); // Using key and value with base64 symbols - const char * kBase64SymbolsKey = "key+/="; - const char * kBase64SymbolValues = "value+/="; + const char kBase64SymbolsKey[] = "key+/="; + const char kBase64SymbolValues[] = "value+/="; err = storage.SyncSetKeyValue(kBase64SymbolsKey, kBase64SymbolValues, static_cast(strlen(kBase64SymbolValues))); NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); @@ -318,7 +318,7 @@ void TestClearStorage(nlTestSuite * inSuite, void * inContext) NL_TEST_ASSERT(inSuite, size == sizeof(buf)); // Add basic key, read it back - const char * kStringValue1 = "abcd"; + const char kStringValue1[] = "abcd"; err = storage.SyncSetKeyValue("roboto", kStringValue1, static_cast(strlen(kStringValue1))); NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); NL_TEST_ASSERT(inSuite, storage.GetNumKeys() == 1); diff --git a/src/platform/Darwin/DnssdContexts.cpp b/src/platform/Darwin/DnssdContexts.cpp index 86df18e5432fee..cf4c35336edbf1 100644 --- a/src/platform/Darwin/DnssdContexts.cpp +++ b/src/platform/Darwin/DnssdContexts.cpp @@ -28,7 +28,7 @@ namespace { constexpr uint8_t kDnssdKeyMaxSize = 32; constexpr uint8_t kDnssdTxtRecordMaxEntries = 20; -constexpr const char * kLocalDot = "local."; +constexpr char kLocalDot[] = "local."; bool IsLocalDomain(const char * domain) { diff --git a/src/platform/Darwin/DnssdHostNameRegistrar.cpp b/src/platform/Darwin/DnssdHostNameRegistrar.cpp index 287bc0bec3380f..7ae1c82b85828c 100644 --- a/src/platform/Darwin/DnssdHostNameRegistrar.cpp +++ b/src/platform/Darwin/DnssdHostNameRegistrar.cpp @@ -37,18 +37,18 @@ namespace Dnssd { namespace { #if CHIP_PROGRESS_LOGGING -constexpr const char * kPathStatusInvalid = "Invalid"; -constexpr const char * kPathStatusUnsatisfied = "Unsatisfied"; -constexpr const char * kPathStatusSatisfied = "Satisfied"; -constexpr const char * kPathStatusSatisfiable = "Satisfiable"; -constexpr const char * kPathStatusUnknown = "Unknown"; - -constexpr const char * kInterfaceTypeCellular = "Cellular"; -constexpr const char * kInterfaceTypeWiFi = "WiFi"; -constexpr const char * kInterfaceTypeWired = "Wired"; -constexpr const char * kInterfaceTypeLoopback = "Loopback"; -constexpr const char * kInterfaceTypeOther = "Other"; -constexpr const char * kInterfaceTypeUnknown = "Unknown"; +constexpr char kPathStatusInvalid[] = "Invalid"; +constexpr char kPathStatusUnsatisfied[] = "Unsatisfied"; +constexpr char kPathStatusSatisfied[] = "Satisfied"; +constexpr char kPathStatusSatisfiable[] = "Satisfiable"; +constexpr char kPathStatusUnknown[] = "Unknown"; + +constexpr char kInterfaceTypeCellular[] = "Cellular"; +constexpr char kInterfaceTypeWiFi[] = "WiFi"; +constexpr char kInterfaceTypeWired[] = "Wired"; +constexpr char kInterfaceTypeLoopback[] = "Loopback"; +constexpr char kInterfaceTypeOther[] = "Other"; +constexpr char kInterfaceTypeUnknown[] = "Unknown"; const char * GetPathStatusString(nw_path_status_t status) { diff --git a/src/platform/Darwin/DnssdImpl.cpp b/src/platform/Darwin/DnssdImpl.cpp index fb661dd8e2f14d..7e9e7af521686d 100644 --- a/src/platform/Darwin/DnssdImpl.cpp +++ b/src/platform/Darwin/DnssdImpl.cpp @@ -31,7 +31,7 @@ using namespace chip::Dnssd::Internal; namespace { -constexpr const char * kLocalDot = "local."; +constexpr char kLocalDot[] = "local."; constexpr DNSServiceFlags kRegisterFlags = kDNSServiceFlagsNoAutoRename; constexpr DNSServiceFlags kBrowseFlags = 0; diff --git a/src/platform/Darwin/DnssdType.cpp b/src/platform/Darwin/DnssdType.cpp index e113fa45ff2029..4b810a67ae66e1 100644 --- a/src/platform/Darwin/DnssdType.cpp +++ b/src/platform/Darwin/DnssdType.cpp @@ -19,8 +19,8 @@ #include -constexpr const char * kProtocolTcp = "._tcp"; -constexpr const char * kProtocolUdp = "._udp"; +constexpr char kProtocolTcp[] = "._tcp"; +constexpr char kProtocolUdp[] = "._udp"; namespace chip { namespace Dnssd { diff --git a/src/platform/ESP32/KeyValueStoreManagerImpl.h b/src/platform/ESP32/KeyValueStoreManagerImpl.h index 1509c59976d663..28e5ef6b80efb6 100644 --- a/src/platform/ESP32/KeyValueStoreManagerImpl.h +++ b/src/platform/ESP32/KeyValueStoreManagerImpl.h @@ -45,7 +45,7 @@ class KeyValueStoreManagerImpl final : public KeyValueStoreManager CHIP_ERROR EraseAll(void); private: - const char * kNamespace = "CHIP_KVS"; + const char kNamespace[] = "CHIP_KVS"; // ===== Members for internal use by the following friends. friend KeyValueStoreManager & KeyValueStoreMgr(); diff --git a/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.h b/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.h index eb0aecdd289901..ccc3f65e3f6cad 100644 --- a/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.h +++ b/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.h @@ -163,10 +163,10 @@ class GenericThreadStackManagerImpl_OpenThread struct SrpClient { - static constexpr uint8_t kMaxServicesNumber = CHIP_DEVICE_CONFIG_THREAD_SRP_MAX_SERVICES; - static constexpr const char * kDefaultDomainName = "default.service.arpa"; - static constexpr uint8_t kDefaultDomainNameSize = 20; - static constexpr uint8_t kMaxDomainNameSize = 32; + static constexpr uint8_t kMaxServicesNumber = CHIP_DEVICE_CONFIG_THREAD_SRP_MAX_SERVICES; + static constexpr char kDefaultDomainName[] = "default.service.arpa"; + static constexpr uint8_t kDefaultDomainNameSize = 20; + static constexpr uint8_t kMaxDomainNameSize = 32; // SRP is used for both operational and commissionable services, so buffers sizes must be worst case. static constexpr size_t kSubTypeMaxNumber = Dnssd::Common::kSubTypeMaxNumber; diff --git a/src/platform/Tizen/DnssdImpl.cpp b/src/platform/Tizen/DnssdImpl.cpp index 64b6d45932e2d2..9d232cbbb82ef6 100644 --- a/src/platform/Tizen/DnssdImpl.cpp +++ b/src/platform/Tizen/DnssdImpl.cpp @@ -47,8 +47,8 @@ namespace { -constexpr uint8_t kDnssdKeyMaxSize = 32; -constexpr const char * kEmptyAddressIpv6 = "0000:0000:0000:0000:0000:0000:0000:0000"; +constexpr uint8_t kDnssdKeyMaxSize = 32; +constexpr char kEmptyAddressIpv6[] = "0000:0000:0000:0000:0000:0000:0000:0000"; // The number of miliseconds which must elapse without a new "found" event before // mDNS browsing is considered finished. We need this timeout because Tizen Native diff --git a/src/platform/Tizen/Logging.cpp b/src/platform/Tizen/Logging.cpp index 117059e9d15569..3153c82d05859d 100644 --- a/src/platform/Tizen/Logging.cpp +++ b/src/platform/Tizen/Logging.cpp @@ -34,7 +34,7 @@ namespace Platform { */ void ENFORCE_FORMAT(3, 0) LogV(const char * module, uint8_t category, const char * msg, va_list v) { - constexpr const char * kLogTag = "CHIP"; + constexpr char kLogTag[] = "CHIP"; char msgBuf[CHIP_CONFIG_LOG_MESSAGE_MAX_SIZE] = { 0, }; diff --git a/src/platform/android/DnssdImpl.cpp b/src/platform/android/DnssdImpl.cpp index 1a507013a22d85..c468eb5e3b59d0 100644 --- a/src/platform/android/DnssdImpl.cpp +++ b/src/platform/android/DnssdImpl.cpp @@ -53,8 +53,8 @@ jmethodID sRemoveServicesMethod = nullptr; // Implementation of functions declared in lib/dnssd/platform/Dnssd.h -constexpr const char * kProtocolTcp = "._tcp"; -constexpr const char * kProtocolUdp = "._udp"; +constexpr char kProtocolTcp[] = "._tcp"; +constexpr char kProtocolUdp[] = "._udp"; CHIP_ERROR ChipDnssdInit(DnssdAsyncReturnCallback initCallback, DnssdAsyncReturnCallback errorCallback, void * context) { diff --git a/src/platform/bouffalolab/common/BLConfig.h b/src/platform/bouffalolab/common/BLConfig.h index 50078facffa218..bb9f57fd01b639 100644 --- a/src/platform/bouffalolab/common/BLConfig.h +++ b/src/platform/bouffalolab/common/BLConfig.h @@ -34,48 +34,48 @@ class BLConfig /** Key definitions for well-known keys */ /** Manufacturing config keys, which should be saved in a specified place */ - static constexpr const char * kConfigKey_SerialNum = ("serial-num"); - static constexpr const char * kConfigKey_MfrDeviceId = ("device-id"); - static constexpr const char * kConfigKey_MfrDeviceCert = ("device-cert"); - static constexpr const char * kConfigKey_MfrDeviceICACerts = ("device-ca-certs"); - static constexpr const char * kConfigKey_MfrDevicePrivateKey = ("device-key"); - static constexpr const char * kConfigKey_ManufacturingDate = ("mfg-date"); - static constexpr const char * kConfigKey_SetupPinCode = ("pin-code"); - static constexpr const char * kConfigKey_SetupDiscriminator = ("discriminator"); - static constexpr const char * kConfigKey_Spake2pIterationCount = ("iteration-count"); - static constexpr const char * kConfigKey_Spake2pSalt = ("salt"); - static constexpr const char * kConfigKey_Spake2pVerifier = ("verifier"); - static constexpr const char * kConfigKey_UniqueId = ("unique-id"); + static constexpr char kConfigKey_SerialNum[] = ("serial-num"); + static constexpr char kConfigKey_MfrDeviceId[] = ("device-id"); + static constexpr char kConfigKey_MfrDeviceCert[] = ("device-cert"); + static constexpr char kConfigKey_MfrDeviceICACerts[] = ("device-ca-certs"); + static constexpr char kConfigKey_MfrDevicePrivateKey[] = ("device-key"); + static constexpr char kConfigKey_ManufacturingDate[] = ("mfg-date"); + static constexpr char kConfigKey_SetupPinCode[] = ("pin-code"); + static constexpr char kConfigKey_SetupDiscriminator[] = ("discriminator"); + static constexpr char kConfigKey_Spake2pIterationCount[] = ("iteration-count"); + static constexpr char kConfigKey_Spake2pSalt[] = ("salt"); + static constexpr char kConfigKey_Spake2pVerifier[] = ("verifier"); + static constexpr char kConfigKey_UniqueId[] = ("unique-id"); /** Config keys, which should be droped after a factory reset */ - static constexpr const char * kConfigKey_FabricId = ("fabric-id"); - static constexpr const char * kConfigKey_ServiceConfig = ("service-config"); - static constexpr const char * kConfigKey_PairedAccountId = ("account-id"); - static constexpr const char * kConfigKey_ServiceId = ("service-id"); - static constexpr const char * kConfigKey_FabricSecret = ("fabric-secret"); - static constexpr const char * kConfigKey_HardwareVersion = ("hardware-ver"); - static constexpr const char * kConfigKey_LastUsedEpochKeyId = ("last-ek-id"); - static constexpr const char * kConfigKey_FailSafeArmed = ("fail-safe-armed"); - static constexpr const char * kConfigKey_OperationalDeviceId = ("op-device-id"); - static constexpr const char * kConfigKey_OperationalDeviceCert = ("op-device-cert"); - static constexpr const char * kConfigKey_OperationalDeviceICACerts = ("op-device-ca-certs"); - static constexpr const char * kConfigKey_OperationalDevicePrivateKey = ("op-device-key"); - static constexpr const char * kConfigKey_RegulatoryLocation = ("regulatory-location"); - static constexpr const char * kConfigKey_CountryCode = ("country-code"); - static constexpr const char * kConfigKey_ActiveLocale = ("active-locale"); - static constexpr const char * kConfigKey_Breadcrumb = ("breadcrumb"); - static constexpr const char * kConfigKey_GroupKeyIndex = ("group-key-index"); - static constexpr const char * kConfigKey_LifeTimeCounter = ("life-time-counter"); + static constexpr char kConfigKey_FabricId[] = ("fabric-id"); + static constexpr char kConfigKey_ServiceConfig[] = ("service-config"); + static constexpr char kConfigKey_PairedAccountId[] = ("account-id"); + static constexpr char kConfigKey_ServiceId[] = ("service-id"); + static constexpr char kConfigKey_FabricSecret[] = ("fabric-secret"); + static constexpr char kConfigKey_HardwareVersion[] = ("hardware-ver"); + static constexpr char kConfigKey_LastUsedEpochKeyId[] = ("last-ek-id"); + static constexpr char kConfigKey_FailSafeArmed[] = ("fail-safe-armed"); + static constexpr char kConfigKey_OperationalDeviceId[] = ("op-device-id"); + static constexpr char kConfigKey_OperationalDeviceCert[] = ("op-device-cert"); + static constexpr char kConfigKey_OperationalDeviceICACerts[] = ("op-device-ca-certs"); + static constexpr char kConfigKey_OperationalDevicePrivateKey[] = ("op-device-key"); + static constexpr char kConfigKey_RegulatoryLocation[] = ("regulatory-location"); + static constexpr char kConfigKey_CountryCode[] = ("country-code"); + static constexpr char kConfigKey_ActiveLocale[] = ("active-locale"); + static constexpr char kConfigKey_Breadcrumb[] = ("breadcrumb"); + static constexpr char kConfigKey_GroupKeyIndex[] = ("group-key-index"); + static constexpr char kConfigKey_LifeTimeCounter[] = ("life-time-counter"); - static constexpr const char * kConfigKey_WiFiSSID = ("bl-wifi-ssid"); - static constexpr const char * kConfigKey_WiFiPassword = ("bl-wifi-pass"); + static constexpr char kConfigKey_WiFiSSID[] = ("bl-wifi-ssid"); + static constexpr char kConfigKey_WiFiPassword[] = ("bl-wifi-pass"); /** Counter Keys, diagnostic information */ - static constexpr const char * kCounterKey_RebootCount = ("reboot-count"); - static constexpr const char * kCounterKey_TotalOperationalHours = ("total-hours"); - static constexpr const char * kCounterKey_UpTime = ("up-time"); + static constexpr char kCounterKey_RebootCount[] = ("reboot-count"); + static constexpr char kCounterKey_TotalOperationalHours[] = ("total-hours"); + static constexpr char kCounterKey_UpTime[] = ("up-time"); - static constexpr const char * kBLKey_factoryResetFlag = ("__factory_reset_pending"); + static constexpr char kBLKey_factoryResetFlag[] = ("__factory_reset_pending"); static void Init(void); diff --git a/src/platform/mt793x/DnssdImpl.cpp b/src/platform/mt793x/DnssdImpl.cpp index 12cdda0a794742..f85007689f7652 100644 --- a/src/platform/mt793x/DnssdImpl.cpp +++ b/src/platform/mt793x/DnssdImpl.cpp @@ -52,9 +52,9 @@ extern void mDNSPlatformWriteLogRedirect(void (*)(const char *, const char *)); } namespace { -constexpr const char * kLocalDot = "local."; -constexpr const char * kProtocolTcp = "._tcp"; -constexpr const char * kProtocolUdp = "._udp"; +constexpr char kLocalDot[] = "local."; +constexpr char kProtocolTcp[] = "._tcp"; +constexpr char kProtocolUdp[] = "._udp"; static constexpr uint32_t kTimeoutMilli = 3000; static constexpr size_t kMaxResults = 20; diff --git a/src/platform/mt793x/KeyValueStoreManagerImpl.h b/src/platform/mt793x/KeyValueStoreManagerImpl.h index ee811358df7430..f572f0e27bf72d 100644 --- a/src/platform/mt793x/KeyValueStoreManagerImpl.h +++ b/src/platform/mt793x/KeyValueStoreManagerImpl.h @@ -78,7 +78,7 @@ class KeyValueStoreManagerImpl final : public KeyValueStoreManager CHIP_ERROR _Put(const char * key, const void * value, size_t value_size); private: - const char * kNamespace = "CHIP_KVS"; + const char kNamespace[] = "CHIP_KVS"; static CHIP_ERROR MapNvdmStatus(nvdm_status_t nvdm_status); // ===== Members for internal use by the following friends. diff --git a/src/platform/nrfconnect/wifi/NrfWiFiDriver.h b/src/platform/nrfconnect/wifi/NrfWiFiDriver.h index d1fc765a72ac26..d0d3da1b156b0d 100644 --- a/src/platform/nrfconnect/wifi/NrfWiFiDriver.h +++ b/src/platform/nrfconnect/wifi/NrfWiFiDriver.h @@ -48,8 +48,8 @@ class NrfWiFiDriver final : public WiFiDriver public: // Define non-volatile storage keys for SSID and password. // The naming convention is aligned with DefaultStorageKeyAllocator class. - static constexpr const char * kSsidKey = "g/wi/s"; - static constexpr const char * kPassKey = "g/wi/p"; + static constexpr char kSsidKey[] = "g/wi/s"; + static constexpr char kPassKey[] = "g/wi/p"; class WiFiNetworkIterator final : public NetworkIterator { diff --git a/src/platform/tests/TestKeyValueStoreMgr.cpp b/src/platform/tests/TestKeyValueStoreMgr.cpp index 33d70713730461..d311650bb67f27 100644 --- a/src/platform/tests/TestKeyValueStoreMgr.cpp +++ b/src/platform/tests/TestKeyValueStoreMgr.cpp @@ -36,9 +36,9 @@ using namespace chip::DeviceLayer::PersistedStorage; static void TestKeyValueStoreMgr_EmptyString(nlTestSuite * inSuite, void * inContext) { - constexpr const char * kTestKey = "str_key"; - constexpr const char kTestValue[] = ""; - constexpr size_t kTestValueLen = 0; + constexpr char kTestKey[] = "str_key"; + constexpr char kTestValue[] = ""; + constexpr size_t kTestValueLen = 0; char readValue[sizeof(kTestValue)]; size_t readSize; @@ -71,8 +71,8 @@ static void TestKeyValueStoreMgr_EmptyString(nlTestSuite * inSuite, void * inCon static void TestKeyValueStoreMgr_String(nlTestSuite * inSuite, void * inContext) { - constexpr const char * kTestKey = "str_key"; - constexpr const char kTestValue[] = "test_value"; + constexpr char kTestKey[] = "str_key"; + constexpr char kTestValue[] = "test_value"; char readValue[sizeof(kTestValue)]; size_t readSize; @@ -97,7 +97,7 @@ static void TestKeyValueStoreMgr_String(nlTestSuite * inSuite, void * inContext) static void TestKeyValueStoreMgr_Uint32(nlTestSuite * inSuite, void * inContext) { - constexpr const char * kTestKey = "uint32_key"; + constexpr char kTestKey[] = "uint32_key"; constexpr const uint32_t kTestValue = 5; uint32_t readValue = UINT32_MAX; @@ -121,7 +121,7 @@ static void TestKeyValueStoreMgr_Uint32(nlTestSuite * inSuite, void * inContext) static void TestKeyValueStoreMgr_Array(nlTestSuite * inSuite, void * inContext) { - constexpr const char * kTestKey = "array_key"; + constexpr char kTestKey[] = "array_key"; constexpr uint32_t kTestValue[5] = { 1, 2, 3, 4, 5 }; uint32_t readValue[5]; @@ -153,7 +153,7 @@ static void TestKeyValueStoreMgr_Struct(nlTestSuite * inSuite, void * inContext) uint32_t value2; }; - constexpr const char * kTestKey = "struct_key"; + constexpr char kTestKey[] = "struct_key"; constexpr TestStruct kTestValue{ 1, 2 }; TestStruct readValue; @@ -180,7 +180,7 @@ static void TestKeyValueStoreMgr_Struct(nlTestSuite * inSuite, void * inContext) static void TestKeyValueStoreMgr_UpdateValue(nlTestSuite * inSuite, void * inContext) { - constexpr const char * kTestKey = "update_key"; + constexpr char kTestKey[] = "update_key"; CHIP_ERROR err; uint32_t readValue; @@ -201,8 +201,8 @@ static void TestKeyValueStoreMgr_UpdateValue(nlTestSuite * inSuite, void * inCon static void TestKeyValueStoreMgr_TooSmallBufferRead(nlTestSuite * inSuite, void * inContext) { - constexpr const char * kTestKey = "too_small_buffer_read_key"; - constexpr uint8_t kTestValue[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; + constexpr char kTestKey[] = "too_small_buffer_read_key"; + constexpr uint8_t kTestValue[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; uint8_t readValue[9]; size_t readSize; @@ -254,7 +254,7 @@ static void TestKeyValueStoreMgr_AllCharactersKey(nlTestSuite * inSuite, void * static void TestKeyValueStoreMgr_NonExistentDelete(nlTestSuite * inSuite, void * inContext) { - constexpr const char * kTestKey = "non_existent"; + constexpr char kTestKey[] = "non_existent"; CHIP_ERROR err = KeyValueStoreMgr().Delete(kTestKey); NL_TEST_ASSERT(inSuite, err == CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND); @@ -263,7 +263,7 @@ static void TestKeyValueStoreMgr_NonExistentDelete(nlTestSuite * inSuite, void * #if !defined(__ZEPHYR__) && !defined(__MBED__) static void TestKeyValueStoreMgr_MultiRead(nlTestSuite * inSuite, void * inContext) { - constexpr const char * kTestKey = "multi_key"; + constexpr char kTestKey[] = "multi_key"; constexpr uint32_t kTestValue[5] = { 1, 2, 3, 4, 5 }; CHIP_ERROR err = KeyValueStoreMgr().Put(kTestKey, kTestValue); @@ -289,8 +289,8 @@ static void TestKeyValueStoreMgr_MultiRead(nlTestSuite * inSuite, void * inConte #ifdef __ZEPHYR__ static void TestKeyValueStoreMgr_DoFactoryReset(nlTestSuite * inSuite, void * inContext) { - constexpr const char * kStrKey = "string_with_weird_chars\\=_key"; - constexpr const char * kUintKey = "some_uint_key"; + constexpr char kStrKey[] = "string_with_weird_chars\\=_key"; + constexpr char kUintKey[] = "some_uint_key"; NL_TEST_ASSERT(inSuite, KeyValueStoreMgr().Put(kStrKey, "some_string") == CHIP_NO_ERROR); NL_TEST_ASSERT(inSuite, KeyValueStoreMgr().Put(kUintKey, uint32_t(1234)) == CHIP_NO_ERROR); diff --git a/src/protocols/bdx/BdxMessages.h b/src/protocols/bdx/BdxMessages.h index 753520eab455d6..66cfe33a2bd349 100644 --- a/src/protocols/bdx/BdxMessages.h +++ b/src/protocols/bdx/BdxMessages.h @@ -35,7 +35,7 @@ namespace bdx { inline constexpr uint16_t kMaxFileDesignatorLen = 0xFF; -inline constexpr const char * kProtocolName = "BDX"; +inline constexpr char kProtocolName[] = "BDX"; enum class MessageType : uint8_t { diff --git a/src/protocols/bdx/BdxUri.h b/src/protocols/bdx/BdxUri.h index 8e072892f6fbcd..00fe0ee34be3bf 100644 --- a/src/protocols/bdx/BdxUri.h +++ b/src/protocols/bdx/BdxUri.h @@ -22,7 +22,7 @@ namespace chip { namespace bdx { -inline constexpr const char kScheme[] = "bdx://"; +inline constexpr char kScheme[] = "bdx://"; /** * Parses the URI into NodeId and File Designator diff --git a/src/protocols/echo/Echo.h b/src/protocols/echo/Echo.h index 08690e2ae45abc..3e9741f1feec29 100644 --- a/src/protocols/echo/Echo.h +++ b/src/protocols/echo/Echo.h @@ -38,7 +38,7 @@ namespace chip { namespace Protocols { namespace Echo { -inline constexpr const char * kProtocolName = "Echo"; +inline constexpr char kProtocolName[] = "Echo"; /** * Echo Protocol Message Types diff --git a/src/protocols/interaction_model/Constants.h b/src/protocols/interaction_model/Constants.h index d5b33e3f23ff2b..4b5929a9a54433 100644 --- a/src/protocols/interaction_model/Constants.h +++ b/src/protocols/interaction_model/Constants.h @@ -45,7 +45,7 @@ namespace chip { namespace Protocols { namespace InteractionModel { -inline constexpr const char * kProtocolName = "IM"; +inline constexpr char kProtocolName[] = "IM"; /** * Version of the Interaction Model used by the node. diff --git a/src/protocols/secure_channel/Constants.h b/src/protocols/secure_channel/Constants.h index f624ee63612af4..e2415ca6089353 100644 --- a/src/protocols/secure_channel/Constants.h +++ b/src/protocols/secure_channel/Constants.h @@ -43,7 +43,7 @@ namespace chip { namespace Protocols { namespace SecureChannel { -inline constexpr const char * kProtocolName = "SecureChannel"; +inline constexpr char kProtocolName[] = "SecureChannel"; /** * SecureChannel Protocol Message Types diff --git a/src/protocols/secure_channel/PASESession.cpp b/src/protocols/secure_channel/PASESession.cpp index 28979dc69e021d..da168fa7c79c95 100644 --- a/src/protocols/secure_channel/PASESession.cpp +++ b/src/protocols/secure_channel/PASESession.cpp @@ -54,9 +54,9 @@ using namespace Crypto; using namespace Messaging; using namespace Protocols::SecureChannel; -const char * kSpake2pContext = "CHIP PAKE V1 Commissioning"; -const char * kSpake2pI2RSessionInfo = "Commissioning I2R Key"; -const char * kSpake2pR2ISessionInfo = "Commissioning R2I Key"; +const char kSpake2pContext[] = "CHIP PAKE V1 Commissioning"; +const char kSpake2pI2RSessionInfo[] = "Commissioning I2R Key"; +const char kSpake2pR2ISessionInfo[] = "Commissioning R2I Key"; // Amounts of time to allow for server-side processing of messages. // diff --git a/src/protocols/secure_channel/PASESession.h b/src/protocols/secure_channel/PASESession.h index 02d8fa7d6636f8..393d3a65fc958a 100644 --- a/src/protocols/secure_channel/PASESession.h +++ b/src/protocols/secure_channel/PASESession.h @@ -41,8 +41,8 @@ namespace chip { -extern const char * kSpake2pI2RSessionInfo; -extern const char * kSpake2pR2ISessionInfo; +extern const char kSpake2pI2RSessionInfo[]; +extern const char kSpake2pR2ISessionInfo[]; inline constexpr uint16_t kPBKDFParamRandomNumberSize = 32; diff --git a/src/protocols/user_directed_commissioning/UserDirectedCommissioning.h b/src/protocols/user_directed_commissioning/UserDirectedCommissioning.h index d0d5bcd83a7c48..12315a06b29041 100644 --- a/src/protocols/user_directed_commissioning/UserDirectedCommissioning.h +++ b/src/protocols/user_directed_commissioning/UserDirectedCommissioning.h @@ -41,7 +41,7 @@ namespace chip { namespace Protocols { namespace UserDirectedCommissioning { -inline constexpr const char * kProtocolName = "UserDirectedCommissioning"; +inline constexpr char kProtocolName[] = "UserDirectedCommissioning"; // Cache contains 16 clients. This may need to be tweaked. inline constexpr uint8_t kMaxUDCClients = 16; diff --git a/src/setup_payload/tests/TestHelpers.h b/src/setup_payload/tests/TestHelpers.h index 8e83b512df26d1..17017387f5fa48 100644 --- a/src/setup_payload/tests/TestHelpers.h +++ b/src/setup_payload/tests/TestHelpers.h @@ -39,7 +39,7 @@ const uint32_t kOptionalDefaultIntValue = 12; inline constexpr char kSerialNumberDefaultStringValue[] = "123456789"; const uint32_t kSerialNumberDefaultUInt32Value = 123456789; -inline constexpr const char * kDefaultPayloadQRCode = "MT:M5L90MP500K64J00000"; +inline constexpr char kDefaultPayloadQRCode[] = "MT:M5L90MP500K64J00000"; inline SetupPayload GetDefaultPayload() { diff --git a/src/transport/TraceMessage.h b/src/transport/TraceMessage.h index 943c9c6d7de0c5..ee69538c0881b6 100644 --- a/src/transport/TraceMessage.h +++ b/src/transport/TraceMessage.h @@ -75,9 +75,9 @@ namespace chip { namespace trace { -inline constexpr const char * kTraceMessageEvent = "SecureMsg"; -inline constexpr const char * kTraceMessageSentDataFormat = "SecMsgSent"; -inline constexpr const char * kTraceMessageReceivedDataFormat = "SecMsgReceived"; +inline constexpr char kTraceMessageEvent[] = "SecureMsg"; +inline constexpr char kTraceMessageSentDataFormat[] = "SecMsgSent"; +inline constexpr char kTraceMessageReceivedDataFormat[] = "SecMsgReceived"; struct TraceSecureMessageSentData {