binfmt/, drivers/, graphics/: Fix several inappropriate accesses to get_errno() that were missed in previous changes (some going back to nuttx-.23).

This commit is contained in:
Gregory Nutt 2018-01-30 17:23:10 -06:00
parent 82982f7972
commit 30f2927101
11 changed files with 44 additions and 118 deletions

View File

@ -52,14 +52,6 @@
#if !defined(CONFIG_BINFMT_DISABLE) && defined(CONFIG_SCHED_HAVE_PARENT)
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/

View File

@ -566,7 +566,7 @@ static void wm8776_senddone(FAR struct i2s_dev_s *i2s,
CONFIG_WM8776_MSG_PRIO);
if (ret < 0)
{
auderr("ERROR: mq_send failed: %d\n", errno);
auderr("ERROR: mq_send failed: %d\n", get_errno());
}
}
@ -913,7 +913,7 @@ static int wm8776_enqueuebuffer(FAR struct audio_lowerhalf_s *dev,
CONFIG_WM8776_MSG_PRIO);
if (ret < 0)
{
int errcode = errno;
int errcode = get_errno();
DEBUGASSERT(errcode > 0);
auderr("ERROR: mq_send failed: %d\n", errcode);

View File

@ -234,7 +234,7 @@ static ssize_t loop_read(FAR struct inode *inode, FAR unsigned char *buffer,
FAR struct loop_struct_s *dev;
ssize_t nbytesread;
off_t offset;
int ret;
off_t ret;
DEBUGASSERT(inode && inode->i_private);
dev = (FAR struct loop_struct_s *)inode->i_private;
@ -249,10 +249,9 @@ static ssize_t loop_read(FAR struct inode *inode, FAR unsigned char *buffer,
offset = start_sector * dev->sectsize + dev->offset;
ret = file_seek(&dev->devfile, offset, SEEK_SET);
if (ret == (off_t)-1)
if (ret < 0)
{
ferr("ERROR: Seek failed for offset=%d: %d\n",
(int)offset, get_errno());
ferr("ERROR: Seek failed for offset=%d: %d\n", (int)offset, (int)ret);
return -EIO;
}
@ -290,7 +289,7 @@ static ssize_t loop_write(FAR struct inode *inode,
FAR struct loop_struct_s *dev;
ssize_t nbyteswritten;
off_t offset;
int ret;
off_t ret;
DEBUGASSERT(inode && inode->i_private);
dev = (FAR struct loop_struct_s *)inode->i_private;
@ -299,10 +298,9 @@ static ssize_t loop_write(FAR struct inode *inode,
offset = start_sector * dev->sectsize + dev->offset;
ret = file_seek(&dev->devfile, offset, SEEK_SET);
if (ret == (off_t)-1)
if (ret < 0)
{
ferr("ERROR: Seek failed for offset=%d: %d\n",
(int)offset, get_errno());
ferr("ERROR: Seek failed for offset=%d: %d\n", (int)offset, (int)ret);
}
/* Then write the requested number of sectors to that position */

View File

@ -79,7 +79,7 @@ static int syslogstream_flush(FAR struct lib_syslogstream_s *stream)
(size_t)iob->io_len);
if (nbytes < 0)
{
ret = -get_errno();
ret = (int)nbytes;
}
else
{
@ -172,18 +172,18 @@ static void syslogstream_putc(FAR struct lib_outstream_s *this, int ch)
*/
ret = syslog_putc(ch);
if (ret != EOF)
if (ret >= 0)
{
this->nput++;
return;
}
/* The special errno value -EINTR means that syslog_putc() was
/* The special return value -EINTR means that syslog_putc() was
* awakened by a signal. This is not a real error and must be
* ignored in this context.
*/
}
while (get_errno() == -EINTR);
while (ret == -EINTR);
}
}
}

View File

@ -231,7 +231,7 @@ int usbmonitor_start(void)
(FAR char * const *)NULL);
if (ret < 0)
{
int errcode = errno;
int errcode = get_errno();
uerr("ERROR: Failed to start the USB monitor: %d\n",
errcode);
UNUSED(errcode);

View File

@ -130,7 +130,7 @@ int cc3000_socket(int domain, int type, int protocol)
if (type < SOCK_STREAM || type >= ARRAY_SIZE(bsd2ti_types))
{
errno = EPROTOTYPE;
set_errno(EPROTOTYPE);
return -1;
}
@ -145,7 +145,7 @@ int cc3000_socket(int domain, int type, int protocol)
break;
default:
errno = EAFNOSUPPORT;
set_errno(EAFNOSUPPORT);
return -1;
}
@ -163,7 +163,7 @@ int cc3000_socket(int domain, int type, int protocol)
break;
default:
errno = EPROTONOSUPPORT;
set_errno(EPROTONOSUPPORT);
return -1;
}

