Skip to content

Commit

Permalink
clang-tidy: Apply fixes "readability-avoid-const-params-in-decls" (#3084
Browse files Browse the repository at this point in the history
)

Declaring passed-by-value parameters const has no effect in a declaration.
  • Loading branch information
mspang authored Oct 6, 2020
1 parent a0525ed commit 8a532d6
Show file tree
Hide file tree
Showing 17 changed files with 41 additions and 43 deletions.
2 changes: 1 addition & 1 deletion src/ble/BleConnectionDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class DLL_EXPORT BleConnectionDelegate

// Call this function to delegate the connection steps required to get a BLE_CONNECTION_OBJECT
// out of a peripheral discriminator.
virtual void NewConnection(BleLayer * bleLayer, void * appState, const uint16_t connDiscriminator) = 0;
virtual void NewConnection(BleLayer * bleLayer, void * appState, uint16_t connDiscriminator) = 0;
};

} /* namespace Ble */
Expand Down
2 changes: 1 addition & 1 deletion src/ble/BleLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ class DLL_EXPORT BleLayer
BleApplicationDelegate * appDelegate, chip::System::Layer * systemLayer);
BLE_ERROR Shutdown();

BLE_ERROR NewBleConnection(void * appState, const uint16_t connDiscriminator,
BLE_ERROR NewBleConnection(void * appState, uint16_t connDiscriminator,
BleConnectionDelegate::OnConnectionCompleteFunct onConnectionComplete,
BleConnectionDelegate::OnConnectionErrorFunct onConnectionError);
BLE_ERROR NewBleEndPoint(BLEEndPoint ** retEndPoint, BLE_CONNECTION_OBJECT connObj, BleRole role, bool autoClose);
Expand Down
24 changes: 12 additions & 12 deletions src/crypto/CHIPCryptoPAL.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ class P256PublicKey : public ECPKey<P256ECDSASignature>
size_t Length() const override { return kP256_PublicKey_Length; }
operator uint8_t *() const override { return (uint8_t *) bytes; }

CHIP_ERROR ECDSA_validate_msg_signature(const uint8_t * msg, const size_t msg_length,
CHIP_ERROR ECDSA_validate_msg_signature(const uint8_t * msg, size_t msg_length,
const P256ECDSASignature & signature) const override;

private:
Expand All @@ -188,7 +188,7 @@ class ECPKeypair
*represented as ASN.1 DER integers, plus the ASN.1 sequence Header
* @return Returns a CHIP_ERROR on error, CHIP_NO_ERROR otherwise
**/
virtual CHIP_ERROR ECDSA_sign_msg(const uint8_t * msg, const size_t msg_length, Sig & out_signature) = 0;
virtual CHIP_ERROR ECDSA_sign_msg(const uint8_t * msg, size_t msg_length, Sig & out_signature) = 0;

/** @brief A function to derive a shared secret using ECDH
* @param remote_public_key Public key of remote peer with which we are trying to establish secure channel. remote_public_key is
Expand Down Expand Up @@ -246,7 +246,7 @@ class P256Keypair : public ECPKeypair<P256PublicKey, P256ECDHDerivedSecret, P256
*represented as ASN.1 DER integers, plus the ASN.1 sequence Header
* @return Returns a CHIP_ERROR on error, CHIP_NO_ERROR otherwise
**/
CHIP_ERROR ECDSA_sign_msg(const uint8_t * msg, const size_t msg_length, P256ECDSASignature & out_signature) override;
CHIP_ERROR ECDSA_sign_msg(const uint8_t * msg, size_t msg_length, P256ECDSASignature & out_signature) override;

/** @brief A function to derive a shared secret using ECDH
* @param remote_public_key Public key of remote peer with which we are trying to establish secure channel. remote_public_key is
Expand Down Expand Up @@ -314,7 +314,7 @@ CHIP_ERROR AES_CCM_decrypt(const uint8_t * ciphertext, size_t ciphertext_length,
* @return Returns a CHIP_ERROR on error, CHIP_NO_ERROR otherwise
**/

CHIP_ERROR Hash_SHA256(const uint8_t * data, const size_t data_length, uint8_t * out_buffer);
CHIP_ERROR Hash_SHA256(const uint8_t * data, size_t data_length, uint8_t * out_buffer);

/**
* @brief A class that defines stream based implementation of SHA-256 hash
Expand All @@ -332,7 +332,7 @@ class Hash_SHA256_stream
~Hash_SHA256_stream();

CHIP_ERROR Begin();
CHIP_ERROR AddData(const uint8_t * data, const size_t data_length);
CHIP_ERROR AddData(const uint8_t * data, size_t data_length);
CHIP_ERROR Finish(uint8_t * out_buffer);
void Clear();

Expand All @@ -353,16 +353,16 @@ class Hash_SHA256_stream
* @return Returns a CHIP_ERROR on error, CHIP_NO_ERROR otherwise
**/

CHIP_ERROR HKDF_SHA256(const uint8_t * secret, const size_t secret_length, const uint8_t * salt, const size_t salt_length,
const uint8_t * info, const size_t info_length, uint8_t * out_buffer, size_t out_length);
CHIP_ERROR HKDF_SHA256(const uint8_t * secret, size_t secret_length, const uint8_t * salt, size_t salt_length, const uint8_t * info,
size_t info_length, uint8_t * out_buffer, size_t out_length);

/**
* @brief A cryptographically secure random number generator based on NIST SP800-90A
* @param out_buffer Buffer to write random bytes into
* @param out_length Number of random bytes to generate
* @return Returns a CHIP_ERROR on error, CHIP_NO_ERROR otherwise
**/
CHIP_ERROR DRBG_get_bytes(uint8_t * out_buffer, const size_t out_length);
CHIP_ERROR DRBG_get_bytes(uint8_t * out_buffer, size_t out_length);

/** @brief Entropy callback function
* @param data Callback-specific data pointer
Expand Down Expand Up @@ -747,8 +747,8 @@ class Spake2p
*
* @return Returns a CHIP_ERROR when the MAC doesn't validate, CHIP_NO_ERROR otherwise.
**/
virtual CHIP_ERROR KDF(const uint8_t * ikm, const size_t ikm_len, const uint8_t * salt, const size_t salt_len,
const uint8_t * info, const size_t info_len, uint8_t * out, size_t out_len) = 0;
virtual CHIP_ERROR KDF(const uint8_t * ikm, size_t ikm_len, const uint8_t * salt, size_t salt_len, const uint8_t * info,
size_t info_len, uint8_t * out, size_t out_len) = 0;

CHIP_SPAKE2P_ROLE role;
CHIP_SPAKE2P_STATE state;
Expand Down Expand Up @@ -799,8 +799,8 @@ class Spake2p_P256_SHA256_HKDF_HMAC : public Spake2p
CHIP_ERROR InitImpl() override;
CHIP_ERROR Hash(const uint8_t * in, size_t in_len) override;
CHIP_ERROR HashFinalize(uint8_t * out) override;
CHIP_ERROR KDF(const uint8_t * secret, const size_t secret_length, const uint8_t * salt, const size_t salt_length,
const uint8_t * info, const size_t info_length, uint8_t * out, size_t out_length) override;
CHIP_ERROR KDF(const uint8_t * secret, size_t secret_length, const uint8_t * salt, size_t salt_length, const uint8_t * info,
size_t info_length, uint8_t * out, size_t out_length) override;

private:
/**
Expand Down
4 changes: 2 additions & 2 deletions src/include/platform/SoftwareUpdateManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -295,12 +295,12 @@ class SoftwareUpdateManager
CHIP_ERROR CheckNow();
CHIP_ERROR ImageInstallComplete(CHIP_ERROR aError);
CHIP_ERROR PrepareImageStorageComplete(CHIP_ERROR aError);
CHIP_ERROR SetEventCallback(void * const aAppState, const EventCallback aEventCallback);
CHIP_ERROR SetEventCallback(void * aAppState, EventCallback aEventCallback);
CHIP_ERROR SetQueryIntervalWindow(uint32_t aMinWaitTimeMs, uint32_t aMaxWaitTimeMs);

bool IsInProgress();

void SetRetryPolicyCallback(const RetryPolicyCallback aRetryPolicyCallback);
void SetRetryPolicyCallback(RetryPolicyCallback aRetryPolicyCallback);

State GetState();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class GenericSoftwareUpdateManagerImpl
bool _IsInProgress();
SoftwareUpdateManager::State _GetState();

void _SetRetryPolicyCallback(const SoftwareUpdateManager::RetryPolicyCallback aRetryPolicyCallback);
void _SetRetryPolicyCallback(SoftwareUpdateManager::RetryPolicyCallback aRetryPolicyCallback);

static void _DefaultEventHandler(void * apAppState, SoftwareUpdateManager::EventType aEvent,
const SoftwareUpdateManager::InEventParam & aInParam,
Expand All @@ -64,7 +64,7 @@ class GenericSoftwareUpdateManagerImpl
CHIP_ERROR _PrepareImageStorageComplete(CHIP_ERROR aError);
CHIP_ERROR _ImageInstallComplete(CHIP_ERROR aError);
CHIP_ERROR _SetQueryIntervalWindow(uint32_t aMinWaitTimeMs, uint32_t aMaxWaitTimeMs);
CHIP_ERROR _SetEventCallback(void * const aAppState, const SoftwareUpdateManager::EventCallback aEventCallback);
CHIP_ERROR _SetEventCallback(void * aAppState, SoftwareUpdateManager::EventCallback aEventCallback);

// ===== Members for use by the implementation subclass.

Expand Down Expand Up @@ -96,7 +96,7 @@ class GenericSoftwareUpdateManagerImpl
static void PrepareBinding(intptr_t arg);
static void StartDownload(intptr_t arg);
static void HandleHoldOffTimerExpired(::chip::System::Layer * aLayer, void * aAppState, ::chip::System::Error aError);
static void DefaultRetryPolicyCallback(void * const aAppState, SoftwareUpdateManager::RetryParam & aRetryParam,
static void DefaultRetryPolicyCallback(void * aAppState, SoftwareUpdateManager::RetryParam & aRetryParam,
uint32_t & aOutIntervalMsec);

private:
Expand Down
2 changes: 1 addition & 1 deletion src/inet/TCPEndPoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ class DLL_EXPORT TCPEndPoint : public EndPointBasis
*/
bool IsConnected() const;

void SetConnectTimeout(const uint32_t connTimeoutMsecs);
void SetConnectTimeout(uint32_t connTimeoutMsecs);

#if INET_TCP_IDLE_CHECK_INTERVAL > 0
/**
Expand Down
4 changes: 2 additions & 2 deletions src/lib/core/CHIPTLVDebug.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ struct DumpContext
void * mContext;
};

extern const char * DecodeType(const TLVType aType);
extern const char * DecodeType(TLVType aType);

extern const char * DecodeTagControl(const TLVTagControl aTagControl);
extern const char * DecodeTagControl(TLVTagControl aTagControl);

extern CHIP_ERROR DumpIterator(DumpWriter aWriter, const TLVReader & aReader);

Expand Down
9 changes: 4 additions & 5 deletions src/lib/core/CHIPTLVUtilities.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,16 @@ namespace Utilities {
typedef CHIP_ERROR (*IterateHandler)(const TLVReader & aReader, size_t aDepth, void * aContext);

extern CHIP_ERROR Iterate(const TLVReader & aReader, IterateHandler aHandler, void * aContext);
extern CHIP_ERROR Iterate(const TLVReader & aReader, IterateHandler aHandler, void * aContext, const bool aRecurse);
extern CHIP_ERROR Iterate(const TLVReader & aReader, IterateHandler aHandler, void * aContext, bool aRecurse);

extern CHIP_ERROR Count(const TLVReader & aReader, size_t & aCount);
extern CHIP_ERROR Count(const TLVReader & aReader, size_t & aCount, const bool aRecurse);
extern CHIP_ERROR Count(const TLVReader & aReader, size_t & aCount, bool aRecurse);

extern CHIP_ERROR Find(const TLVReader & aReader, const uint64_t & aTag, TLVReader & aResult);
extern CHIP_ERROR Find(const TLVReader & aReader, const uint64_t & aTag, TLVReader & aResult, const bool aRecurse);
extern CHIP_ERROR Find(const TLVReader & aReader, const uint64_t & aTag, TLVReader & aResult, bool aRecurse);

extern CHIP_ERROR Find(const TLVReader & aReader, IterateHandler aHandler, void * aContext, TLVReader & aResult);
extern CHIP_ERROR Find(const TLVReader & aReader, IterateHandler aHandler, void * aContext, TLVReader & aResult,
const bool aRecurse);
extern CHIP_ERROR Find(const TLVReader & aReader, IterateHandler aHandler, void * aContext, TLVReader & aResult, bool aRecurse);
} // namespace Utilities

} // namespace TLV
Expand Down
5 changes: 2 additions & 3 deletions src/lib/message/CHIPBinding.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,7 @@ class Binding

static void DefaultEventHandler(void * apAppState, EventType aEvent, const InEventParam & aInParam, OutEventParam & aOutParam);

CHIP_ERROR AllocateRightSizedBuffer(PacketBuffer *& buf, const uint32_t desiredSize, const uint32_t minSize,
uint32_t & outMaxPayloadSize);
CHIP_ERROR AllocateRightSizedBuffer(PacketBuffer *& buf, uint32_t desiredSize, uint32_t minSize, uint32_t & outMaxPayloadSize);

private:
friend class ChipExchangeManager;
Expand Down Expand Up @@ -326,7 +325,7 @@ class Binding
static void OnSecureSessionFailed(ChipSecurityManager * sm, ChipConnection * con, void * reqState, CHIP_ERROR localErr,
uint64_t peerNodeId, Protocols::StatusReporting::StatusReport * statusReport);
void OnSecureSessionReady(uint64_t peerNodeId, uint8_t encType, ChipAuthMode authMode, uint16_t keyId);
void OnKeyError(const uint32_t aKeyId, const uint64_t aPeerNodeId, const CHIP_ERROR aKeyErr);
void OnKeyError(uint32_t aKeyId, uint64_t aPeerNodeId, CHIP_ERROR aKeyErr);

static void OnResolveComplete(void * appState, INET_ERROR err, uint8_t addrCount, Inet::IPAddress * addrArray);
static void OnConnectionComplete(ChipConnection * con, CHIP_ERROR conErr);
Expand Down
2 changes: 1 addition & 1 deletion src/lib/message/CHIPExchangeMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ class DLL_EXPORT ChipExchangeManager
void InitBindingPool();
Binding * AllocBinding();
void FreeBinding(Binding * binding);
uint16_t GetBindingLogId(const Binding * const binding) const;
uint16_t GetBindingLogId(const Binding * binding) const;

void NotifySecurityManagerAvailable();
void NotifyKeyFailed(uint64_t peerNodeId, uint16_t keyId, CHIP_ERROR keyErr);
Expand Down
2 changes: 1 addition & 1 deletion src/lib/message/CHIPMessageLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ class ChipConnection

void Abort();

void SetConnectTimeout(const uint32_t connTimeoutMsecs);
void SetConnectTimeout(uint32_t connTimeoutMsecs);

CHIP_ERROR SetIdleTimeout(uint32_t timeoutMS);

Expand Down
2 changes: 1 addition & 1 deletion src/lib/support/PersistedCounter.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class PersistedCounter : public MonotonicallyIncreasingCounter
* CHIP_ERROR_INVALID_INTEGER_VALUE if aEpoch is 0.
* CHIP_NO_ERROR otherwise
*/
CHIP_ERROR Init(const chip::Platform::PersistedStorage::Key aId, uint32_t aEpoch);
CHIP_ERROR Init(chip::Platform::PersistedStorage::Key aId, uint32_t aEpoch);

/**
* @brief
Expand Down
2 changes: 1 addition & 1 deletion src/platform/Linux/BLEManagerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ class BLEManagerImpl final : public BLEManager,

// ===== Members that implement virtual methods on BleConnectionDelegate.

void NewConnection(BleLayer * bleLayer, void * appState, const uint16_t connDiscriminator) override;
void NewConnection(BleLayer * bleLayer, void * appState, uint16_t connDiscriminator) override;

// ===== Members for internal use by the following friends.

Expand Down
2 changes: 1 addition & 1 deletion src/system/SystemLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class DLL_EXPORT Layer
Error NewTimer(Timer *& aTimerPtr);

void StartTimer(uint32_t aMilliseconds, chip::Callback::Callback<> * aCallback);
void DispatchTimerCallbacks(const uint64_t kCurrentEpoch);
void DispatchTimerCallbacks(uint64_t kCurrentEpoch);

typedef void (*TimerCompleteFunct)(Layer * aLayer, void * aAppState, Error aError);
Error StartTimer(uint32_t aMilliseconds, TimerCompleteFunct aComplete, void * aAppState);
Expand Down
2 changes: 1 addition & 1 deletion src/transport/BLE.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class DLL_EXPORT BLE : public Base

private:
CHIP_ERROR InitInternal(BLE_CONNECTION_OBJECT connObj);
CHIP_ERROR DelegateConnection(const uint16_t connDiscriminator);
CHIP_ERROR DelegateConnection(uint16_t connDiscriminator);
void SetupEvents(Ble::BLEEndPoint * endPoint);

/**
Expand Down
8 changes: 4 additions & 4 deletions src/transport/SecureSession.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class DLL_EXPORT SecureSession
* @return CHIP_ERROR The result of key derivation
*/
CHIP_ERROR Init(const Crypto::P256Keypair & local_keypair, const Crypto::P256PublicKey & remote_public_key,
const uint8_t * salt, const size_t salt_length, const uint8_t * info, const size_t info_length);
const uint8_t * salt, size_t salt_length, const uint8_t * info, size_t info_length);

/**
* @brief
Expand All @@ -70,8 +70,8 @@ class DLL_EXPORT SecureSession
* @param info_length Length of the initial info
* @return CHIP_ERROR The result of key derivation
*/
CHIP_ERROR InitFromSecret(const uint8_t * secret, const size_t secret_length, const uint8_t * salt, const size_t salt_length,
const uint8_t * info, const size_t info_length);
CHIP_ERROR InitFromSecret(const uint8_t * secret, size_t secret_length, const uint8_t * salt, size_t salt_length,
const uint8_t * info, size_t info_length);

/**
* @brief
Expand Down Expand Up @@ -129,7 +129,7 @@ class DLL_EXPORT SecureSession
// Use unencrypted header as additional authenticated data (AAD) during encryption and decryption.
// The encryption operations includes AAD when message authentication tag is generated. This tag
// is used at the time of decryption to integrity check the received data.
static CHIP_ERROR GetAdditionalAuthData(const PacketHeader & header, const Header::Flags payloadEncodeFlags, uint8_t * aad,
static CHIP_ERROR GetAdditionalAuthData(const PacketHeader & header, Header::Flags payloadEncodeFlags, uint8_t * aad,
size_t & len);
};

Expand Down
6 changes: 3 additions & 3 deletions src/transport/raw/MessageHeader.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ class PacketHeader
* CHIP_ERROR_INVALID_ARGUMENT on insufficient buffer size
* CHIP_ERROR_VERSION_MISMATCH if header version is not supported.
*/
CHIP_ERROR Decode(const uint8_t * const data, size_t size, uint16_t * decode_size);
CHIP_ERROR Decode(const uint8_t * data, size_t size, uint16_t * decode_size);

/**
* Encodes a header into the given buffer.
Expand Down Expand Up @@ -374,7 +374,7 @@ class PayloadHeader
* CHIP_ERROR_INVALID_ARGUMENT on insufficient buffer size
* CHIP_ERROR_VERSION_MISMATCH if header version is not supported.
*/
CHIP_ERROR Decode(Header::Flags flags, const uint8_t * const data, size_t size, uint16_t * decode_size);
CHIP_ERROR Decode(Header::Flags flags, const uint8_t * data, size_t size, uint16_t * decode_size);

/**
* Encodes the encrypted part of the header into the given buffer.
Expand Down Expand Up @@ -445,7 +445,7 @@ class MessageAuthenticationCode
* CHIP_ERROR_INVALID_ARGUMENT on insufficient buffer size
* CHIP_ERROR_VERSION_MISMATCH if header version is not supported.
*/
CHIP_ERROR Decode(const PacketHeader & packetHeader, const uint8_t * const data, size_t size, uint16_t * decode_size);
CHIP_ERROR Decode(const PacketHeader & packetHeader, const uint8_t * data, size_t size, uint16_t * decode_size);

/**
* Encodes the Messae Authentication Tag into the given buffer.
Expand Down

0 comments on commit 8a532d6

Please sign in to comment.