Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
multiplemonomials committed Oct 27, 2024
1 parent 9b8c417 commit f51c5c2
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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;
}
Expand Down Expand Up @@ -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;
}

Expand All @@ -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)
{

}
Expand Down
30 changes: 15 additions & 15 deletions connectivity/netsocket/tests/emac_test_utils/EmacTestNetworkStack.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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:

Expand All @@ -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;
Expand Down
7 changes: 2 additions & 5 deletions connectivity/netsocket/tests/emac_test_utils/emac_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion connectivity/netsocket/tests/emac_test_utils/emac_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
8 changes: 8 additions & 0 deletions run-formatter.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit f51c5c2

Please sign in to comment.