diff --git a/connectivity/netsocket/tests/emac_test_utils/EmacTestNetworkStack.cpp b/connectivity/netsocket/tests/emac_test_utils/EmacTestNetworkStack.cpp index 291a111c9b7..fd8002c8ee5 100644 --- a/connectivity/netsocket/tests/emac_test_utils/EmacTestNetworkStack.cpp +++ b/connectivity/netsocket/tests/emac_test_utils/EmacTestNetworkStack.cpp @@ -19,7 +19,8 @@ #include "mbed_interface.h" -bool EmacTestNetworkStack::emac_if_init(EMAC *emac) { +bool EmacTestNetworkStack::emac_if_init(EMAC *emac) +{ emac->set_link_input_cb(emac_if_link_input_cb); emac->set_link_state_cb(emac_if_link_state_change_cb); @@ -31,8 +32,7 @@ bool EmacTestNetworkStack::emac_if_init(EMAC *emac) { int hwaddr_len = emac->get_hwaddr_size(); printf("emac hwaddr length %i\r\n\r\n", hwaddr_len); - if(hwaddr_len != 6) - { + if (hwaddr_len != 6) { printf("invalid emac hwaddr length %d!\n", hwaddr_len); return false; } @@ -141,8 +141,7 @@ void EmacTestNetworkStack::socket_attach(nsapi_socket_t handle, void (*callback) nsapi_error_t EmacTestNetworkStack::add_ethernet_interface(EMAC &emac, bool default_if, OnboardNetworkStack::Interface **interface_out, NetworkInterface *user_network_interface) { // Only one interface is supported - if(m_interface.m_emac != nullptr) - { + if (m_interface.m_emac != nullptr) { return NSAPI_ERROR_UNSUPPORTED; } @@ -156,17 +155,19 @@ nsapi_error_t EmacTestNetworkStack::add_ethernet_interface(EMAC &emac, bool defa return NSAPI_ERROR_OK; } -EMAC *EmacTestNetworkStack::get_emac() { +EMAC *EmacTestNetworkStack::get_emac() +{ return m_interface.m_emac; } -unsigned char const *EmacTestNetworkStack::get_mac_addr() const { +unsigned char const *EmacTestNetworkStack::get_mac_addr() const +{ return eth_mac_addr; } -EmacTestNetworkStack::Interface::Interface(EmacTestNetworkStack & netStack): -m_netStack(netStack), -m_emac(nullptr) +EmacTestNetworkStack::Interface::Interface(EmacTestNetworkStack &netStack): + m_netStack(netStack), + m_emac(nullptr) { } diff --git a/connectivity/netsocket/tests/emac_test_utils/EmacTestNetworkStack.h b/connectivity/netsocket/tests/emac_test_utils/EmacTestNetworkStack.h index 1a071b1b499..322e29d5d06 100644 --- a/connectivity/netsocket/tests/emac_test_utils/EmacTestNetworkStack.h +++ b/connectivity/netsocket/tests/emac_test_utils/EmacTestNetworkStack.h @@ -52,10 +52,10 @@ class EmacTestNetworkStack : public OnboardNetworkStack, private mbed::NonCopyab nsapi_error_t set_mac_address(uint8_t *mac_addr, nsapi_size_t addr_len); nsapi_error_t bringup(bool dhcp, const char *ip, - const char *netmask, const char *gw, - nsapi_ip_stack_t stack, - bool blocking - ) override; + const char *netmask, const char *gw, + nsapi_ip_stack_t stack, + bool blocking + ) override; nsapi_error_t bringdown() override; @@ -73,19 +73,19 @@ class EmacTestNetworkStack : public OnboardNetworkStack, private mbed::NonCopyab private: friend EmacTestNetworkStack; - explicit Interface(EmacTestNetworkStack & netStack); + explicit Interface(EmacTestNetworkStack &netStack); - EmacTestNetworkStack & m_netStack; + EmacTestNetworkStack &m_netStack; EMAC *m_emac; }; nsapi_error_t add_ethernet_interface(EMAC &emac, bool default_if, OnboardNetworkStack::Interface **interface_out, NetworkInterface *user_network_interface) override; /// Get a pointer to the EMAC driver. Will return nullptr if no interface has been added yet. - EMAC * get_emac(); + EMAC *get_emac(); /// Get the MAC address being used for the ethernet port - unsigned char const * get_mac_addr() const; + unsigned char const *get_mac_addr() const; protected: @@ -100,27 +100,27 @@ class EmacTestNetworkStack : public OnboardNetworkStack, private mbed::NonCopyab nsapi_error_t socket_connect(nsapi_socket_t handle, const SocketAddress &address) override; nsapi_error_t socket_accept(nsapi_socket_t server, - nsapi_socket_t *handle, SocketAddress *address = 0) override; + nsapi_socket_t *handle, SocketAddress *address = 0) override; nsapi_size_or_error_t socket_send(nsapi_socket_t handle, - const void *data, nsapi_size_t size) override; + const void *data, nsapi_size_t size) override; nsapi_size_or_error_t socket_recv(nsapi_socket_t handle, - void *data, nsapi_size_t size) override; + void *data, nsapi_size_t size) override; nsapi_size_or_error_t socket_sendto(nsapi_socket_t handle, const SocketAddress &address, - const void *data, nsapi_size_t size) override; + const void *data, nsapi_size_t size) override; nsapi_size_or_error_t socket_recvfrom(nsapi_socket_t handle, SocketAddress *address, - void *buffer, nsapi_size_t size) override; + void *buffer, nsapi_size_t size) override; void socket_attach(nsapi_socket_t handle, void (*callback)(void *), void *data) override; nsapi_error_t setsockopt(nsapi_socket_t handle, int level, - int optname, const void *optval, unsigned optlen) override; + int optname, const void *optval, unsigned optlen) override; nsapi_error_t getsockopt(nsapi_socket_t handle, int level, - int optname, void *optval, unsigned *optlen) override; + int optname, void *optval, unsigned *optlen) override; private: call_in_callback_cb_t get_call_in_callback() override; diff --git a/connectivity/netsocket/tests/emac_test_utils/emac_util.cpp b/connectivity/netsocket/tests/emac_test_utils/emac_util.cpp index c34b20a0447..1ac6ff58eac 100644 --- a/connectivity/netsocket/tests/emac_test_utils/emac_util.cpp +++ b/connectivity/netsocket/tests/emac_test_utils/emac_util.cpp @@ -506,12 +506,9 @@ void worker_loop_start(void (*test_step_cb_fnc)(int opt), std::chrono::milliseco validate_outgoing_msg_timer = worker_loop_event_queue.call_every(200ms, emac_if_validate_outgoing_msg); } - if(loop_forever) - { + if (loop_forever) { worker_loop_semaphore.acquire(); - } - else - { + } else { worker_loop_semaphore.try_acquire_for(600s); } diff --git a/connectivity/netsocket/tests/emac_test_utils/emac_util.h b/connectivity/netsocket/tests/emac_test_utils/emac_util.h index e2eaebd613d..f6320110a07 100644 --- a/connectivity/netsocket/tests/emac_test_utils/emac_util.h +++ b/connectivity/netsocket/tests/emac_test_utils/emac_util.h @@ -120,7 +120,7 @@ void emac_if_set_memory(bool memory); void emac_if_set_ctp_server_enabled(bool enabled); void worker_loop_init(void); -void worker_loop_start(void (*test_step_cb_fnc)(int opt), std::chrono::milliseconds poll_rate, bool loop_forever=false); +void worker_loop_start(void (*test_step_cb_fnc)(int opt), std::chrono::milliseconds poll_rate, bool loop_forever = false); void worker_loop_end(void); void worker_loop_link_up_wait(void); diff --git a/run-formatter.sh b/run-formatter.sh new file mode 100755 index 00000000000..47d45bbaed8 --- /dev/null +++ b/run-formatter.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +# Script to run the Astyle formatter on the Mbed OS code base. +# Run before submitting code changes! +git diff --name-only --diff-filter=d origin/master \ + | ( grep '.*\.\(c\|cpp\|h\|hpp\)$' || true ) \ + | ( grep -v -f .codecheckignore || true ) \ + | while read file; do astyle -n --options=.astylerc "${file}"; done \ No newline at end of file