net/: The value ERROR should never be returned from internal OS functions. That is reserved for returning values to appliations with the errno value set. Within the OS, errors are returned with a negated errno value ALWAYS.

This commit is contained in:
Gregory Nutt 2019-02-14 15:38:36 -06:00
parent 359753adee
commit 69056d4053
5 changed files with 19 additions and 17 deletions

View file

@ -51,8 +51,8 @@
#include <stdio.h>
#include <time.h>
#include <string.h>
#include <debug.h>
#include <errno.h>
#include <debug.h>
#include <arpa/inet.h>
#include <net/ethernet.h>
@ -774,7 +774,7 @@ static int c5471_phyinit (void)
if (phyid != LU3X31_T64_PHYID)
{
nerr("ERROR: Unrecognized PHY ID: %08x\n", phyid);
return ERROR;
return -ENODEV;
}
/* Next, Set desired network rate, 10BaseT, 100BaseT, or auto. */

View file

@ -45,6 +45,7 @@
#include <nuttx/config.h>
#if defined(CONFIG_NET) && defined(CONFIG_NET_PKT)
#include <errno.h>
#include <debug.h>
#include <nuttx/net/netdev.h>
@ -73,10 +74,10 @@
* dev - The device driver structure containing the received packet
*
* Returned Value:
* OK The packet has been processed and can be deleted
* ERROR There is a matching connection, but could not dispatch the packet
* yet. Useful when a packet arrives before a recv call is in
* place.
* OK The packet has been processed and can be deleted
* -EAGAIN There is a matching connection, but could not dispatch the packet
* yet. Useful when a packet arrives before a recv call is in
* place.
*
* Assumptions:
* The network is locked.
@ -109,14 +110,14 @@ int pkt_input(struct net_driver_s *dev)
if ((flags & PKT_NEWDATA) != 0)
{
/* No.. the packet was not processed now. Return ERROR so
/* No.. the packet was not processed now. Return -EAGAIN so
* that the driver may retry again later. We still need to
* set d_len to zero so that the driver is aware that there
* is nothing to be sent.
*/
nwarn("WARNING: Packet not processed\n");
ret = ERROR;
ret = -EAGAIN;
}
}
else

View file

@ -268,7 +268,7 @@ int tcp_accept_connection(FAR struct net_driver_s *dev,
FAR struct tcp_conn_s *conn, uint16_t portno)
{
FAR struct tcp_conn_s *listener;
int ret = ERROR;
int ret = -EINVAL;
/* The event processing logic has already allocated and initialized a TCP
* connection -- now check there if is an application in place to accept

View file

@ -72,11 +72,11 @@
* iplen - Length of the IP and UDP headers
*
* Returned Value:
* OK - The packet has been processed and can be deleted
* ERROR - Hold the packet and try again later. There is a listening
* socket but no receive in place to catch the packet yet. The
* device's d_len will be set to zero in this case as there is
* no outgoing data.
* OK - The packet has been processed and can be deleted
* -EAGAIN - Hold the packet and try again later. There is a listening
* socket but no receive in place to catch the packet yet. The
* device's d_len will be set to zero in this case as there is
* no outgoing data.
*
* Assumptions:
* The network is locked.
@ -200,7 +200,7 @@ static int udp_input(FAR struct net_driver_s *dev, unsigned int iplen)
if ((flags & UDP_NEWDATA) != 0)
{
/* No.. the packet was not processed now. Return ERROR so
/* No.. the packet was not processed now. Return -EAGAIN so
* that the driver may retry again later. We still need to
* set d_len to zero so that the driver is aware that there
* is nothing to be sent.
@ -208,7 +208,7 @@ static int udp_input(FAR struct net_driver_s *dev, unsigned int iplen)
nwarn("WARNING: Packet not processed\n");
dev->d_len = 0;
ret = ERROR;
ret = -EAGAIN;
}
/* If the application has data to send, setup the UDP/IP header */

View file

@ -50,6 +50,7 @@
#include <queue.h>
#include <string.h>
#include <assert.h>
#include <errno.h>
#include <debug.h>
#include <nuttx/semaphore.h>
@ -212,7 +213,7 @@ int udp_wrbuffer_test(void)
{
int val = 0;
nxsem_getvalue(&g_wrbuffer.sem, &val);
return val > 0 ? OK : ERROR;
return val > 0 ? OK : -ENOSPC;
}
#endif /* CONFIG_NET && CONFIG_NET_UDP && CONFIG_NET_UDP_WRITE_BUFFERS */