Skip to content

Commit 2296015

Browse files
committed
CpuUid: fixed coding style
1 parent 6bdc293 commit 2296015

File tree

2 files changed

+26
-21
lines changed

2 files changed

+26
-21
lines changed

drivers/CpuUid.cpp

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,18 @@ const char CpuUid::_hexChars[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8',
2626
CpuUid::CpuUid() : _data(NULL)
2727
{
2828
_size = cpu_uid_get_length();
29+
#ifdef MBED_ASSERT
2930
MBED_ASSERT(_size > 0);
30-
if (0 < _size)
31-
{
31+
#endif
32+
if (0 < _size) {
3233
_data = new uint8_t[_size];
3334
cpu_uid_get_uid(_data);
3435
}
3536
}
3637

3738
CpuUid::~CpuUid()
3839
{
39-
if (_data)
40-
{
40+
if (_data) {
4141
delete _data;
4242
}
4343
}
@@ -46,21 +46,19 @@ CpuUid::operator std::string()
4646
{
4747
std::string str;
4848

49-
for (int i = 0; i < _size; ++i)
50-
{
49+
for (int i = 0; i < _size; ++i) {
5150
str += _hexChars[_data[i] >> 4];
5251
str += _hexChars[_data[i] & 0x0F];
5352
}
5453

5554
return str;
5655
}
5756

58-
CpuUid::operator CpuUidArray()
57+
CpuUid::operator cpu_uid_array_t()
5958
{
60-
CpuUidArray array;
59+
cpu_uid_array_t array;
6160

62-
for (int i = 0; i < _size; ++i)
63-
{
61+
for (int i = 0; i < _size; ++i) {
6462
array.push_back(_data[i]);
6563
}
6664

@@ -69,8 +67,7 @@ CpuUid::operator CpuUidArray()
6967

7068
uint8_t CpuUid::operator[](int x)
7169
{
72-
if (x >= 0 && x < _size)
73-
{
70+
if (x >= 0 && x < _size) {
7471
return _data[x];
7572
}
7673

drivers/CpuUid.h

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,10 @@ namespace mbed {
3232
* @ingroup drivers
3333
*/
3434
class CpuUid {
35-
3635
public:
3736
/** CPU UID array typedef
3837
*/
39-
typedef std::vector<uint8_t> CpuUidArray;
38+
typedef std::vector<uint8_t> cpu_uid_array_t;
4039

4140
/** CpuUid constructor
4241
*/
@@ -50,31 +49,40 @@ class CpuUid {
5049
*
5150
* @return Size of device's CPU UID in bytes
5251
*/
53-
int size() { return _size; }
52+
int size()
53+
{
54+
return _size;
55+
}
5456

5557
/** Get CPU UID data pointer
5658
*
5759
* @return Pointer to uid data buffer
5860
*/
59-
const uint8_t* data() { return _data; }
61+
const uint8_t *data()
62+
{
63+
return _data;
64+
}
6065

6166
/** Overload operator for std::string
6267
*
6368
* @return string object containing the CPU UID in uppercase hex letters in ascii format
6469
*/
6570
operator std::string();
6671

67-
/** Overload operator for CpuUidArray
72+
/** Overload operator for cpu_uid_array_t
6873
*
69-
* @return CpuUidArray object containing the CPU UID
74+
* @return cpu_uid_array_t object containing the CPU UID
7075
*/
71-
operator CpuUidArray();
76+
operator cpu_uid_array_t();
7277

7378
/** Overload operator for byte pointer
7479
*
7580
* @return Pointer to uid data buffer
7681
*/
77-
operator const uint8_t*() { return _data; }
82+
operator const uint8_t*()
83+
{
84+
return _data;
85+
}
7886

7987
/** Overload operator for array subscript
8088
*
@@ -85,7 +93,7 @@ class CpuUid {
8593
uint8_t operator[](int x);
8694

8795
private:
88-
uint8_t * _data;
96+
uint8_t *_data;
8997
int _size;
9098

9199
static const char _hexChars[16];

0 commit comments

Comments
 (0)