Skip to content

Commit a49783c

Browse files
gekyadbridge
authored andcommitted
nsapi - Adopted standardized return types in the Nanostack interfaces
1 parent 33b600e commit a49783c

File tree

2 files changed

+48
-48
lines changed

2 files changed

+48
-48
lines changed

features/nanostack/FEATURE_NANOSTACK/nanostack-interface/NanostackInterface.cpp

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ class NanostackSocket {
109109

110110
static NanostackSocket * socket_tbl[NS_INTERFACE_SOCKETS_MAX];
111111

112-
static int map_mesh_error(mesh_error_t err)
112+
static nsapi_error_t map_mesh_error(mesh_error_t err)
113113
{
114114
switch (err) {
115115
case MESH_ERROR_NONE: return 0;
@@ -163,7 +163,7 @@ NanostackSocket::~NanostackSocket()
163163
close();
164164
}
165165
if (socket_id >= 0) {
166-
int ret = socket_free(socket_id);
166+
nsapi_error_t ret = socket_free(socket_id);
167167
MBED_ASSERT(0 == ret);
168168
MBED_ASSERT(socket_tbl[socket_id] == this);
169169
socket_tbl[socket_id] = NULL;
@@ -205,7 +205,7 @@ void NanostackSocket::close()
205205
MBED_ASSERT(mode != SOCKET_MODE_CLOSED);
206206

207207
if (socket_id >= 0) {
208-
int ret = socket_close(socket_id, (addr_valid ? &ns_address : NULL));
208+
nsapi_error_t ret = socket_close(socket_id, (addr_valid ? &ns_address : NULL));
209209
MBED_ASSERT(0 == ret);
210210
} else {
211211
MBED_ASSERT(SOCKET_MODE_UNOPENED == mode);
@@ -462,7 +462,7 @@ MeshInterfaceNanostack::MeshInterfaceNanostack(NanostackRfPhy *phy)
462462
// Nothing to do
463463
}
464464

465-
int MeshInterfaceNanostack::initialize(NanostackRfPhy *phy)
465+
nsapi_error_t MeshInterfaceNanostack::initialize(NanostackRfPhy *phy)
466466
{
467467
if (this->phy != NULL) {
468468
error("Phy already set");
@@ -482,7 +482,7 @@ void MeshInterfaceNanostack::mesh_network_handler(mesh_connection_status_t statu
482482
nanostack_unlock();
483483
}
484484

485-
int MeshInterfaceNanostack::register_rf()
485+
nsapi_error_t MeshInterfaceNanostack::register_rf()
486486
{
487487
nanostack_lock();
488488

@@ -500,7 +500,7 @@ int MeshInterfaceNanostack::register_rf()
500500
return 0;
501501
}
502502

503-
int MeshInterfaceNanostack::actual_connect()
503+
nsapi_error_t MeshInterfaceNanostack::actual_connect()
504504
{
505505
nanostack_assert_locked();
506506

@@ -528,7 +528,7 @@ NetworkStack * MeshInterfaceNanostack::get_stack()
528528
return NanostackInterface::get_stack();
529529
}
530530

531-
int MeshInterfaceNanostack::disconnect()
531+
nsapi_error_t MeshInterfaceNanostack::disconnect()
532532
{
533533
nanostack_lock();
534534

@@ -558,7 +558,7 @@ const char *MeshInterfaceNanostack::get_mac_address()
558558
return mac_addr_str;
559559
}
560560

561-
int ThreadInterface::connect()
561+
nsapi_error_t ThreadInterface::connect()
562562
{
563563
// initialize mesh networking resources, memory, timers, etc...
564564
mesh_system_init();
@@ -582,14 +582,14 @@ int ThreadInterface::connect()
582582
nanostack_unlock();
583583
return map_mesh_error(status);
584584
}
585-
int ret = this->actual_connect();
585+
nsapi_error_t ret = this->actual_connect();
586586

587587
nanostack_unlock();
588588

589589
return ret;
590590
}
591591

592-
int LoWPANNDInterface::connect()
592+
nsapi_error_t LoWPANNDInterface::connect()
593593
{
594594
// initialize mesh networking resources, memory, timers, etc...
595595
mesh_system_init();
@@ -613,7 +613,7 @@ int LoWPANNDInterface::connect()
613613
nanostack_unlock();
614614
return map_mesh_error(status);
615615
}
616-
int ret = this->actual_connect();
616+
nsapi_error_t ret = this->actual_connect();
617617

618618
nanostack_unlock();
619619

@@ -642,7 +642,7 @@ const char * NanostackInterface::get_ip_address()
642642
return NULL;
643643
}
644644

645-
int NanostackInterface::socket_open(void **handle, nsapi_protocol_t protocol)
645+
nsapi_error_t NanostackInterface::socket_open(void **handle, nsapi_protocol_t protocol)
646646
{
647647
// Validate parameters
648648
if (NULL == handle) {
@@ -683,7 +683,7 @@ int NanostackInterface::socket_open(void **handle, nsapi_protocol_t protocol)
683683
return 0;
684684
}
685685

686-
int NanostackInterface::socket_close(void *handle)
686+
nsapi_error_t NanostackInterface::socket_close(void *handle)
687687
{
688688
// Validate parameters
689689
NanostackSocket * socket = static_cast<NanostackSocket *>(handle);
@@ -703,7 +703,7 @@ int NanostackInterface::socket_close(void *handle)
703703

704704
}
705705

706-
int NanostackInterface::socket_sendto(void *handle, const SocketAddress &address, const void *data, unsigned int size)
706+
nsapi_size_or_error_t NanostackInterface::socket_sendto(void *handle, const SocketAddress &address, const void *data, nsapi_size_t size)
707707
{
708708
// Validate parameters
709709
NanostackSocket * socket = static_cast<NanostackSocket *>(handle);
@@ -718,7 +718,7 @@ int NanostackInterface::socket_sendto(void *handle, const SocketAddress &address
718718

719719
nanostack_lock();
720720

721-
int ret;
721+
nsapi_size_or_error_t ret;
722722
if (socket->closed()) {
723723
ret = NSAPI_ERROR_NO_CONNECTION;
724724
} else if (NANOSTACK_SOCKET_TCP == socket->proto) {
@@ -758,7 +758,7 @@ int NanostackInterface::socket_sendto(void *handle, const SocketAddress &address
758758
return ret;
759759
}
760760

761-
int NanostackInterface::socket_recvfrom(void *handle, SocketAddress *address, void *buffer, unsigned size)
761+
nsapi_size_or_error_t NanostackInterface::socket_recvfrom(void *handle, SocketAddress *address, void *buffer, nsapi_size_t size)
762762
{
763763
// Validate parameters
764764
NanostackSocket * socket = static_cast<NanostackSocket *>(handle);
@@ -777,7 +777,7 @@ int NanostackInterface::socket_recvfrom(void *handle, SocketAddress *address, vo
777777

778778
nanostack_lock();
779779

780-
int ret;
780+
nsapi_size_or_error_t ret;
781781
if (socket->closed()) {
782782
ret = NSAPI_ERROR_NO_CONNECTION;
783783
} else if (NANOSTACK_SOCKET_TCP == socket->proto) {
@@ -796,7 +796,7 @@ int NanostackInterface::socket_recvfrom(void *handle, SocketAddress *address, vo
796796
return ret;
797797
}
798798

799-
int NanostackInterface::socket_bind(void *handle, const SocketAddress &address)
799+
nsapi_error_t NanostackInterface::socket_bind(void *handle, const SocketAddress &address)
800800
{
801801
// Validate parameters
802802
NanostackSocket * socket = static_cast<NanostackSocket *>(handle);
@@ -823,7 +823,7 @@ int NanostackInterface::socket_bind(void *handle, const SocketAddress &address)
823823
ns_address.type = ADDRESS_IPV6;
824824
memcpy(ns_address.address, addr_field, sizeof ns_address.address);
825825
ns_address.identifier = address.get_port();
826-
int ret = NSAPI_ERROR_DEVICE_ERROR;
826+
nsapi_error_t ret = NSAPI_ERROR_DEVICE_ERROR;
827827
if (0 == ::socket_bind(socket->socket_id, &ns_address)) {
828828
socket->set_bound();
829829
ret = 0;
@@ -836,22 +836,22 @@ int NanostackInterface::socket_bind(void *handle, const SocketAddress &address)
836836
return ret;
837837
}
838838

839-
int NanostackInterface::setsockopt(void *handle, int level, int optname, const void *optval, unsigned optlen)
839+
nsapi_error_t NanostackInterface::setsockopt(void *handle, int level, int optname, const void *optval, unsigned optlen)
840840
{
841841
return NSAPI_ERROR_UNSUPPORTED;
842842
}
843843

844-
int NanostackInterface::getsockopt(void *handle, int level, int optname, void *optval, unsigned *optlen)
844+
nsapi_error_t NanostackInterface::getsockopt(void *handle, int level, int optname, void *optval, unsigned *optlen)
845845
{
846846
return NSAPI_ERROR_UNSUPPORTED;
847847
}
848848

849-
int NanostackInterface::socket_listen(void *handle, int backlog)
849+
nsapi_error_t NanostackInterface::socket_listen(void *handle, int backlog)
850850
{
851851
return NSAPI_ERROR_UNSUPPORTED;
852852
}
853853

854-
int NanostackInterface::socket_connect(void *handle, const SocketAddress &addr)
854+
nsapi_error_t NanostackInterface::socket_connect(void *handle, const SocketAddress &addr)
855855
{
856856
// Validate parameters
857857
NanostackSocket * socket = static_cast<NanostackSocket *>(handle);
@@ -866,7 +866,7 @@ int NanostackInterface::socket_connect(void *handle, const SocketAddress &addr)
866866

867867
nanostack_lock();
868868

869-
int ret;
869+
nsapi_error_t ret;
870870
ns_address_t ns_addr;
871871
int random_port = socket->is_bound() ? 0 : 1;
872872
convert_mbed_addr_to_ns(&ns_addr, &addr);
@@ -884,12 +884,12 @@ int NanostackInterface::socket_connect(void *handle, const SocketAddress &addr)
884884
return ret;
885885
}
886886

887-
int NanostackInterface::socket_accept(void *server, void **handle, SocketAddress *address)
887+
nsapi_error_t NanostackInterface::socket_accept(void *server, void **handle, SocketAddress *address)
888888
{
889889
return NSAPI_ERROR_UNSUPPORTED;
890890
}
891891

892-
int NanostackInterface::socket_send(void *handle, const void *p, unsigned size)
892+
nsapi_size_or_error_t NanostackInterface::socket_send(void *handle, const void *p, nsapi_size_t size)
893893
{
894894
// Validate parameters
895895
NanostackSocket * socket = static_cast<NanostackSocket *>(handle);
@@ -900,7 +900,7 @@ int NanostackInterface::socket_send(void *handle, const void *p, unsigned size)
900900

901901
nanostack_lock();
902902

903-
int ret;
903+
nsapi_size_or_error_t ret;
904904
if (socket->closed()) {
905905
ret = NSAPI_ERROR_NO_CONNECTION;
906906
} else if (socket->is_connecting()) {
@@ -933,7 +933,7 @@ int NanostackInterface::socket_send(void *handle, const void *p, unsigned size)
933933
return ret;
934934
}
935935

936-
int NanostackInterface::socket_recv(void *handle, void *data, unsigned size)
936+
nsapi_size_or_error_t NanostackInterface::socket_recv(void *handle, void *data, nsapi_size_t size)
937937
{
938938
// Validate parameters
939939
NanostackSocket * socket = static_cast<NanostackSocket *>(handle);
@@ -944,7 +944,7 @@ int NanostackInterface::socket_recv(void *handle, void *data, unsigned size)
944944

945945
nanostack_lock();
946946

947-
int ret;
947+
nsapi_size_or_error_t ret;
948948
if (socket->closed()) {
949949
ret = NSAPI_ERROR_NO_CONNECTION;
950950
} else if (socket->data_available()) {

0 commit comments

Comments
 (0)