Skip to content

netsocket: astyle fix #7692

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion features/netsocket/CellularBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ class CellularBase: public NetworkInterface {
*/
virtual const char *get_gateway() = 0;

virtual CellularBase *cellularBase() {
virtual CellularBase *cellularBase()
{
return this;
}

Expand Down
4 changes: 2 additions & 2 deletions features/netsocket/DNS.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class DNS {
* @return 0 on success, negative error code on failure
*/
virtual nsapi_error_t gethostbyname(const char *host,
SocketAddress *address, nsapi_version_t version = NSAPI_UNSPEC) = 0;
SocketAddress *address, nsapi_version_t version = NSAPI_UNSPEC) = 0;

/** Hostname translation callback (asynchronous)
*
Expand Down Expand Up @@ -75,7 +75,7 @@ class DNS {
* and can be passed to cancel
*/
virtual nsapi_value_or_error_t gethostbyname_async(const char *host, hostbyname_cb_t callback,
nsapi_version_t version = NSAPI_UNSPEC) = 0;
nsapi_version_t version = NSAPI_UNSPEC) = 0;

/** Cancels asynchronous hostname translation
*
Expand Down
10 changes: 5 additions & 5 deletions features/netsocket/EMACInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ nsapi_error_t EMACInterface::connect()
}

return _interface->bringup(_dhcp,
_ip_address[0] ? _ip_address : 0,
_netmask[0] ? _netmask : 0,
_gateway[0] ? _gateway : 0,
DEFAULT_STACK,
_blocking);
_ip_address[0] ? _ip_address : 0,
_netmask[0] ? _netmask : 0,
_gateway[0] ? _gateway : 0,
DEFAULT_STACK,
_blocking);
}

nsapi_error_t EMACInterface::disconnect()
Expand Down
25 changes: 13 additions & 12 deletions features/netsocket/EMACInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@
* the credentials have been set. This is necessary to support specialised
* applications such as 6LoWPAN mesh border routers.
*/
class EMACInterface : public virtual NetworkInterface
{
class EMACInterface : public virtual NetworkInterface {
public:
/** Create an EMAC-based network interface.
*
Expand All @@ -52,9 +51,8 @@ class EMACInterface : public virtual NetworkInterface
* @param emac Reference to EMAC to use
* @param stack Reference to onboard-network stack to use
*/
EMACInterface(
EMAC &emac = EMAC::get_default_instance(),
OnboardNetworkStack &stack = OnboardNetworkStack::get_default_instance());
EMACInterface(EMAC &emac = EMAC::get_default_instance(),
OnboardNetworkStack &stack = OnboardNetworkStack::get_default_instance());

/** Set a static IP address
*
Expand All @@ -67,8 +65,7 @@ class EMACInterface : public virtual NetworkInterface
* @param gateway Null-terminated representation of the local gateway
* @return 0 on success, negative error code on failure
*/
virtual nsapi_error_t set_network(
const char *ip_address, const char *netmask, const char *gateway);
virtual nsapi_error_t set_network(const char *ip_address, const char *netmask, const char *gateway);

/** Enable or disable DHCP on the network
*
Expand All @@ -94,7 +91,7 @@ class EMACInterface : public virtual NetworkInterface
* Provided MAC address is intended for info or debug purposes and
* may not be provided if the underlying network interface does not
* provide a MAC address
*
*
* @return Null-terminated representation of the local MAC address
* or null if no MAC address is available
*/
Expand All @@ -109,7 +106,7 @@ class EMACInterface : public virtual NetworkInterface

/** Get the local network mask
*
* @return Null-terminated representation of the local network mask
* @return Null-terminated representation of the local network mask
* or null if no network mask has been recieved
*/
virtual const char *get_netmask();
Expand Down Expand Up @@ -148,16 +145,20 @@ class EMACInterface : public virtual NetworkInterface
*
* @return Reference to the EMAC in use
*/
EMAC &get_emac() const { return _emac; }
EMAC &get_emac() const
{
return _emac;
}

virtual EMACInterface *emacInterface() {
virtual EMACInterface *emacInterface()
{
return this;
}

protected:
/** Provide access to the underlying stack
*
* @return The underlying network stack
* @return The underlying network stack
*/
virtual NetworkStack *get_stack();

Expand Down
6 changes: 3 additions & 3 deletions features/netsocket/EthInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
*
* Common interface that is shared between ethernet hardware.
*/
class EthInterface : public virtual NetworkInterface
{
class EthInterface : public virtual NetworkInterface {
public:

virtual EthInterface *ethInterface() {
virtual EthInterface *ethInterface()
{
return this;
}

Expand Down
8 changes: 3 additions & 5 deletions features/netsocket/EthernetInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
/** EthernetInterface class
* Implementation of the NetworkStack for an EMAC-based Ethernet driver
*/
class EthernetInterface : public EMACInterface, public EthInterface
{
class EthernetInterface : public EMACInterface, public EthInterface {
public:
/** Create an EMAC-based ethernet interface.
*
Expand All @@ -41,9 +40,8 @@ class EthernetInterface : public EMACInterface, public EthInterface
* @param emac Reference to EMAC to use
* @param stack Reference to onboard-network stack to use
*/
EthernetInterface(
EMAC &emac = EMAC::get_default_instance(),
OnboardNetworkStack &stack = OnboardNetworkStack::get_default_instance()) : EMACInterface(emac, stack) { }
EthernetInterface(EMAC &emac = EMAC::get_default_instance(),
OnboardNetworkStack &stack = OnboardNetworkStack::get_default_instance()) : EMACInterface(emac, stack) { }
};

#endif
2 changes: 1 addition & 1 deletion features/netsocket/InternetSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ nsapi_error_t InternetSocket::getsockopt(int level, int optname, void *optval, u
}
void InternetSocket::event()
{
_event_flag.set(READ_FLAG|WRITE_FLAG);
_event_flag.set(READ_FLAG | WRITE_FLAG);

_pending += 1;
if (_callback && _pending == 1) {
Expand Down
14 changes: 8 additions & 6 deletions features/netsocket/InternetSocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ class InternetSocket : public Socket {
nsapi_error_t open(NetworkStack *stack);

template <typename S>
nsapi_error_t open(S *stack) {
nsapi_error_t open(S *stack)
{
return open(nsapi_create_stack(stack));
}

Expand Down Expand Up @@ -196,8 +197,8 @@ class InternetSocket : public Socket {
* mbed OS and has been known to cause confusion. Replaced by Socket::sigio.
*/
MBED_DEPRECATED_SINCE("mbed-os-5.4",
"The behaviour of Socket::attach differs from other attach functions in "
"mbed OS and has been known to cause confusion. Replaced by Socket::sigio.")
"The behaviour of Socket::attach differs from other attach functions in "
"mbed OS and has been known to cause confusion. Replaced by Socket::sigio.")
void attach(mbed::Callback<void()> func);

/** Register a callback on state change of the socket
Expand All @@ -209,9 +210,10 @@ class InternetSocket : public Socket {
*/
template <typename T, typename M>
MBED_DEPRECATED_SINCE("mbed-os-5.1",
"The attach function does not support cv-qualifiers. Replaced by "
"attach(callback(obj, method)).")
void attach(T *obj, M method) {
"The attach function does not support cv-qualifiers. Replaced by "
"attach(callback(obj, method)).")
void attach(T *obj, M method)
{
attach(mbed::callback(obj, method));
}

Expand Down
6 changes: 3 additions & 3 deletions features/netsocket/MeshInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
*
* Common interface that is shared between mesh hardware
*/
class MeshInterface : public virtual NetworkInterface
{
class MeshInterface : public virtual NetworkInterface {
public:

virtual MeshInterface *meshInterface() {
virtual MeshInterface *meshInterface()
{
return this;
}

Expand Down
22 changes: 13 additions & 9 deletions features/netsocket/NetworkInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,7 @@ class NetworkInterface: public DNS {
* @param gateway Null-terminated representation of the local gateway
* @return 0 on success, negative error code on failure
*/
virtual nsapi_error_t set_network(
const char *ip_address, const char *netmask, const char *gateway);
virtual nsapi_error_t set_network(const char *ip_address, const char *netmask, const char *gateway);

/** Enable or disable DHCP on the network
*
Expand Down Expand Up @@ -163,7 +162,7 @@ class NetworkInterface: public DNS {
* @return 0 on success, negative error code on failure
*/
virtual nsapi_error_t gethostbyname(const char *host,
SocketAddress *address, nsapi_version_t version = NSAPI_UNSPEC);
SocketAddress *address, nsapi_version_t version = NSAPI_UNSPEC);

/** Hostname translation callback (asynchronous)
*
Expand Down Expand Up @@ -203,7 +202,7 @@ class NetworkInterface: public DNS {
* and can be passed to cancel
*/
virtual nsapi_value_or_error_t gethostbyname_async(const char *host, hostbyname_cb_t callback,
nsapi_version_t version = NSAPI_UNSPEC);
nsapi_version_t version = NSAPI_UNSPEC);

/** Cancels asynchronous hostname translation
*
Expand Down Expand Up @@ -245,27 +244,32 @@ class NetworkInterface: public DNS {
virtual nsapi_error_t set_blocking(bool blocking);

/** Dynamic downcast to an EthInterface */
virtual EthInterface *ethInterface() {
virtual EthInterface *ethInterface()
{
return 0;
}

/** Dynamic downcast to a WiFiInterface */
virtual WiFiInterface *wifiInterface() {
virtual WiFiInterface *wifiInterface()
{
return 0;
}

/** Dynamic downcast to a MeshInterface */
virtual MeshInterface *meshInterface() {
virtual MeshInterface *meshInterface()
{
return 0;
}

/** Dynamic downcast to a CellularBase */
virtual CellularBase *cellularBase() {
virtual CellularBase *cellularBase()
{
return 0;
}

/** Dynamic downcast to an EMACInterface */
virtual EMACInterface *emacInterface() {
virtual EMACInterface *emacInterface()
{
return 0;
}

Expand Down
9 changes: 4 additions & 5 deletions features/netsocket/NetworkStack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,13 @@ call_in_callback_cb_t NetworkStack::get_call_in_callback()
}

// NetworkStackWrapper class for encapsulating the raw nsapi_stack structure
class NetworkStackWrapper : public NetworkStack
{
class NetworkStackWrapper : public NetworkStack {
private:
inline nsapi_stack_t *_stack()
{
return reinterpret_cast<nsapi_stack_t *>(
reinterpret_cast<uint8_t *>(this)
- offsetof(nsapi_stack_t, _stack_buffer));
reinterpret_cast<uint8_t *>(this)
- offsetof(nsapi_stack_t, _stack_buffer));
}

inline const nsapi_stack_api_t *_stack_api()
Expand Down Expand Up @@ -358,7 +357,7 @@ class NetworkStackWrapper : public NetworkStack
NetworkStack *nsapi_create_stack(nsapi_stack_t *stack)
{
MBED_STATIC_ASSERT(sizeof stack->_stack_buffer >= sizeof(NetworkStackWrapper),
"The nsapi_stack_t stack buffer must fit a NetworkStackWrapper");
"The nsapi_stack_t stack buffer must fit a NetworkStackWrapper");
return new (stack->_stack_buffer) NetworkStackWrapper;
}

Expand Down
Loading