platform: fix coding style

pull/8711/head
Martin Kojtal 2018-11-12 09:41:14 +00:00
parent fbdbffffb9
commit 3d859575d2
8 changed files with 94 additions and 82 deletions

View File

@ -104,7 +104,7 @@ public:
inline void context(uint32_t context)
{
_context = (void*)context;
_context = (void *)context;
}
inline uint32_t entry(void)

View File

@ -22,7 +22,7 @@ typedef void (*CThunkEntry)(void);
class CThunkBase {
protected:
typedef void (*Trampoline)(CThunkBase*);
typedef void (*Trampoline)(CThunkBase *);
Trampoline _trampoline;

View File

@ -30,7 +30,7 @@ namespace mbed {
*/
/** Represents a directory stream. An opendir function returns
/** Represents a directory stream. An opendir function returns
* objects of this type. The core functions are read and seek,
* but only a subset needs to be provided.
*

View File

@ -31,96 +31,96 @@ namespace mbed {
*/
/**
* Prevents generation of copy constructor and copy assignment operator in
* Prevents generation of copy constructor and copy assignment operator in
* derived classes.
*
*
* @par Usage
*
* To prevent generation of copy constructor and copy assignment operator,
* inherit privately from the NonCopyable class.
*
* @code
*
* To prevent generation of copy constructor and copy assignment operator,
* inherit privately from the NonCopyable class.
*
* @code
* class Resource : NonCopyable<Resource> { };
*
*
* Resource r;
* // generates compile time error:
* Resource r2 = r;
* @endcode
*
*
* @par Background information
*
* Instances of polymorphic classes are not meant to be copied. The
* C++ standards generate a default copy constructor and copy assignment
*
* Instances of polymorphic classes are not meant to be copied. The
* C++ standards generate a default copy constructor and copy assignment
* function if these functions have not been defined in the class.
*
*
* Consider the following example:
*
*
* @code
* // base class representing a connection
* struct Connection {
* struct Connection {
* Connection();
* virtual ~Connection();
* virtual void open() = 0;
* }
*
* class SerialConnection : public Connection {
*
* class SerialConnection : public Connection {
* public:
* SerialConnection(Serial*);
*
*
* private:
* Serial* _serial;
* };
*
* Connection& get_connection() {
*
* Connection& get_connection() {
* static SerialConnection serial_connection;
* return serial_connection;
* }
*
* Connection connection = get_connection();
* @endcode
*
* There is a subtle bug in this code, the function get_connection returns a
* reference to a Connection which is captured by value instead of reference.
*
* When `get_connection` returns a reference to serial_connection it is copied into
* the local variable connection. The vtable and others members defined in Connection
* are copied, but members defined in SerialConnection are left apart. This can cause
* severe crashes or bugs if the virtual functions captured use members not present
*
* There is a subtle bug in this code, the function get_connection returns a
* reference to a Connection which is captured by value instead of reference.
*
* When `get_connection` returns a reference to serial_connection it is copied into
* the local variable connection. The vtable and others members defined in Connection
* are copied, but members defined in SerialConnection are left apart. This can cause
* severe crashes or bugs if the virtual functions captured use members not present
* in the base declaration.
*
* To solve that problem, the copy constructor and assignment operator have to
* be declared (but don't need to be defined) in the private section of the
*
* To solve that problem, the copy constructor and assignment operator have to
* be declared (but don't need to be defined) in the private section of the
* Connection class:
*
*
* @code
* struct Connection {
* struct Connection {
* private:
* Connection(const Connection&);
* Connection& operator=(const Connection&);
* }
* @endcode
*
* Although manually declaring private copy constructor and assignment functions
* works, it is not ideal. These declarations are usually easy to forget,
*
* Although manually declaring private copy constructor and assignment functions
* works, it is not ideal. These declarations are usually easy to forget,
* not immediately visible, and may be obscure to uninformed programmers.
*
* Using the NonCopyable class reduces the boilerplate required and expresses
*
* Using the NonCopyable class reduces the boilerplate required and expresses
* the intent because class inheritance appears right after the class name
* declaration.
*
*
* @code
* struct Connection : private NonCopyable<Connection> {
* struct Connection : private NonCopyable<Connection> {
* // regular declarations
* }
* @endcode
*
*
* @par Implementation details
*
* Using a template type prevents cases where the empty base optimization cannot
* be applied and therefore ensures that the cost of the NonCopyable semantic
*
*
* @par Implementation details
*
* Using a template type prevents cases where the empty base optimization cannot
* be applied and therefore ensures that the cost of the NonCopyable semantic
* sugar is null.
*
*
* As an example, the empty base optimization is prohibited if one of the empty
* base classes is also a base type of the first nonstatic data member:
*
@ -157,7 +157,7 @@ namespace mbed {
* // kind of A. sizeof(C) == sizeof(B) == sizeof(int).
* @endcode
*
* @tparam T The type that should be made noncopyable.
* @tparam T The type that should be made noncopyable.
*
* @note Compile time errors are disabled if you use the develop or release profile.
* To override this behavior and force compile time errors in all profiles,
@ -222,7 +222,7 @@ private:
*/
NonCopyable &operator=(const NonCopyable &);
#endif
#endif
#endif
};
/**@}*/

View File

@ -39,12 +39,13 @@ namespace span_detail {
// If From type is convertible to To type, then the compilation constant value is
// true; otherwise, it is false.
template<typename From, typename To>
class is_convertible
{
struct true_type { char x[512]; };
class is_convertible {
struct true_type {
char x[512];
};
struct false_type { };
static const From& generator();
static const From &generator();
static true_type sink(const To &);
static false_type sink(...);
@ -59,11 +60,11 @@ public:
* Special value for the Extent parameter of Span.
* If the type uses this value, then the size of the array is stored in the object
* at runtime.
*
*
* @relates Span
*/
const ptrdiff_t SPAN_DYNAMIC_EXTENT = -1;
#else
#else
#define SPAN_DYNAMIC_EXTENT -1
#endif
@ -293,6 +294,8 @@ struct Span {
MBED_ASSERT(Extent == 0 || first != NULL);
}
// AStyle ignore, not handling correctly below
// *INDENT-OFF*
/**
* Construct a Span from the reference to an array.
*
@ -322,6 +325,7 @@ struct Span {
"OtherElementType(*)[] should be convertible to ElementType (*)[]"
);
}
// *INDENT-ON*
/**
* Return the size of the sequence viewed.
@ -409,6 +413,8 @@ struct Span {
return Span<element_type, Count>(_data + (Extent - Count), Count);
}
// AStyle ignore, not handling correctly below
// *INDENT-OFF*
/**
* Create a subspan that is a view of other Count elements; the view starts at
* element Offset.
@ -439,6 +445,7 @@ struct Span {
Count == SPAN_DYNAMIC_EXTENT ? Extent - Offset : Count
);
}
// *INDENT-ON*
/**
* Create a new Span over the first @p count elements of the existing view.
@ -464,9 +471,9 @@ struct Span {
{
MBED_ASSERT(0 <= count && count <= Extent);
return Span<element_type, SPAN_DYNAMIC_EXTENT>(
_data + (Extent - count),
count
);
_data + (Extent - count),
count
);
}
/**
@ -491,9 +498,9 @@ struct Span {
(0 <= count && (count + offset) <= Extent)
);
return Span<element_type, SPAN_DYNAMIC_EXTENT>(
_data + offset,
count == SPAN_DYNAMIC_EXTENT ? Extent - offset : count
);
_data + offset,
count == SPAN_DYNAMIC_EXTENT ? Extent - offset : count
);
}
private:
@ -579,6 +586,8 @@ struct Span<ElementType, SPAN_DYNAMIC_EXTENT> {
MBED_ASSERT(first != NULL || (last - first) == 0);
}
// AStyle ignore, not handling correctly below
// *INDENT-OFF*
/**
* Construct a Span from the reference to an array.
*
@ -611,6 +620,7 @@ struct Span<ElementType, SPAN_DYNAMIC_EXTENT> {
"OtherElementType(*)[] should be convertible to ElementType (*)[]"
);
}
// *INDENT-ON*
/**
* Return the size of the array viewed.
@ -713,9 +723,9 @@ struct Span<ElementType, SPAN_DYNAMIC_EXTENT> {
(0 <= Count && (Count + Offset) <= _size)
);
return Span<element_type, Count>(
_data + Offset,
Count == SPAN_DYNAMIC_EXTENT ? _size - Offset : Count
);
_data + Offset,
Count == SPAN_DYNAMIC_EXTENT ? _size - Offset : Count
);
}
/**
@ -742,9 +752,9 @@ struct Span<ElementType, SPAN_DYNAMIC_EXTENT> {
{
MBED_ASSERT(0 <= count && count <= _size);
return Span<element_type, SPAN_DYNAMIC_EXTENT>(
_data + (_size - count),
count
);
_data + (_size - count),
count
);
}
/**
@ -769,9 +779,9 @@ struct Span<ElementType, SPAN_DYNAMIC_EXTENT> {
(0 <= count && (count + offset) <= _size)
);
return Span<element_type, SPAN_DYNAMIC_EXTENT>(
_data + offset,
count == SPAN_DYNAMIC_EXTENT ? _size - offset : count
);
_data + offset,
count == SPAN_DYNAMIC_EXTENT ? _size - offset : count
);
}
private:
@ -787,7 +797,7 @@ private:
*
* @return True if Spans in input have the same size and the same content and
* false otherwise.
*
*
* @relates Span
*/
template<typename T, typename U, ptrdiff_t LhsExtent, ptrdiff_t RhsExtent>
@ -804,6 +814,8 @@ bool operator==(const Span<T, LhsExtent> &lhs, const Span<U, RhsExtent> &rhs)
return std::equal(lhs.data(), lhs.data() + lhs.size(), rhs.data());
}
// AStyle ignore, not handling correctly below
// *INDENT-OFF*
/**
* Equality operation between a Span and a reference to a C++ array.
*
@ -842,7 +854,7 @@ bool operator==(T (&lhs)[LhsExtent], const Span<T, RhsExtent> &rhs)
*
* @return True if arrays in input do not have the same size or the same content
* and false otherwise.
*
*
* @relates Span
*/
template<typename T, typename U, ptrdiff_t LhsExtent, ptrdiff_t RhsExtent>
@ -893,7 +905,7 @@ bool operator!=(T (&lhs)[LhsExtent], const Span<T, RhsExtent> &rhs)
*
* @note This helper avoids the typing of template parameter when Span is
* created 'inline'.
*
*
* @relates Span
*/
template<typename T, size_t Size>
@ -959,7 +971,7 @@ Span<const T, Extent> make_const_Span(const T (&elements)[Extent])
{
return Span<const T, Extent>(elements);
}
// *INDENT-ON*
/**
* Generate a Span to a const content from a pointer to a C/C++ array.
*
@ -972,7 +984,7 @@ Span<const T, Extent> make_const_Span(const T (&elements)[Extent])
*
* @note This helper avoids the typing of template parameter when Span is
* created 'inline'.
*
*
* @relates Span
*/
template<size_t Extent, typename T>
@ -994,7 +1006,7 @@ Span<const T, Extent> make_const_Span(const T *elements)
*
* @note This helper avoids the typing of template parameter when Span is
* created 'inline'.
*
*
* @relates Span
*/
template<typename T>

View File

@ -783,7 +783,7 @@ typedef enum _mbed_error_code {
MBED_DEFINE_SYSTEM_ERROR(BLE_BACKEND_CREATION_FAILED, 66), /* 322 BLE Backend creation failed */
MBED_DEFINE_SYSTEM_ERROR(BLE_BACKEND_NOT_INITIALIZED, 67), /* 323 BLE Backend not initialized */
MBED_DEFINE_SYSTEM_ERROR(ASSERTION_FAILED, 68), /* 324 Assertion Failed */
//Everytime you add a new system error code, you must update
//Error documentation under Handbook to capture the info on
//the new error status/codes

View File

@ -168,7 +168,7 @@ void mbed_error_puts(const char *str);
/** @deprecated Renamed to mbed_error_vprintf to match functionality */
MBED_DEPRECATED_SINCE("mbed-os-5.11",
"Renamed to mbed_error_vprintf to match functionality.")
"Renamed to mbed_error_vprintf to match functionality.")
void mbed_error_vfprintf(const char *format, va_list arg) MBED_PRINTF(1, 0);
/** @}*/

View File

@ -30,7 +30,7 @@ extern "C" {
/**
* enum Memory operation types for tracer
*/
*/
enum {
MBED_MEM_TRACE_MALLOC, /**< Identifier for malloc operation */
MBED_MEM_TRACE_REALLOC, /**< Identifier for realloc operation */