View File

@ -512,15 +512,16 @@ int cc3000_gethostbyname_impl(char *hostname, uint16_t usNameLen,
unsigned long *out_ip_addr)
{
tBsdGethostbynameParams ret;
uint8_t *ptr, *args;
set_errno(EFAIL);
uint8_t *ptr;
uint8_t *args;
if (usNameLen > CC3000_HOSTNAME_MAX_LENGTH)
{
return get_errno();
return -EINVAL;
}
ret.retVal = OK;
ptr = tSLInformation.pucTxCommandBuffer;
args = (ptr + SIMPLE_LINK_HCI_CMND_TRANSPORT_HEADER_SIZE);
@ -539,11 +540,9 @@ int cc3000_gethostbyname_impl(char *hostname, uint16_t usNameLen,
SimpleLinkWaitEvent(HCI_EVNT_BSD_GETHOSTBYNAME, &ret);
set_errno(ret.retVal);
(*((FAR long *)out_ip_addr)) = ret.outputAddress;
return ret.retVal;
return (int)ret.retVal;
}
#endif

View File

@ -39,32 +39,13 @@
#include <nuttx/config.h>
#include <assert.h>
#include <errno.h>
#include <debug.h>
#include <nuttx/nx/nx.h>
#include "nxfe.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Types
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
@ -92,12 +73,7 @@ void nxmu_requestbkgd(FAR struct nxfe_conn_s *conn,
FAR const struct nx_callback_s *cb,
FAR void *arg)
{
#ifdef CONFIG_DEBUG_FEATURES
if (!conn || !be || !cb)
{
errno = EINVAL;
}
#endif
DEBUGASSERT(conn != NULL || be != NULL || cb != NULL);
/* Set the client's callback vtable and and replace the server
* connection with the clients connection.

View File

@ -45,6 +45,7 @@
#include <semaphore.h>
#include <mqueue.h>
#include <fcntl.h>
#include <assert.h>
#include <errno.h>
#include <debug.h>
@ -53,22 +54,6 @@
#include "nxfe.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Types
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
@ -190,7 +175,7 @@ static inline int nxmu_setup(FAR const char *mqname, FAR NX_DRIVERTYPE *dev,
if (ret < 0)
{
gerr("ERROR: nxbe_configure failed: %d\n", -ret);
errno = -ret;
set_errno(-ret);
return ERROR;
}
@ -199,7 +184,7 @@ static inline int nxmu_setup(FAR const char *mqname, FAR NX_DRIVERTYPE *dev,
if (ret < 0)
{
gerr("ERROR: nxbe_colormap failed: %d\n", -ret);
errno = -ret;
set_errno(-ret);
return ERROR;
}
#endif /* CONFIG_FB_CMAP */
@ -301,15 +286,7 @@ int nx_runinstance(FAR const char *mqname, FAR NX_DRIVERTYPE *dev)
/* Initialization *********************************************************/
/* Sanity checking */
#ifdef CONFIG_DEBUG_FEATURES
if (!mqname || !dev)
{
errno = EINVAL;
return ERROR;
}
#endif
DEBUGASSERT(mqname != NULL || dev != NULL);
/* Initialize and configure the server */

View File

@ -158,10 +158,8 @@ int vnc_negotiate(FAR struct vnc_session_s *session)
nrecvd = psock_recv(&session->connect, session->inbuf, len, 0);
if (nrecvd < 0)
{
errcode = get_errno();
gerr("ERROR: Receive protocol confirmation failed: %d\n", errcode);
DEBUGASSERT(errcode > 0);
return -errcode;
gerr("ERROR: Receive protocol confirmation failed: %d\n", (int)nrecvd);
return (int)nrecvd;
}
else if (nrecvd == 0)
{
@ -226,10 +224,8 @@ int vnc_negotiate(FAR struct vnc_session_s *session)
sizeof(struct rfb_selected_sectype_s), 0);
if (nrecvd < 0)
{
errcode = get_errno();
gerr("ERROR: Receive SecurityType failed: %d\n", errcode);
DEBUGASSERT(errcode > 0);
return -errcode;
gerr("ERROR: Receive SecurityType failed: %d\n", (int)nrecvd);
return (int)nrecvd;
}
else if (nrecvd == 0)
{
@ -309,10 +305,8 @@ int vnc_negotiate(FAR struct vnc_session_s *session)
sizeof(struct rfb_clientinit_s), 0);
if (nrecvd < 0)
{
errcode = get_errno();
gerr("ERROR: Receive ClientInit failed: %d\n", errcode);
DEBUGASSERT(errcode > 0);
return -errcode;
gerr("ERROR: Receive ClientInit failed: %d\n", (int)nrecvd);
return (int)nrecvd;
}
else if (nrecvd == 0)
{
@ -383,10 +377,8 @@ int vnc_negotiate(FAR struct vnc_session_s *session)
sizeof(struct rfb_setpixelformat_s), 0);
if (nrecvd < 0)
{
errcode = get_errno();
gerr("ERROR: Receive SetPixelFormat failed: %d\n", errcode);
DEBUGASSERT(errcode > 0);
return -errcode;
gerr("ERROR: Receive SetPixelFormat failed: %d\n", (int)nrecvd);
return (int)nrecvd;
}
else if (nrecvd == 0)
{
@ -430,10 +422,8 @@ int vnc_negotiate(FAR struct vnc_session_s *session)
CONFIG_VNCSERVER_INBUFFER_SIZE, 0);
if (nrecvd < 0)
{
errcode = get_errno();
gerr("ERROR: Receive SetEncodings failed: %d\n", errcode);
DEBUGASSERT(errcode > 0);
return -errcode;
gerr("ERROR: Receive SetEncodings failed: %d\n", (int)nrecvd);
return (int)nrecvd;
}
else if (nrecvd == 0)
{

View File

@ -104,10 +104,8 @@ int vnc_read_remainder(FAR struct vnc_session_s *session, size_t msglen,
msglen - ntotal, 0);
if (nrecvd < 0)
{
errcode = get_errno();
gerr("ERROR: Receive message failed: %d\n", errcode);
DEBUGASSERT(errcode > 0);
return -errcode;
gerr("ERROR: Receive message failed: %d\n", (int)nrecvd);
return (int)recvd;
}
}
@ -155,10 +153,8 @@ int vnc_receiver(FAR struct vnc_session_s *session)
&tv, sizeof(struct timeval));
if (ret < 0)
{
errcode = get_errno();
gerr("ERROR: Failed to disable receive timeout: %d\n", errcode);
DEBUGASSERT(errcode > 0);
return -errcode;
gerr("ERROR: Failed to disable receive timeout: %d\n", ret);
return ret;
}
#endif
@ -174,10 +170,8 @@ int vnc_receiver(FAR struct vnc_session_s *session)
nrecvd = psock_recv(&session->connect, session->inbuf, 1, 0);
if (nrecvd < 0)
{
errcode = get_errno();
gerr("ERROR: Receive byte failed: %d\n", errcode);
DEBUGASSERT(errcode > 0);
return -errcode;
gerr("ERROR: Receive byte failed: %d\n", (int)nrecvd);
return (int)nrecvd;
}
/* A return value of zero means that the connection was gracefully