Skip to content

Commit f40c561

Browse files
committed
Inline nsapi_create_stack(NetworkStack)
The rather fiddly `nsapi_create_stack` template + overloads used during socket formation don't inline their core, which is the identity operation for `NetworkStack *` itself. Make code generation easier by having that core be inline.
1 parent bac5ffe commit f40c561

File tree

3 files changed

+9
-15
lines changed

3 files changed

+9
-15
lines changed

UNITTESTS/stubs/NetworkStack_stub.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,6 @@ NetworkStack *nsapi_create_stack(nsapi_stack_t *stack)
6868
return reinterpret_cast<NetworkStack *>(stack);
6969
}
7070

71-
NetworkStack *nsapi_create_stack(NetworkStack *stack)
72-
{
73-
return reinterpret_cast<NetworkStack *>(stack);
74-
}
75-
7671
nsapi_value_or_error_t NetworkStack::gethostbyname_async(const char *host, hostbyname_cb_t callback, nsapi_version_t version,
7772
const char *interface_name)
7873
{

features/netsocket/NetworkStack.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -445,8 +445,3 @@ NetworkStack *nsapi_create_stack(nsapi_stack_t *stack)
445445
return new (stack->_stack_buffer) NetworkStackWrapper;
446446
}
447447

448-
NetworkStack *nsapi_create_stack(NetworkStack *stack)
449-
{
450-
return stack;
451-
}
452-

features/netsocket/NetworkStack.h

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -483,14 +483,18 @@ class NetworkStack: public DNS {
483483

484484
/** Convert a raw nsapi_stack_t object into a C++ NetworkStack object
485485
*
486-
* @param stack Reference to an object that can be converted to a stack
486+
* @param stack Pointer to an object that can be converted to a stack
487487
* - A raw nsapi_stack_t object
488-
* - A reference to a network stack
489-
* - A reference to a network interface
490-
* @return Reference to the underlying network stack
488+
* - A pointer to a network stack
489+
* - A pointer to a network interface
490+
* @return Pointer to the underlying network stack
491491
*/
492492
NetworkStack *nsapi_create_stack(nsapi_stack_t *stack);
493-
NetworkStack *nsapi_create_stack(NetworkStack *stack);
493+
494+
inline NetworkStack *nsapi_create_stack(NetworkStack *stack)
495+
{
496+
return stack;
497+
}
494498

495499
template <typename IF>
496500
NetworkStack *nsapi_create_stack(IF *iface)

0 commit comments

Comments
 (0)