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:
parent
359753adee
commit
69056d4053
@ -51,8 +51,8 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <debug.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <debug.h>
|
||||||
|
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <net/ethernet.h>
|
#include <net/ethernet.h>
|
||||||
@ -774,7 +774,7 @@ static int c5471_phyinit (void)
|
|||||||
if (phyid != LU3X31_T64_PHYID)
|
if (phyid != LU3X31_T64_PHYID)
|
||||||
{
|
{
|
||||||
nerr("ERROR: Unrecognized PHY ID: %08x\n", phyid);
|
nerr("ERROR: Unrecognized PHY ID: %08x\n", phyid);
|
||||||
return ERROR;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Next, Set desired network rate, 10BaseT, 100BaseT, or auto. */
|
/* Next, Set desired network rate, 10BaseT, 100BaseT, or auto. */
|
||||||
|
@ -45,6 +45,7 @@
|
|||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
#if defined(CONFIG_NET) && defined(CONFIG_NET_PKT)
|
#if defined(CONFIG_NET) && defined(CONFIG_NET_PKT)
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
#include <nuttx/net/netdev.h>
|
#include <nuttx/net/netdev.h>
|
||||||
@ -73,10 +74,10 @@
|
|||||||
* dev - The device driver structure containing the received packet
|
* dev - The device driver structure containing the received packet
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* OK The packet has been processed and can be deleted
|
* OK The packet has been processed and can be deleted
|
||||||
* ERROR There is a matching connection, but could not dispatch the packet
|
* -EAGAIN There is a matching connection, but could not dispatch the packet
|
||||||
* yet. Useful when a packet arrives before a recv call is in
|
* yet. Useful when a packet arrives before a recv call is in
|
||||||
* place.
|
* place.
|
||||||
*
|
*
|
||||||
* Assumptions:
|
* Assumptions:
|
||||||
* The network is locked.
|
* The network is locked.
|
||||||
@ -109,14 +110,14 @@ int pkt_input(struct net_driver_s *dev)
|
|||||||
|
|
||||||
if ((flags & PKT_NEWDATA) != 0)
|
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
|
* that the driver may retry again later. We still need to
|
||||||
* set d_len to zero so that the driver is aware that there
|
* set d_len to zero so that the driver is aware that there
|
||||||
* is nothing to be sent.
|
* is nothing to be sent.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
nwarn("WARNING: Packet not processed\n");
|
nwarn("WARNING: Packet not processed\n");
|
||||||
ret = ERROR;
|
ret = -EAGAIN;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -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 *conn, uint16_t portno)
|
||||||
{
|
{
|
||||||
FAR struct tcp_conn_s *listener;
|
FAR struct tcp_conn_s *listener;
|
||||||
int ret = ERROR;
|
int ret = -EINVAL;
|
||||||
|
|
||||||
/* The event processing logic has already allocated and initialized a TCP
|
/* The event processing logic has already allocated and initialized a TCP
|
||||||
* connection -- now check there if is an application in place to accept
|
* connection -- now check there if is an application in place to accept
|
||||||
|
@ -72,11 +72,11 @@
|
|||||||
* iplen - Length of the IP and UDP headers
|
* iplen - Length of the IP and UDP headers
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* OK - The packet has been processed and can be deleted
|
* OK - The packet has been processed and can be deleted
|
||||||
* ERROR - Hold the packet and try again later. There is a listening
|
* -EAGAIN - Hold the packet and try again later. There is a listening
|
||||||
* socket but no receive in place to catch the packet yet. The
|
* 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
|
* device's d_len will be set to zero in this case as there is
|
||||||
* no outgoing data.
|
* no outgoing data.
|
||||||
*
|
*
|
||||||
* Assumptions:
|
* Assumptions:
|
||||||
* The network is locked.
|
* 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)
|
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
|
* that the driver may retry again later. We still need to
|
||||||
* set d_len to zero so that the driver is aware that there
|
* set d_len to zero so that the driver is aware that there
|
||||||
* is nothing to be sent.
|
* 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");
|
nwarn("WARNING: Packet not processed\n");
|
||||||
dev->d_len = 0;
|
dev->d_len = 0;
|
||||||
ret = ERROR;
|
ret = -EAGAIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If the application has data to send, setup the UDP/IP header */
|
/* If the application has data to send, setup the UDP/IP header */
|
||||||
|
@ -50,6 +50,7 @@
|
|||||||
#include <queue.h>
|
#include <queue.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <errno.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
#include <nuttx/semaphore.h>
|
#include <nuttx/semaphore.h>
|
||||||
@ -212,7 +213,7 @@ int udp_wrbuffer_test(void)
|
|||||||
{
|
{
|
||||||
int val = 0;
|
int val = 0;
|
||||||
nxsem_getvalue(&g_wrbuffer.sem, &val);
|
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 */
|
#endif /* CONFIG_NET && CONFIG_NET_UDP && CONFIG_NET_UDP_WRITE_BUFFERS */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user