Skip to content

Commit 7cbc0e3

Browse files
committed
BLE: Clang tidy on public headers.
1 parent 0baa92d commit 7cbc0e3

35 files changed

+199
-205
lines changed

connectivity/FEATURE_BLE/include/ble/BLE.h

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,10 @@ class BLE {
154154
*/
155155
static const InstanceID_t NUM_INSTANCES = 1;
156156

157+
// Prevent copy construction and copy assignment of BLE.
158+
BLE(const BLE &) = delete;
159+
BLE &operator=(const BLE &) = delete;
160+
157161
/**
158162
* Get a reference to the BLE singleton.
159163
*
@@ -193,7 +197,7 @@ class BLE {
193197
*/
194198
MBED_DEPRECATED_SINCE("mbed-os-6.3.0", "BLE singleton supports one instance. You may create multiple"
195199
"instances by using the constructor.")
196-
InstanceID_t getInstanceID(void) const
200+
InstanceID_t getInstanceID() const
197201
{
198202
return DEFAULT_INSTANCE;
199203
}
@@ -299,7 +303,7 @@ class BLE {
299303
* @attention This should be called before using anything else in the BLE
300304
* API.
301305
*/
302-
ble_error_t init(InitializationCompleteCallback_t completion_cb = NULL)
306+
ble_error_t init(InitializationCompleteCallback_t completion_cb = nullptr)
303307
{
304308
FunctionPointerWithContext<InitializationCompleteCallbackContext *> callback(completion_cb);
305309
return initImplementation(callback);
@@ -331,7 +335,7 @@ class BLE {
331335
* @note The application should set up a callback to signal completion of
332336
* initialization when using init().
333337
*/
334-
bool hasInitialized(void) const;
338+
bool hasInitialized() const;
335339

336340
/**
337341
* Shut down the underlying stack, and reset state of this BLE instance.
@@ -343,7 +347,7 @@ class BLE {
343347
* GAP state. This API offers a way to repopulate the GATT database with new
344348
* services and characteristics.
345349
*/
346-
ble_error_t shutdown(void);
350+
ble_error_t shutdown();
347351

348352
/**
349353
* This call allows the application to get the BLE stack version information.
@@ -352,7 +356,7 @@ class BLE {
352356
*
353357
* @note The BLE API owns the string returned.
354358
*/
355-
const char *getVersion(void);
359+
const char *getVersion();
356360

357361
/**
358362
* Accessor to Gap. All Gap-related functionality requires going through
@@ -465,11 +469,6 @@ class BLE {
465469
FunctionPointerWithContext<InitializationCompleteCallbackContext *> callback
466470
);
467471

468-
private:
469-
// Prevent copy construction and copy assignment of BLE.
470-
BLE(const BLE &) = delete;
471-
BLE &operator=(const BLE &) = delete;
472-
473472
private:
474473
ble::BLEInstanceBase &transport; /* The device-specific backend */
475474
OnEventsToProcessCallback_t whenEventsToProcess;

connectivity/FEATURE_BLE/include/ble/Gap.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -549,9 +549,7 @@ class Gap {
549549
* Prevent polymorphic deletion and avoid unnecessary virtual destructor
550550
* as the Gap class will never delete the instance it contains.
551551
*/
552-
~EventHandler()
553-
{
554-
}
552+
~EventHandler() = default;
555553
};
556554

557555
/**
@@ -1316,7 +1314,7 @@ class Gap {
13161314
*
13171315
* @return Maximum size of the whitelist.
13181316
*/
1319-
uint8_t getMaxWhitelistSize(void) const;
1317+
uint8_t getMaxWhitelistSize() const;
13201318

13211319
/**
13221320
* Get the Link Layer to use the internal whitelist when scanning,
@@ -1379,7 +1377,7 @@ class Gap {
13791377
* the address in input was not identifiable as a random address.
13801378
*/
13811379
static ble_error_t getRandomAddressType(
1382-
const ble::address_t address,
1380+
ble::address_t address,
13831381
ble::random_address_type_t *addressType
13841382
);
13851383

@@ -1401,7 +1399,7 @@ class Gap {
14011399
* @note Currently, a call to reset() does not reset the advertising and
14021400
* scan parameters to default values.
14031401
*/
1404-
ble_error_t reset(void);
1402+
ble_error_t reset();
14051403

14061404
/**
14071405
* Register a Gap shutdown event handler.

connectivity/FEATURE_BLE/include/ble/GattClient.h

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,7 @@ class GattClient {
120120
* Prevent polymorphic deletion and avoid unnecessary virtual destructor
121121
* as the GattClient class will never delete the instance it contains.
122122
*/
123-
~EventHandler()
124-
{
125-
}
123+
~EventHandler() = default;
126124
};
127125

128126
/**
@@ -235,7 +233,7 @@ class GattClient {
235233
* specific subclass.
236234
*/
237235

238-
~GattClient() { }
236+
~GattClient() = default;
239237

240238
/**
241239
* Launch the service and characteristic discovery procedure of a GATT server
@@ -289,8 +287,8 @@ class GattClient {
289287
*/
290288
ble_error_t launchServiceDiscovery(
291289
ble::connection_handle_t connectionHandle,
292-
ServiceDiscovery::ServiceCallback_t sc = NULL,
293-
ServiceDiscovery::CharacteristicCallback_t cc = NULL,
290+
ServiceDiscovery::ServiceCallback_t sc = nullptr,
291+
ServiceDiscovery::CharacteristicCallback_t cc = nullptr,
294292
const UUID &matchingServiceUUID = UUID::ShortUUIDBytes_t(BLE_UUID_UNKNOWN),
295293
const UUID &matchingCharacteristicUUIDIn = UUID::ShortUUIDBytes_t(BLE_UUID_UNKNOWN)
296294
);
@@ -368,15 +366,15 @@ class GattClient {
368366
*
369367
* @return true if service discovery procedure is active and false otherwise.
370368
*/
371-
bool isServiceDiscoveryActive(void) const;
369+
bool isServiceDiscoveryActive() const;
372370

373371
/**
374372
* Terminate all ongoing service discovery procedures.
375373
*
376374
* It results in an invocation of the service discovery termination handler
377375
* registered with onServiceDiscoveryTermination().
378376
*/
379-
void terminateServiceDiscovery(void);
377+
void terminateServiceDiscovery();
380378

381379
/**
382380
* Initiate the read procedure of an attribute handle.
@@ -627,7 +625,10 @@ class GattClient {
627625
* available.
628626
*/
629627
template <typename T>
630-
void onShutdown(T *objPtr, void (T::*memberPtr)(const GattClient *));
628+
void onShutdown(T *objPtr, void (T::*memberPtr)(const GattClient *))
629+
{
630+
onShutdown({objPtr, memberPtr});
631+
}
631632

632633
/**
633634
* Get the callchain of shutdown event handlers.
@@ -668,7 +669,7 @@ class GattClient {
668669
*
669670
* @return BLE_ERROR_NONE on success.
670671
*/
671-
ble_error_t reset(void);
672+
ble_error_t reset();
672673

673674
/* Entry points for the underlying stack to report events back to the user. */
674675

connectivity/FEATURE_BLE/include/ble/GattServer.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,7 @@ class GattServer {
126126
* Prevent polymorphic deletion and avoid unnecessary virtual destructor
127127
* as the GattServer class will never delete the instance it contains.
128128
*/
129-
~EventHandler()
130-
{
131-
}
129+
~EventHandler() = default;
132130
};
133131

134132
/**
@@ -224,7 +222,7 @@ class GattServer {
224222
*
225223
* @return BLE_ERROR_NONE on success.
226224
*/
227-
ble_error_t reset(void);
225+
ble_error_t reset();
228226

229227
/**
230228
* Add a service declaration to the local attribute server table.

connectivity/FEATURE_BLE/include/ble/SecurityManager.h

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#ifndef BLE_SECURITY_MANAGER_H_
2020
#define BLE_SECURITY_MANAGER_H_
2121

22-
#include <stdint.h>
22+
#include <cstdint>
2323
#include "ble/common/CallChainOfFunctionPointersWithContext.h"
2424
#include "platform/Callback.h"
2525

@@ -421,9 +421,7 @@ class SecurityManager
421421
* Prevent polymorphic deletion and avoid unnecessary virtual destructor
422422
* as the SecurityManager class will never delete the instance it contains.
423423
*/
424-
~EventHandler()
425-
{
426-
}
424+
~EventHandler() = default;
427425
};
428426

429427
/*
@@ -457,9 +455,9 @@ class SecurityManager
457455
bool enableBonding = true,
458456
bool requireMITM = true,
459457
SecurityIOCapabilities_t iocaps = IO_CAPS_NONE,
460-
const Passkey_t passkey = NULL,
458+
const Passkey_t passkey = nullptr,
461459
bool signing = true,
462-
const char *dbFilepath = NULL
460+
const char *dbFilepath = nullptr
463461
);
464462

465463
/**
@@ -473,7 +471,7 @@ class SecurityManager
473471
*
474472
* @return BLE_ERROR_NONE on success.
475473
*/
476-
ble_error_t setDatabaseFilepath(const char *dbFilepath = NULL);
474+
ble_error_t setDatabaseFilepath(const char *dbFilepath = nullptr);
477475

478476
/**
479477
* Notify all registered onShutdown callbacks that the SecurityManager is
@@ -488,7 +486,7 @@ class SecurityManager
488486
*
489487
* @return BLE_ERROR_NONE on success.
490488
*/
491-
ble_error_t reset(void);
489+
ble_error_t reset();
492490

493491
/**
494492
* Normally all bonding information is lost when device is reset, this requests that the stack
@@ -511,7 +509,7 @@ class SecurityManager
511509
* @retval BLE_ERROR_INVALID_STATE If the API is called without module initialization or
512510
* application registration.
513511
*/
514-
ble_error_t purgeAllBondingState(void);
512+
ble_error_t purgeAllBondingState();
515513

516514
/**
517515
* Create a list of addresses from all peers in the bond table and generate
@@ -870,7 +868,10 @@ class SecurityManager
870868
void onShutdown(const SecurityManagerShutdownCallback_t& callback);
871869

872870
template <typename T>
873-
void onShutdown(T *objPtr, void (T::*memberPtr)(const SecurityManager *));
871+
void onShutdown(T *objPtr, void (T::*memberPtr)(const SecurityManager *))
872+
{
873+
onShutdown({objPtr, memberPtr});
874+
}
874875

875876
/**
876877
* Provide access to the callchain of shutdown event callbacks.

connectivity/FEATURE_BLE/include/ble/common/BLETypes.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
#ifndef BLE_TYPES_H_
2020
#define BLE_TYPES_H_
2121

22-
#include <stddef.h>
23-
#include <stdint.h>
24-
#include <string.h>
22+
#include <cstddef>
23+
#include <cstdint>
24+
#include <cstring>
2525
#include "ble/common/SafeEnum.h"
2626
#include "platform/Span.h"
2727

@@ -872,7 +872,7 @@ struct whitelist_t {
872872
* @post type is equal to PUBLIC and the address value is equal to
873873
* 00:00:00:00:00:00
874874
*/
875-
entry_t(void) : type(), address() { }
875+
entry_t() : type(), address() { }
876876

877877
/**
878878
* Type of the peer address.

connectivity/FEATURE_BLE/include/ble/common/Bounded.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#ifndef BLE_COMMON_BOUNDED_H_
2020
#define BLE_COMMON_BOUNDED_H_
2121

22-
#include <stdint.h>
22+
#include <cstdint>
2323

2424
namespace ble {
2525

@@ -47,9 +47,9 @@ struct Bounded {
4747
Bounded(Rep v) : _value(v)
4848
{
4949
if (v < Min) {
50-
_value = v;
50+
_value = Min;
5151
} else if (v > Max) {
52-
_value = v;
52+
_value = Max;
5353
}
5454
}
5555

connectivity/FEATURE_BLE/include/ble/common/CallChainOfFunctionPointersWithContext.h

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#ifndef MBED_CALLCHAIN_OF_FUNCTION_POINTERS_WITH_CONTEXT_H
2020
#define MBED_CALLCHAIN_OF_FUNCTION_POINTERS_WITH_CONTEXT_H
2121

22-
#include <string.h>
22+
#include <cstring>
2323
#include "ble/common/FunctionPointerWithContext.h"
2424
#include "ble/common/SafeBool.h"
2525

@@ -96,6 +96,14 @@ class CallChainOfFunctionPointersWithContext :
9696
*/
9797
CallChainOfFunctionPointersWithContext() : chainHead(NULL) { }
9898

99+
/* Disallow copy constructor and assignment operators. */
100+
CallChainOfFunctionPointersWithContext(
101+
const CallChainOfFunctionPointersWithContext&
102+
) = delete;
103+
CallChainOfFunctionPointersWithContext &operator=(
104+
const CallChainOfFunctionPointersWithContext&
105+
) = delete;
106+
99107
/**
100108
* Destruction of the callchain.
101109
*/
@@ -186,7 +194,7 @@ class CallChainOfFunctionPointersWithContext :
186194
/**
187195
* Remove all functions registered in the chain.
188196
*/
189-
void clear(void)
197+
void clear()
190198
{
191199
pFunctionPointerWithContext_t fptr = chainHead;
192200
while (fptr) {
@@ -203,7 +211,7 @@ class CallChainOfFunctionPointersWithContext :
203211
*
204212
* @return true if the callchain is not empty and false otherwise.
205213
*/
206-
bool hasCallbacksAttached(void) const
214+
bool hasCallbacksAttached() const
207215
{
208216
return (chainHead != NULL);
209217
}
@@ -324,16 +332,6 @@ class CallChainOfFunctionPointersWithContext :
324332
* const from an external standpoint.
325333
*/
326334
mutable pFunctionPointerWithContext_t currentCalled;
327-
328-
329-
/* Disallow copy constructor and assignment operators. */
330-
private:
331-
CallChainOfFunctionPointersWithContext(
332-
const CallChainOfFunctionPointersWithContext&
333-
);
334-
CallChainOfFunctionPointersWithContext &operator=(
335-
const CallChainOfFunctionPointersWithContext&
336-
);
337335
};
338336

339337
/**

connectivity/FEATURE_BLE/include/ble/common/Duration.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
#ifndef BLE_COMMON_DURATION_H_
2020
#define BLE_COMMON_DURATION_H_
2121

22-
#include <stdint.h>
23-
#include <stddef.h>
22+
#include <cstdint>
23+
#include <cstddef>
2424
#include "platform/mbed_assert.h"
2525
#include "platform/mbed_chrono.h"
2626

@@ -155,7 +155,7 @@ struct Duration {
155155
* @param other_ms The Duration in millisecond to convert.
156156
*/
157157
template<typename OtherRep, typename OtherRange, typename OtherF>
158-
explicit Duration(Duration<OtherRep, 1000, OtherRange, OtherF> other_ms, void* = NULL) :
158+
explicit Duration(Duration<OtherRep, 1000, OtherRange, OtherF> other_ms, void* = nullptr) :
159159
duration(clamp(((other_ms.value() * 1000) + TB - 1) / TB))
160160
{
161161
}

0 commit comments

Comments
 (0)