From fca919f3d276ca86f9deb911a71a3ed635872d2a Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sun, 5 Jul 2015 11:18:56 -0600 Subject: [PATCH] Networking: Fix some compilation issues noted with network is build with CONFIG_BUILD_KERNEL --- fs/vfs/fs_select.c | 2 +- net/arp/arp_notify.c | 2 +- net/igmp/igmp_msg.c | 2 +- net/local/local_accept.c | 2 +- net/local/local_fifo.c | 8 ++++---- net/local/local_recvutils.c | 2 +- net/local/local_sendpacket.c | 2 +- net/netdev/netdev_ioctl.c | 2 +- net/socket/connect.c | 4 ++-- net/socket/net_dupsd.c | 2 +- net/socket/net_dupsd2.c | 2 +- net/socket/net_sendfile.c | 4 ++-- net/socket/net_vfcntl.c | 3 ++- net/socket/recvfrom.c | 2 +- net/socket/socket.c | 2 +- net/utils/net_lock.c | 2 +- 16 files changed, 22 insertions(+), 21 deletions(-) diff --git a/fs/vfs/fs_select.c b/fs/vfs/fs_select.c index 47fa65004b..60151232f2 100644 --- a/fs/vfs/fs_select.c +++ b/fs/vfs/fs_select.c @@ -103,7 +103,7 @@ int select(int nfds, FAR fd_set *readfds, FAR fd_set *writefds, FAR fd_set *exceptfds, FAR struct timeval *timeout) { struct pollfd *pollset; - int errcode; + int errcode = OK; int fd; int npfds; int msec; diff --git a/net/arp/arp_notify.c b/net/arp/arp_notify.c index 86427e232e..e5a1559502 100644 --- a/net/arp/arp_notify.c +++ b/net/arp/arp_notify.c @@ -204,7 +204,7 @@ int arp_wait(FAR struct arp_notify_s *notify, FAR struct timespec *timeout) */ ret = net_timedwait(¬ify->nt_sem, &abstime); - errcode = ((ret < 0) ? errno : 0); + errcode = ((ret < 0) ? get_errno() : 0); } while (ret < 0 && errcode == EINTR); diff --git a/net/igmp/igmp_msg.c b/net/igmp/igmp_msg.c index aef5965fd1..d680541d95 100644 --- a/net/igmp/igmp_msg.c +++ b/net/igmp/igmp_msg.c @@ -127,7 +127,7 @@ void igmp_waitmsg(FAR struct igmp_group_s *group, uint8_t msgid) * the wait is awakened by a signal. */ - ASSERT(errno == EINTR); + ASSERT(get_errno() == EINTR); } } diff --git a/net/local/local_accept.c b/net/local/local_accept.c index 00eaf0da3b..0c393dcf21 100644 --- a/net/local/local_accept.c +++ b/net/local/local_accept.c @@ -72,7 +72,7 @@ static int local_waitlisten(FAR struct local_conn_s *server) ret = sem_wait(&server->lc_waitsem); if (ret < 0) { - int errval = errno; + int errval = get_errno(); DEBUGASSERT(errval == EINTR); return -errval; } diff --git a/net/local/local_fifo.c b/net/local/local_fifo.c index 0e4b3d667c..569aa92a01 100644 --- a/net/local/local_fifo.c +++ b/net/local/local_fifo.c @@ -186,7 +186,7 @@ static int local_create_fifo(FAR const char *path) ret = mkfifo(path, 0644); if (ret < 0) { - int errcode = errno; + int errcode = get_errno(); DEBUGASSERT(errcode > 0); ndbg("ERROR: Failed to create FIFO %s: %d\n", path, errcode); @@ -227,7 +227,7 @@ static int local_release_fifo(FAR const char *path) ret = unlink(path); if (ret < 0) { - int errcode = errno; + int errcode = get_errno(); DEBUGASSERT(errcode > 0); ndbg("ERROR: Failed to unlink FIFO %s: %d\n", path, errcode); @@ -257,7 +257,7 @@ static int local_rx_open(FAR struct local_conn_s *conn, FAR const char *path, conn->lc_infd = open(path, oflags); if (conn->lc_infd < 0) { - int errcode = errno; + int errcode = get_errno(); DEBUGASSERT(errcode > 0); ndbg("ERROR: Failed on open %s for reading: %d\n", @@ -293,7 +293,7 @@ static int local_tx_open(FAR struct local_conn_s *conn, FAR const char *path, conn->lc_outfd = open(path, oflags); if (conn->lc_outfd < 0) { - int errcode = errno; + int errcode = get_errno(); DEBUGASSERT(errcode > 0); ndbg("ERROR: Failed on open %s for writing: %d\n", diff --git a/net/local/local_recvutils.c b/net/local/local_recvutils.c index f6e638ab01..27272a59db 100644 --- a/net/local/local_recvutils.c +++ b/net/local/local_recvutils.c @@ -88,7 +88,7 @@ int local_fifo_read(int fd, FAR uint8_t *buf, size_t *len) nread = read(fd, buf, remaining); if (nread < 0) { - int errcode = errno; + int errcode = get_errno(); DEBUGASSERT(errcode > 0); if (errcode != EINTR) diff --git a/net/local/local_sendpacket.c b/net/local/local_sendpacket.c index d32a09f34f..c55aa7efbf 100644 --- a/net/local/local_sendpacket.c +++ b/net/local/local_sendpacket.c @@ -95,7 +95,7 @@ static int local_fifo_write(int fd, FAR const uint8_t *buf, size_t len) nwritten = write(fd, buf, len); if (nwritten < 0) { - int errcode = errno; + int errcode = get_errno(); DEBUGASSERT(errcode > 0); if (errcode != EINTR) diff --git a/net/netdev/netdev_ioctl.c b/net/netdev/netdev_ioctl.c index dfeba23748..627d8025c8 100644 --- a/net/netdev/netdev_ioctl.c +++ b/net/netdev/netdev_ioctl.c @@ -989,7 +989,7 @@ int netdev_ioctl(int sockfd, int cmd, unsigned long arg) /* On failure, set the errno and return -1 */ errout: - errno = -ret; + set_errno(-ret); return ERROR; } diff --git a/net/socket/connect.c b/net/socket/connect.c index 35de1e531c..7360d611c6 100644 --- a/net/socket/connect.c +++ b/net/socket/connect.c @@ -375,7 +375,7 @@ static inline int psock_tcp_connect(FAR struct socket *psock, if (ret < 0) { - ret = -errno; + ret = -get_errno(); } else { @@ -641,7 +641,7 @@ int psock_connect(FAR struct socket *psock, FAR const struct sockaddr *addr, return OK; errout: - errno = err; + set_errno(err); return ERROR; } diff --git a/net/socket/net_dupsd.c b/net/socket/net_dupsd.c index 0af6fce57d..6381c45d52 100644 --- a/net/socket/net_dupsd.c +++ b/net/socket/net_dupsd.c @@ -140,7 +140,7 @@ int net_dupsd(int sockfd, int minsd) errout: sched_unlock(); - errno = err; + set_errno(err); return ERROR; } diff --git a/net/socket/net_dupsd2.c b/net/socket/net_dupsd2.c index fa09ce4ccb..96c3d18315 100644 --- a/net/socket/net_dupsd2.c +++ b/net/socket/net_dupsd2.c @@ -116,7 +116,7 @@ int dup2(int sockfd1, int sockfd2) errout: sched_unlock(); - errno = err; + set_errno(err); return ERROR; } diff --git a/net/socket/net_sendfile.c b/net/socket/net_sendfile.c index 61548264ae..2f6c3c9bb5 100644 --- a/net/socket/net_sendfile.c +++ b/net/socket/net_sendfile.c @@ -373,7 +373,7 @@ static uint16_t sendfile_interrupt(FAR struct net_driver_s *dev, FAR void *pvcon pstate->snd_foffset + pstate->snd_sent, SEEK_SET); if (ret < 0) { - int errcode = errno; + int errcode = get_errno(); nlldbg("failed to lseek: %d\n", errcode); pstate->snd_sent = -errcode; goto end_wait; @@ -382,7 +382,7 @@ static uint16_t sendfile_interrupt(FAR struct net_driver_s *dev, FAR void *pvcon ret = file_read(pstate->snd_file, dev->d_appdata, sndlen); if (ret < 0) { - int errcode = errno; + int errcode = get_errno(); nlldbg("failed to read from input file: %d\n", errcode); pstate->snd_sent = -errcode; goto end_wait; diff --git a/net/socket/net_vfcntl.c b/net/socket/net_vfcntl.c index ac43604e7d..5341328a7b 100644 --- a/net/socket/net_vfcntl.c +++ b/net/socket/net_vfcntl.c @@ -280,9 +280,10 @@ int net_vfcntl(int sockfd, int cmd, va_list ap) errout: if (err != 0) { - errno = err; + set_errno(err); return ERROR; } + return ret; } diff --git a/net/socket/recvfrom.c b/net/socket/recvfrom.c index dc4c5edba7..cf26072ac9 100644 --- a/net/socket/recvfrom.c +++ b/net/socket/recvfrom.c @@ -1206,7 +1206,7 @@ static void recvfrom_init(FAR struct socket *psock, FAR void *buf, #if defined(CONFIG_NET_UDP) || defined(CONFIG_NET_TCP) static ssize_t recvfrom_result(int result, struct recvfrom_s *pstate) { - int save_errno = errno; /* In case something we do changes it */ + int save_errno = get_errno(); /* In case something we do changes it */ /* Check for a error/timeout detected by the interrupt handler. Errors are * signaled by negative errno values for the rcv length diff --git a/net/socket/socket.c b/net/socket/socket.c index e44adeb3a3..2c8376e1e7 100644 --- a/net/socket/socket.c +++ b/net/socket/socket.c @@ -288,7 +288,7 @@ int psock_socket(int domain, int type, int protocol, FAR struct socket *psock) goto errout; } -#if !defined(CONFIG_NET_TCP) && !defined(CONFIG_NET_UDP) +#if defined(CONFIG_NET_LOCAL) && !defined(CONFIG_NET_LOCAL_STREAM) && !defined(CONFIG_NET_LOCAL_DGRAM) UNUSED(ipdomain); #endif diff --git a/net/utils/net_lock.c b/net/utils/net_lock.c index 1469387278..da359840ce 100644 --- a/net/utils/net_lock.c +++ b/net/utils/net_lock.c @@ -86,7 +86,7 @@ static void _net_takesem(void) * awakened by a signal. */ - ASSERT(errno == EINTR); + ASSERT(get_errno() == EINTR); } }