Reserver the name 'err' for other purposes

This commit is contained in:
Gregory Nutt 2016-06-11 14:40:07 -06:00
parent 1cdc746726
commit 86b79b33cf
49 changed files with 374 additions and 380 deletions

View File

@ -320,14 +320,14 @@ static inline void up_configbaud(struct up_dev_s *priv)
/* Test values calculated for every multiplier/divisor combination */ /* Test values calculated for every multiplier/divisor combination */
uint32_t tdiv; uint32_t tdiv;
uint32_t terr; uint32_t tmperr;
int tmulval; int tmulval;
int tdivaddval; int tdivaddval;
/* Optimal multiplier/divider values */ /* Optimal multiplier/divider values */
uint32_t div = 0; uint32_t div = 0;
uint32_t err = 100000; uint32_t errval = 100000;
int mulval = 1; int mulval = 1;
int divaddval = 0; int divaddval = 0;
@ -350,13 +350,13 @@ static inline void up_configbaud(struct up_dev_s *priv)
/* Try every valid multiplier, tmulval (or until a perfect match is found). */ /* Try every valid multiplier, tmulval (or until a perfect match is found). */
for (tmulval = 1; tmulval <= 15 && err > 0; tmulval++) for (tmulval = 1; tmulval <= 15 && errval > 0; tmulval++)
{ {
/* Try every valid pre-scale div, tdivaddval (or until a perfect match is /* Try every valid pre-scale div, tdivaddval (or until a perfect match is
* found). * found).
*/ */
for (tdivaddval = 0; tdivaddval <= 15 && err > 0; tdivaddval++) for (tdivaddval = 0; tdivaddval <= 15 && errval > 0; tdivaddval++)
{ {
/* Calculate the divisor with these fractional divider settings */ /* Calculate the divisor with these fractional divider settings */
@ -373,16 +373,16 @@ static inline void up_configbaud(struct up_dev_s *priv)
if (actualbaud <= priv->baud) if (actualbaud <= priv->baud)
{ {
terr = priv->baud - actualbaud; tmperr = priv->baud - actualbaud;
} }
else else
{ {
terr = actualbaud - priv->baud; tmperr = actualbaud - priv->baud;
} }
/* Is this the smallest error we have encountered? */ /* Is this the smallest error we have encountered? */
if (terr < err) if (tmperr < errval)
{ {
/* Yes, save these settings as the new, candidate optimal /* Yes, save these settings as the new, candidate optimal
* settings * settings
@ -391,7 +391,7 @@ static inline void up_configbaud(struct up_dev_s *priv)
mulval = tmulval; mulval = tmulval;
divaddval = tdivaddval; divaddval = tdivaddval;
div = tdiv; div = tdiv;
err = terr; errval = tmperr;
} }
} }
} }

View File

@ -144,14 +144,14 @@ static inline void up_configbaud(void)
/* Test values calculated for every multiplier/divisor combination */ /* Test values calculated for every multiplier/divisor combination */
uint32_t tdiv; uint32_t tdiv;
uint32_t terr; uint32_t tmperr;
int tmulval; int tmulval;
int tdivaddval; int tdivaddval;
/* Optimal multiplier/divider values */ /* Optimal multiplier/divider values */
uint32_t div = 0; uint32_t div = 0;
uint32_t err = 100000; uint32_t errval = 100000;
int mulval = 1; int mulval = 1;
int divaddval = 0; int divaddval = 0;
@ -176,13 +176,13 @@ static inline void up_configbaud(void)
* match is found). * match is found).
*/ */
for (tmulval = 1 ; tmulval <= 15 && err > 0; tmulval++) for (tmulval = 1 ; tmulval <= 15 && errval > 0; tmulval++)
{ {
/* Try every valid pre-scale div, tdivaddval (or until a perfect /* Try every valid pre-scale div, tdivaddval (or until a perfect
* match is found). * match is found).
*/ */
for (tdivaddval = 0 ; tdivaddval <= 15 && err > 0; tdivaddval++) for (tdivaddval = 0 ; tdivaddval <= 15 && errval > 0; tdivaddval++)
{ {
/* Calculate the divisor with these fractional divider settings */ /* Calculate the divisor with these fractional divider settings */
@ -199,23 +199,23 @@ static inline void up_configbaud(void)
if (actualbaud <= CONFIG_UART_BAUD) if (actualbaud <= CONFIG_UART_BAUD)
{ {
terr = CONFIG_UART_BAUD - actualbaud; tmperr = CONFIG_UART_BAUD - actualbaud;
} }
else else
{ {
terr = actualbaud - CONFIG_UART_BAUD; tmperr = actualbaud - CONFIG_UART_BAUD;
} }
/* Is this the smallest error we have encountered? */ /* Is this the smallest error we have encountered? */
if (terr < err) if (tmperr < errval)
{ {
/* Yes, save these settings as the new, candidate optimal settings */ /* Yes, save these settings as the new, candidate optimal settings */
mulval = tmulval ; mulval = tmulval ;
divaddval = tdivaddval; divaddval = tdivaddval;
div = tdiv; div = tdiv;
err = terr; errval = tmperr;
} }
} }
} }

View File

@ -215,14 +215,14 @@ static inline void up_configbaud(void)
/* Test values calculated for every multiplier/divisor combination */ /* Test values calculated for every multiplier/divisor combination */
uint32_t tdiv; uint32_t tdiv;
uint32_t terr; uint32_t tmperr;
int tmulval; int tmulval;
int tdivaddval; int tdivaddval;
/* Optimal multiplier/divider values */ /* Optimal multiplier/divider values */
uint32_t div = 0; uint32_t div = 0;
uint32_t err = 100000; uint32_t errval = 100000;
int mulval = 1; int mulval = 1;
int divaddval = 0; int divaddval = 0;
@ -247,13 +247,13 @@ static inline void up_configbaud(void)
* match is found). * match is found).
*/ */
for (tmulval = 1 ; tmulval <= 15 && err > 0; tmulval++) for (tmulval = 1 ; tmulval <= 15 && errval > 0; tmulval++)
{ {
/* Try every valid pre-scale div, tdivaddval (or until a perfect /* Try every valid pre-scale div, tdivaddval (or until a perfect
* match is found). * match is found).
*/ */
for (tdivaddval = 0 ; tdivaddval <= 15 && err > 0; tdivaddval++) for (tdivaddval = 0 ; tdivaddval <= 15 && errval > 0; tdivaddval++)
{ {
/* Calculate the divisor with these fractional divider settings */ /* Calculate the divisor with these fractional divider settings */
@ -270,23 +270,23 @@ static inline void up_configbaud(void)
if (actualbaud <= CONFIG_UART_BAUD) if (actualbaud <= CONFIG_UART_BAUD)
{ {
terr = CONFIG_UART_BAUD - actualbaud; tmperr = CONFIG_UART_BAUD - actualbaud;
} }
else else
{ {
terr = actualbaud - CONFIG_UART_BAUD; tmperr = actualbaud - CONFIG_UART_BAUD;
} }
/* Is this the smallest error we have encountered? */ /* Is this the smallest error we have encountered? */
if (terr < err) if (tmperr < errval)
{ {
/* Yes, save these settings as the new, candidate optimal settings */ /* Yes, save these settings as the new, candidate optimal settings */
mulval = tmulval ; mulval = tmulval ;
divaddval = tdivaddval; divaddval = tdivaddval;
div = tdiv; div = tdiv;
err = terr; errval = tmperr;
} }
} }
} }

View File

@ -785,50 +785,50 @@ uint32_t spifiGetSubBlockFromBlock(const SPIFI_HANDLE_T *pHandle, uint32_t block
SPIFI_ERR_T spifiProgram(const SPIFI_HANDLE_T *pHandle, uint32_t addr, const uint32_t *writeBuff, uint32_t bytes) SPIFI_ERR_T spifiProgram(const SPIFI_HANDLE_T *pHandle, uint32_t addr, const uint32_t *writeBuff, uint32_t bytes)
{ {
uint32_t sendBytes; uint32_t sendBytes;
SPIFI_ERR_T err = SPIFI_ERR_NONE; SPIFI_ERR_T errcode = SPIFI_ERR_NONE;
/* Program using up to page size */ /* Program using up to page size */
while ((bytes > 0) && (err == SPIFI_ERR_NONE)) { while ((bytes > 0) && (errcode == SPIFI_ERR_NONE)) {
sendBytes = bytes; sendBytes = bytes;
if (sendBytes > pHandle->pInfoData->pageSize) { if (sendBytes > pHandle->pInfoData->pageSize) {
sendBytes = pHandle->pInfoData->pageSize; sendBytes = pHandle->pInfoData->pageSize;
} }
err = pHandle->pFamFx->pageProgram(pHandle, addr, writeBuff, sendBytes); errcode = pHandle->pFamFx->pageProgram(pHandle, addr, writeBuff, sendBytes);
addr += sendBytes; addr += sendBytes;
writeBuff += (sendBytes >> 2); writeBuff += (sendBytes >> 2);
bytes -= sendBytes; bytes -= sendBytes;
} }
return err; return errcode;
} }
/* Read the device into the passed buffer */ /* Read the device into the passed buffer */
SPIFI_ERR_T spifiRead(const SPIFI_HANDLE_T *pHandle, uint32_t addr, uint32_t *readBuff, uint32_t bytes) SPIFI_ERR_T spifiRead(const SPIFI_HANDLE_T *pHandle, uint32_t addr, uint32_t *readBuff, uint32_t bytes)
{ {
uint32_t readBytes; uint32_t readBytes;
SPIFI_ERR_T err = SPIFI_ERR_NONE; SPIFI_ERR_T errcode = SPIFI_ERR_NONE;
/* Read using up to the maximum read size */ /* Read using up to the maximum read size */
while ((bytes > 0) && (err == SPIFI_ERR_NONE)) { while ((bytes > 0) && (errcode == SPIFI_ERR_NONE)) {
readBytes = bytes; readBytes = bytes;
if (readBytes > pHandle->pInfoData->maxReadSize) { if (readBytes > pHandle->pInfoData->maxReadSize) {
readBytes = pHandle->pInfoData->maxReadSize; readBytes = pHandle->pInfoData->maxReadSize;
} }
err = pHandle->pFamFx->read(pHandle, addr, readBuff, readBytes); errcode = pHandle->pFamFx->read(pHandle, addr, readBuff, readBytes);
addr += readBytes; addr += readBytes;
readBuff += (readBytes / sizeof(uint32_t)); readBuff += (readBytes / sizeof(uint32_t));
bytes -= readBytes; bytes -= readBytes;
} }
return err; return errcode;
} }
/* Erase multiple blocks */ /* Erase multiple blocks */
SPIFI_ERR_T spifiErase(const SPIFI_HANDLE_T *pHandle, uint32_t firstBlock, uint32_t numBlocks) SPIFI_ERR_T spifiErase(const SPIFI_HANDLE_T *pHandle, uint32_t firstBlock, uint32_t numBlocks)
{ {
SPIFI_ERR_T err = SPIFI_ERR_NONE; SPIFI_ERR_T errcode = SPIFI_ERR_NONE;
if ((firstBlock + numBlocks) > pHandle->pInfoData->numBlocks) { if ((firstBlock + numBlocks) > pHandle->pInfoData->numBlocks) {
return SPIFI_ERR_RANGE; return SPIFI_ERR_RANGE;
@ -836,20 +836,20 @@ SPIFI_ERR_T spifiErase(const SPIFI_HANDLE_T *pHandle, uint32_t firstBlock, uint3
/* Only perform erase if numBlocks is != 0 */ /* Only perform erase if numBlocks is != 0 */
for (; (numBlocks); ++firstBlock, --numBlocks) { for (; (numBlocks); ++firstBlock, --numBlocks) {
err = pHandle->pFamFx->eraseBlock(pHandle, firstBlock); errcode = pHandle->pFamFx->eraseBlock(pHandle, firstBlock);
if (err != SPIFI_ERR_NONE) { if (errcode != SPIFI_ERR_NONE) {
break; break;
} }
} }
return err; return errcode;
} }
/* Erase multiple blocks by address range */ /* Erase multiple blocks by address range */
SPIFI_ERR_T spifiEraseByAddr(const SPIFI_HANDLE_T *pHandle, uint32_t firstAddr, uint32_t lastAddr) SPIFI_ERR_T spifiEraseByAddr(const SPIFI_HANDLE_T *pHandle, uint32_t firstAddr, uint32_t lastAddr)
{ {
uint32_t firstBlock, lastBlock; uint32_t firstBlock, lastBlock;
SPIFI_ERR_T err = SPIFI_ERR_RANGE; SPIFI_ERR_T errcode = SPIFI_ERR_RANGE;
/* Get block numbers for addresses */ /* Get block numbers for addresses */
firstBlock = spifiGetBlockFromAddr(pHandle, firstAddr); firstBlock = spifiGetBlockFromAddr(pHandle, firstAddr);
@ -857,8 +857,8 @@ SPIFI_ERR_T spifiEraseByAddr(const SPIFI_HANDLE_T *pHandle, uint32_t firstAddr,
/* Limit to legal address range */ /* Limit to legal address range */
if ((firstBlock != ~0UL) && (lastBlock != ~0UL)) { if ((firstBlock != ~0UL) && (lastBlock != ~0UL)) {
err = spifiErase(pHandle, firstBlock, ((lastBlock - firstBlock) + 1)); errcode = spifiErase(pHandle, firstBlock, ((lastBlock - firstBlock) + 1));
} }
return err; return errcode;
} }

View File

@ -315,11 +315,11 @@ static void up_shutdown(struct uart_dev_s *dev)
static int up_attach(struct uart_dev_s *dev) static int up_attach(struct uart_dev_s *dev)
{ {
struct up_dev_s *priv = dev->priv; struct up_dev_s *priv = dev->priv;
int err; int errcode;
err = rgmp_request_irq(priv->irq, &priv->action, 0); errcode = rgmp_request_irq(priv->irq, &priv->action, 0);
return err; return errcode;
} }
/**************************************************************************** /****************************************************************************
@ -578,15 +578,15 @@ void up_earlyserialinit(void)
void up_serialinit(void) void up_serialinit(void)
{ {
uart_dev_t *dev; uart_dev_t *dev;
int err; int errcode;
#ifdef CONFIG_COM1 #ifdef CONFIG_COM1
dev = up_alloc_com(COM1, 4); dev = up_alloc_com(COM1, 4);
if (dev == NULL) if (dev == NULL)
dbg("alloc com1 fail\n"); dbg("alloc com1 fail\n");
else { else {
err = uart_register("/dev/ttyS0", dev); errcode = uart_register("/dev/ttyS0", dev);
if (err) if (errcode)
dbg("register com1 fail\n"); dbg("register com1 fail\n");
} }
#endif #endif
@ -595,8 +595,8 @@ void up_serialinit(void)
if (dev == NULL) if (dev == NULL)
dbg("alloc com2 fail\n"); dbg("alloc com2 fail\n");
else { else {
err = uart_register("/dev/ttyS1", dev); errcode = uart_register("/dev/ttyS1", dev);
if (err) if (errcode)
dbg("register com2 fail\n"); dbg("register com2 fail\n");
} }
#endif #endif
@ -605,8 +605,8 @@ void up_serialinit(void)
if (dev == NULL) if (dev == NULL)
dbg("alloc com3 fail\n"); dbg("alloc com3 fail\n");
else { else {
err = uart_register("/dev/ttyS2", dev); errcode = uart_register("/dev/ttyS2", dev);
if (err) if (errcode)
dbg("register com3 fail\n"); dbg("register com3 fail\n");
} }
#endif #endif
@ -615,8 +615,8 @@ void up_serialinit(void)
if (dev == NULL) if (dev == NULL)
dbg("alloc com4 fail\n"); dbg("alloc com4 fail\n");
else { else {
err = uart_register("/dev/ttyS3", dev); errcode = uart_register("/dev/ttyS3", dev);
if (err) if (errcode)
dbg("register com4 fail\n"); dbg("register com4 fail\n");
} }
#endif #endif

View File

@ -86,7 +86,7 @@ int exec(FAR const char *filename, FAR char * const *argv,
#if defined(CONFIG_SCHED_ONEXIT) && defined(CONFIG_SCHED_HAVE_PARENT) #if defined(CONFIG_SCHED_ONEXIT) && defined(CONFIG_SCHED_HAVE_PARENT)
FAR struct binary_s *bin; FAR struct binary_s *bin;
int pid; int pid;
int err; int errcode;
int ret; int ret;
/* Allocate the load information */ /* Allocate the load information */
@ -95,7 +95,7 @@ int exec(FAR const char *filename, FAR char * const *argv,
if (!bin) if (!bin)
{ {
bdbg("ERROR: Failed to allocate binary_s\n"); bdbg("ERROR: Failed to allocate binary_s\n");
err = ENOMEM; errcode = ENOMEM;
goto errout; goto errout;
} }
@ -110,8 +110,8 @@ int exec(FAR const char *filename, FAR char * const *argv,
ret = binfmt_copyargv(bin, argv); ret = binfmt_copyargv(bin, argv);
if (ret < 0) if (ret < 0)
{ {
err = -ret; errcode = -ret;
bdbg("ERROR: Failed to copy argv[]: %d\n", err); bdbg("ERROR: Failed to copy argv[]: %d\n", errcode);
goto errout_with_bin; goto errout_with_bin;
} }
@ -120,8 +120,8 @@ int exec(FAR const char *filename, FAR char * const *argv,
ret = load_module(bin); ret = load_module(bin);
if (ret < 0) if (ret < 0)
{ {
err = get_errno(); errcode = get_errno();
bdbg("ERROR: Failed to load program '%s': %d\n", filename, err); bdbg("ERROR: Failed to load program '%s': %d\n", filename, errcode);
goto errout_with_argv; goto errout_with_argv;
} }
@ -137,8 +137,8 @@ int exec(FAR const char *filename, FAR char * const *argv,
pid = exec_module(bin); pid = exec_module(bin);
if (pid < 0) if (pid < 0)
{ {
err = get_errno(); errcode = get_errno();
bdbg("ERROR: Failed to execute program '%s': %d\n", filename, err); bdbg("ERROR: Failed to execute program '%s': %d\n", filename, errcode);
goto errout_with_lock; goto errout_with_lock;
} }
@ -149,8 +149,8 @@ int exec(FAR const char *filename, FAR char * const *argv,
ret = schedule_unload(pid, bin); ret = schedule_unload(pid, bin);
if (ret < 0) if (ret < 0)
{ {
err = get_errno(); errcode = get_errno();
bdbg("ERROR: Failed to schedule unload '%s': %d\n", filename, err); bdbg("ERROR: Failed to schedule unload '%s': %d\n", filename, errcode);
} }
sched_unlock(); sched_unlock();
@ -164,12 +164,12 @@ errout_with_argv:
errout_with_bin: errout_with_bin:
kmm_free(bin); kmm_free(bin);
errout: errout:
set_errno(err); set_errno(errcode);
return ERROR; return ERROR;
#else #else
struct binary_s bin; struct binary_s bin;
int err; int errcode;
int ret; int ret;
/* Load the module into memory */ /* Load the module into memory */
@ -182,8 +182,8 @@ errout:
ret = load_module(&bin); ret = load_module(&bin);
if (ret < 0) if (ret < 0)
{ {
err = get_errno(); errcode = get_errno();
bdbg("ERROR: Failed to load program '%s': %d\n", filename, err); bdbg("ERROR: Failed to load program '%s': %d\n", filename, errcode);
goto errout; goto errout;
} }
@ -192,8 +192,8 @@ errout:
ret = exec_module(&bin); ret = exec_module(&bin);
if (ret < 0) if (ret < 0)
{ {
err = get_errno(); errcode = get_errno();
bdbg("ERROR: Failed to execute program '%s': %d\n", filename, err); bdbg("ERROR: Failed to execute program '%s': %d\n", filename, errcode);
goto errout_with_module; goto errout_with_module;
} }
@ -204,10 +204,9 @@ errout:
errout_with_module: errout_with_module:
unload_module(&bin); unload_module(&bin);
errout: errout:
set_errno(err); set_errno(errcode);
return ERROR; return ERROR;
#endif #endif
} }
#endif /* !CONFIG_BINFMT_DISABLE */ #endif /* !CONFIG_BINFMT_DISABLE */

View File

@ -142,7 +142,7 @@ int exec_module(FAR const struct binary_s *binp)
#endif #endif
FAR uint32_t *stack; FAR uint32_t *stack;
pid_t pid; pid_t pid;
int err; int errcode;
int ret; int ret;
/* Sanity checking */ /* Sanity checking */
@ -150,7 +150,7 @@ int exec_module(FAR const struct binary_s *binp)
#ifdef CONFIG_DEBUG_FEATURES #ifdef CONFIG_DEBUG_FEATURES
if (!binp || !binp->entrypt || binp->stacksize <= 0) if (!binp || !binp->entrypt || binp->stacksize <= 0)
{ {
err = EINVAL; errcode = EINVAL;
goto errout; goto errout;
} }
#endif #endif
@ -162,7 +162,7 @@ int exec_module(FAR const struct binary_s *binp)
tcb = (FAR struct task_tcb_s *)kmm_zalloc(sizeof(struct task_tcb_s)); tcb = (FAR struct task_tcb_s *)kmm_zalloc(sizeof(struct task_tcb_s));
if (!tcb) if (!tcb)
{ {
err = ENOMEM; errcode = ENOMEM;
goto errout; goto errout;
} }
@ -173,7 +173,7 @@ int exec_module(FAR const struct binary_s *binp)
if (ret < 0) if (ret < 0)
{ {
bdbg("ERROR: up_addrenv_select() failed: %d\n", ret); bdbg("ERROR: up_addrenv_select() failed: %d\n", ret);
err = -ret; errcode = -ret;
goto errout_with_tcb; goto errout_with_tcb;
} }
@ -192,7 +192,7 @@ int exec_module(FAR const struct binary_s *binp)
stack = (FAR uint32_t *)kumm_malloc(binp->stacksize); stack = (FAR uint32_t *)kumm_malloc(binp->stacksize);
if (!stack) if (!stack)
{ {
err = ENOMEM; errcode = ENOMEM;
goto errout_with_addrenv; goto errout_with_addrenv;
} }
@ -202,8 +202,8 @@ int exec_module(FAR const struct binary_s *binp)
stack, binp->stacksize, binp->entrypt, binp->argv); stack, binp->stacksize, binp->entrypt, binp->argv);
if (ret < 0) if (ret < 0)
{ {
err = get_errno(); errcode = get_errno();
bdbg("task_init() failed: %d\n", err); bdbg("task_init() failed: %d\n", errcode);
goto errout_with_addrenv; goto errout_with_addrenv;
} }
@ -225,7 +225,7 @@ int exec_module(FAR const struct binary_s *binp)
if (ret < 0) if (ret < 0)
{ {
bdbg("ERROR: up_addrenv_select() failed: %d\n", ret); bdbg("ERROR: up_addrenv_select() failed: %d\n", ret);
err = -ret; errcode = -ret;
goto errout_with_tcbinit; goto errout_with_tcbinit;
} }
#endif #endif
@ -237,7 +237,7 @@ int exec_module(FAR const struct binary_s *binp)
if (ret < 0) if (ret < 0)
{ {
bdbg("ERROR: shm_group_initialize() failed: %d\n", ret); bdbg("ERROR: shm_group_initialize() failed: %d\n", ret);
err = -ret; errcode = -ret;
goto errout_with_tcbinit; goto errout_with_tcbinit;
} }
#endif #endif
@ -260,7 +260,7 @@ int exec_module(FAR const struct binary_s *binp)
ret = up_addrenv_clone(&binp->addrenv, &tcb->cmn.group->tg_addrenv); ret = up_addrenv_clone(&binp->addrenv, &tcb->cmn.group->tg_addrenv);
if (ret < 0) if (ret < 0)
{ {
err = -ret; errcode = -ret;
bdbg("ERROR: up_addrenv_clone() failed: %d\n", ret); bdbg("ERROR: up_addrenv_clone() failed: %d\n", ret);
goto errout_with_tcbinit; goto errout_with_tcbinit;
} }
@ -288,8 +288,8 @@ int exec_module(FAR const struct binary_s *binp)
ret = task_activate((FAR struct tcb_s *)tcb); ret = task_activate((FAR struct tcb_s *)tcb);
if (ret < 0) if (ret < 0)
{ {
err = get_errno(); errcode = get_errno();
bdbg("task_activate() failed: %d\n", err); bdbg("task_activate() failed: %d\n", errcode);
goto errout_with_tcbinit; goto errout_with_tcbinit;
} }
@ -300,7 +300,7 @@ int exec_module(FAR const struct binary_s *binp)
if (ret < 0) if (ret < 0)
{ {
bdbg("ERROR: up_addrenv_select() failed: %d\n", ret); bdbg("ERROR: up_addrenv_select() failed: %d\n", ret);
err = -ret; errcode = -ret;
goto errout_with_tcbinit; goto errout_with_tcbinit;
} }
#endif #endif
@ -322,8 +322,8 @@ errout_with_tcb:
kmm_free(tcb); kmm_free(tcb);
errout: errout:
set_errno(err); set_errno(errcode);
bdbg("returning errno: %d\n", err); bdbg("returning errno: %d\n", errcode);
return ERROR; return ERROR;
} }

View File

@ -377,7 +377,7 @@ static int adc_receive(FAR struct adc_dev_s *dev, uint8_t ch, int32_t data)
{ {
FAR struct adc_fifo_s *fifo = &dev->ad_recv; FAR struct adc_fifo_s *fifo = &dev->ad_recv;
int nexttail; int nexttail;
int err = -ENOMEM; int errcode = -ENOMEM;
/* Check if adding this new message would over-run the drivers ability to enqueue /* Check if adding this new message would over-run the drivers ability to enqueue
* read data. * read data.
@ -407,9 +407,10 @@ static int adc_receive(FAR struct adc_dev_s *dev, uint8_t ch, int32_t data)
sem_post(&fifo->af_sem); sem_post(&fifo->af_sem);
} }
err = OK; errcode = OK;
} }
return err;
return errcode;
} }
/**************************************************************************** /****************************************************************************

View File

@ -1015,7 +1015,7 @@ int can_receive(FAR struct can_dev_s *dev, FAR struct can_hdr_s *hdr,
FAR struct can_rxfifo_s *fifo = &dev->cd_recv; FAR struct can_rxfifo_s *fifo = &dev->cd_recv;
FAR uint8_t *dest; FAR uint8_t *dest;
int nexttail; int nexttail;
int err = -ENOMEM; int errcode = -ENOMEM;
int i; int i;
canllinfo("ID: %d DLC: %d\n", hdr->ch_id, hdr->ch_dlc); canllinfo("ID: %d DLC: %d\n", hdr->ch_id, hdr->ch_dlc);
@ -1113,7 +1113,7 @@ int can_receive(FAR struct can_dev_s *dev, FAR struct can_hdr_s *hdr,
sem_post(&fifo->rx_sem); sem_post(&fifo->rx_sem);
} }
err = OK; errcode = OK;
} }
#ifdef CONFIG_CAN_ERRORS #ifdef CONFIG_CAN_ERRORS
else else
@ -1124,7 +1124,7 @@ int can_receive(FAR struct can_dev_s *dev, FAR struct can_hdr_s *hdr,
} }
#endif #endif
return err; return errcode;
} }
/**************************************************************************** /****************************************************************************

View File

@ -1089,7 +1089,7 @@ static int e1000_probe(uint16_t addr, pci_id_t id)
{ {
uint32_t mmio_base, mmio_size; uint32_t mmio_base, mmio_size;
uint32_t size; uint32_t size;
int err; int errcode;
void *kmem; void *kmem;
void *omem; void *omem;
struct e1000_dev *dev; struct e1000_dev *dev;
@ -1107,7 +1107,7 @@ static int e1000_probe(uint16_t addr, pci_id_t id)
/* enable device */ /* enable device */
if ((err = pci_enable_device(addr, PCI_BUS_MASTER)) < 0) if ((errcode = pci_enable_device(addr, PCI_BUS_MASTER)) < 0)
{ {
goto error; goto error;
} }
@ -1120,8 +1120,8 @@ static int e1000_probe(uint16_t addr, pci_id_t id)
mmio_base = pci_resource_start(addr, 0); mmio_base = pci_resource_start(addr, 0);
mmio_size = pci_resource_len(addr, 0); mmio_size = pci_resource_len(addr, 0);
err = rgmp_memmap_nocache(mmio_base, mmio_size, mmio_base); errcode = rgmp_memmap_nocache(mmio_base, mmio_size, mmio_base);
if (err) if (errcode)
{ {
goto error; goto error;
} }
@ -1139,7 +1139,7 @@ static int e1000_probe(uint16_t addr, pci_id_t id)
dev->int_desc.handler = e1000_interrupt_handler; dev->int_desc.handler = e1000_interrupt_handler;
dev->int_desc.dev_id = dev; dev->int_desc.dev_id = dev;
if ((err = pci_request_irq(addr, &dev->int_desc, 0)) < 0) if ((errcode = pci_request_irq(addr, &dev->int_desc, 0)) < 0)
{ {
goto err0; goto err0;
} }
@ -1164,7 +1164,7 @@ static int e1000_probe(uint16_t addr, pci_id_t id)
omem = kmem = memalign(PGSIZE, size); omem = kmem = memalign(PGSIZE, size);
if (kmem == NULL) if (kmem == NULL)
{ {
err = -ENOMEM; errcode = -ENOMEM;
goto err1; goto err1;
} }
@ -1211,8 +1211,8 @@ static int e1000_probe(uint16_t addr, pci_id_t id)
/* Register the device with the OS so that socket IOCTLs can be performed */ /* Register the device with the OS so that socket IOCTLs can be performed */
err = netdev_register(&dev->netdev, NET_LL_ETHERNET); errcode = netdev_register(&dev->netdev, NET_LL_ETHERNET);
if (err) if (errcode)
{ {
goto err2; goto err2;
} }
@ -1234,8 +1234,8 @@ err0:
rgmp_memunmap(mmio_base, mmio_size); rgmp_memunmap(mmio_base, mmio_size);
error: error:
kmm_free(dev); kmm_free(dev);
cprintf("e1000 device probe fail: %d\n", err); cprintf("e1000 device probe fail: %d\n", errcode);
return err; return errcode;
} }
/**************************************************************************** /****************************************************************************

View File

@ -169,7 +169,7 @@ static int vnet_rmmac(struct net_driver_s *dev, FAR const uint8_t *mac);
static int vnet_transmit(FAR struct vnet_driver_s *vnet) static int vnet_transmit(FAR struct vnet_driver_s *vnet)
{ {
int err; int errcode;
/* Verify that the hardware is ready to send another packet. If we get /* Verify that the hardware is ready to send another packet. If we get
* here, then we are committed to sending a packet; Higher level logic * here, then we are committed to sending a packet; Higher level logic
@ -178,8 +178,8 @@ static int vnet_transmit(FAR struct vnet_driver_s *vnet)
/* Send the packet: address=vnet->sk_dev.d_buf, length=vnet->sk_dev.d_len */ /* Send the packet: address=vnet->sk_dev.d_buf, length=vnet->sk_dev.d_len */
err = vnet_xmit(vnet->vnet, (char *)vnet->sk_dev.d_buf, vnet->sk_dev.d_len); errcode = vnet_xmit(vnet->vnet, (char *)vnet->sk_dev.d_buf, vnet->sk_dev.d_len);
if (err) if (errcode)
{ {
/* When vnet_xmit fail, it means TX buffer is full. Watchdog /* When vnet_xmit fail, it means TX buffer is full. Watchdog
* is of no use here because no TX done INT will happen. So * is of no use here because no TX done INT will happen. So

View File

@ -189,7 +189,7 @@ int pipe(int fd[2])
FAR struct pipe_dev_s *dev = NULL; FAR struct pipe_dev_s *dev = NULL;
char devname[16]; char devname[16];
int pipeno; int pipeno;
int err; int errcode;
int ret; int ret;
/* Get exclusive access to the pipe allocation data */ /* Get exclusive access to the pipe allocation data */
@ -208,7 +208,7 @@ int pipe(int fd[2])
if (pipeno < 0) if (pipeno < 0)
{ {
(void)sem_post(&g_pipesem); (void)sem_post(&g_pipesem);
err = -pipeno; errcode = -pipeno;
goto errout; goto errout;
} }
@ -226,7 +226,7 @@ int pipe(int fd[2])
if (!dev) if (!dev)
{ {
(void)sem_post(&g_pipesem); (void)sem_post(&g_pipesem);
err = ENOMEM; errcode = ENOMEM;
goto errout_with_pipe; goto errout_with_pipe;
} }
@ -238,7 +238,7 @@ int pipe(int fd[2])
if (ret != 0) if (ret != 0)
{ {
(void)sem_post(&g_pipesem); (void)sem_post(&g_pipesem);
err = -ret; errcode = -ret;
goto errout_with_dev; goto errout_with_dev;
} }
@ -254,7 +254,7 @@ int pipe(int fd[2])
fd[1] = open(devname, O_WRONLY); fd[1] = open(devname, O_WRONLY);
if (fd[1] < 0) if (fd[1] < 0)
{ {
err = -fd[1]; errcode = -fd[1];
goto errout_with_driver; goto errout_with_driver;
} }
@ -263,7 +263,7 @@ int pipe(int fd[2])
fd[0] = open(devname, O_RDONLY); fd[0] = open(devname, O_RDONLY);
if (fd[0] < 0) if (fd[0] < 0)
{ {
err = -fd[0]; errcode = -fd[0];
goto errout_with_wrfd; goto errout_with_wrfd;
} }
@ -285,7 +285,7 @@ errout_with_pipe:
pipe_free(pipeno); pipe_free(pipeno);
errout: errout:
set_errno(err); set_errno(errcode);
return ERROR; return ERROR;
} }

View File

@ -196,12 +196,12 @@ int file_dup2(FAR struct file *filep1, FAR struct file *filep2)
{ {
FAR struct filelist *list; FAR struct filelist *list;
FAR struct inode *inode; FAR struct inode *inode;
int err; int errcode;
int ret; int ret;
if (!filep1 || !filep1->f_inode || !filep2) if (!filep1 || !filep1->f_inode || !filep2)
{ {
err = EBADF; errcode = EBADF;
goto errout; goto errout;
} }
@ -287,7 +287,7 @@ errout_with_inode:
filep2->f_inode = NULL; filep2->f_inode = NULL;
errout_with_ret: errout_with_ret:
err = -ret; errcode = -ret;
if (list != NULL) if (list != NULL)
{ {
@ -295,7 +295,7 @@ errout_with_ret:
} }
errout: errout:
set_errno(err); set_errno(errcode);
return ERROR; return ERROR;
} }

View File

@ -115,7 +115,7 @@ int munmap(FAR void *start, size_t length)
FAR void *newaddr; FAR void *newaddr;
unsigned int offset; unsigned int offset;
int ret; int ret;
int err; int errcode;
/* Find a region containing this start and length in the list of regions */ /* Find a region containing this start and length in the list of regions */
@ -144,7 +144,7 @@ int munmap(FAR void *start, size_t length)
if (!curr) if (!curr)
{ {
fdbg("Region not found\n"); fdbg("Region not found\n");
err = EINVAL; errcode = EINVAL;
goto errout_with_semaphore; goto errout_with_semaphore;
} }
@ -159,7 +159,7 @@ int munmap(FAR void *start, size_t length)
if (offset + length < curr->length) if (offset + length < curr->length)
{ {
fdbg("Cannot umap without unmapping to the end\n"); fdbg("Cannot umap without unmapping to the end\n");
err = ENOSYS; errcode = ENOSYS;
goto errout_with_semaphore; goto errout_with_semaphore;
} }
@ -205,7 +205,7 @@ int munmap(FAR void *start, size_t length)
errout_with_semaphore: errout_with_semaphore:
sem_post(&g_rammaps.exclsem); sem_post(&g_rammaps.exclsem);
set_errno(err); set_errno(errcode);
return ERROR; return ERROR;
} }

View File

@ -121,7 +121,7 @@ FAR void *rammap(int fd, size_t length, off_t offset)
FAR uint8_t *rdbuffer; FAR uint8_t *rdbuffer;
ssize_t nread; ssize_t nread;
off_t fpos; off_t fpos;
int err; int errcode;
int ret; int ret;
/* There is a major design flaw that I have not yet thought of fix for: /* There is a major design flaw that I have not yet thought of fix for:
@ -143,7 +143,7 @@ FAR void *rammap(int fd, size_t length, off_t offset)
if (!alloc) if (!alloc)
{ {
fdbg("Region allocation failed, length: %d\n", (int)length); fdbg("Region allocation failed, length: %d\n", (int)length);
err = ENOMEM; errcode = ENOMEM;
goto errout; goto errout;
} }
@ -165,7 +165,7 @@ FAR void *rammap(int fd, size_t length, off_t offset)
*/ */
fdbg("Seek to position %d failed\n", (int)offset); fdbg("Seek to position %d failed\n", (int)offset);
err = EINVAL; errcode = EINVAL;
goto errout_with_region; goto errout_with_region;
} }
@ -181,8 +181,8 @@ FAR void *rammap(int fd, size_t length, off_t offset)
* signal. * signal.
*/ */
err = get_errno(); errcode = get_errno();
if (err != EINTR) if (errcode != EINTR)
{ {
/* All other read errors are bad. errno is already set. /* All other read errors are bad. errno is already set.
* (but maybe should be forced to EINVAL?). NOTE that if * (but maybe should be forced to EINVAL?). NOTE that if
@ -190,7 +190,7 @@ FAR void *rammap(int fd, size_t length, off_t offset)
* destroy the errno value. * destroy the errno value.
*/ */
fdbg("Read failed: offset=%d errno=%d\n", (int)offset, err); fdbg("Read failed: offset=%d errno=%d\n", (int)offset, errcode);
#ifdef CONFIG_DEBUG_FS #ifdef CONFIG_DEBUG_FS
goto errout_with_region; goto errout_with_region;
#else #else
@ -234,7 +234,7 @@ FAR void *rammap(int fd, size_t length, off_t offset)
errout_with_region: errout_with_region:
kumm_free(alloc); kumm_free(alloc);
errout: errout:
set_errno(err); set_errno(errcode);
return MAP_FAILED; return MAP_FAILED;
errout_with_errno: errout_with_errno:

View File

@ -79,7 +79,7 @@
int close(int fd) int close(int fd)
{ {
int err; int errcode;
#if CONFIG_NFILE_DESCRIPTORS > 0 #if CONFIG_NFILE_DESCRIPTORS > 0
int ret; int ret;
@ -98,7 +98,7 @@ int close(int fd)
else else
#endif #endif
{ {
err = EBADF; errcode = EBADF;
goto errout; goto errout;
} }
} }
@ -119,7 +119,7 @@ int close(int fd)
{ {
/* An error occurred while closing the driver */ /* An error occurred while closing the driver */
err = -ret; errcode = -ret;
goto errout; goto errout;
} }
@ -128,7 +128,6 @@ int close(int fd)
#endif #endif
errout: errout:
set_errno(err); set_errno(errcode);
return ERROR; return ERROR;
} }

View File

@ -75,14 +75,14 @@
#if CONFIG_NFILE_DESCRIPTORS > 0 #if CONFIG_NFILE_DESCRIPTORS > 0
int file_vfcntl(FAR struct file *filep, int cmd, va_list ap) int file_vfcntl(FAR struct file *filep, int cmd, va_list ap)
{ {
int err = 0; int errcode = 0;
int ret = OK; int ret = OK;
/* Was this file opened ? */ /* Was this file opened ? */
if (!filep->f_inode) if (!filep->f_inode)
{ {
err = EBADF; errcode = EBADF;
goto errout; goto errout;
} }
@ -119,7 +119,7 @@ int file_vfcntl(FAR struct file *filep, int cmd, va_list ap)
* successful execution of one of the exec functions. * successful execution of one of the exec functions.
*/ */
err = ENOSYS; errcode = ENOSYS;
break; break;
case F_GETFL: case F_GETFL:
@ -169,7 +169,7 @@ int file_vfcntl(FAR struct file *filep, int cmd, va_list ap)
* fd does not refer to a socket, the results are unspecified. * fd does not refer to a socket, the results are unspecified.
*/ */
err = EBADF; /* Only valid on socket descriptors */ errcode = EBADF; /* Only valid on socket descriptors */
break; break;
case F_GETLK: case F_GETLK:
@ -199,18 +199,18 @@ int file_vfcntl(FAR struct file *filep, int cmd, va_list ap)
* not be done. * not be done.
*/ */
err = ENOSYS; /* Not implemented */ errcode = ENOSYS; /* Not implemented */
break; break;
default: default:
err = EINVAL; errcode = EINVAL;
break; break;
} }
errout: errout:
if (err != 0) if (errcode != 0)
{ {
set_errno(err); set_errno(errcode);
return ERROR; return ERROR;
} }

View File

@ -129,7 +129,7 @@ FAR struct file_struct *fs_fdopen(int fd, int oflags, FAR struct tcb_s *tcb)
{ {
FAR struct streamlist *slist; FAR struct streamlist *slist;
FAR FILE *stream; FAR FILE *stream;
int err = OK; int errcode = OK;
int ret; int ret;
int i; int i;
@ -137,7 +137,7 @@ FAR struct file_struct *fs_fdopen(int fd, int oflags, FAR struct tcb_s *tcb)
if (fd < 0) if (fd < 0)
{ {
err = EBADF; errcode = EBADF;
goto errout; goto errout;
} }
@ -173,7 +173,7 @@ FAR struct file_struct *fs_fdopen(int fd, int oflags, FAR struct tcb_s *tcb)
#else #else
/* No networking... it is just a bad descriptor */ /* No networking... it is just a bad descriptor */
err = EBADF; errcode = EBADF;
goto errout; goto errout;
#endif #endif
} }
@ -193,7 +193,7 @@ FAR struct file_struct *fs_fdopen(int fd, int oflags, FAR struct tcb_s *tcb)
{ {
/* No... return the reported error */ /* No... return the reported error */
err = -ret; errcode = -ret;
goto errout; goto errout;
} }
@ -241,7 +241,7 @@ FAR struct file_struct *fs_fdopen(int fd, int oflags, FAR struct tcb_s *tcb)
if (!stream->fs_bufstart) if (!stream->fs_bufstart)
{ {
err = ENOMEM; errcode = ENOMEM;
goto errout_with_sem; goto errout_with_sem;
} }
@ -266,7 +266,7 @@ FAR struct file_struct *fs_fdopen(int fd, int oflags, FAR struct tcb_s *tcb)
/* No free stream available.. report ENFILE */ /* No free stream available.. report ENFILE */
err = ENFILE; errcode = ENFILE;
#if CONFIG_STDIO_BUFFER_SIZE > 0 #if CONFIG_STDIO_BUFFER_SIZE > 0
errout_with_sem: errout_with_sem:
@ -274,7 +274,7 @@ errout_with_sem:
sem_post(&slist->sl_sem); sem_post(&slist->sl_sem);
errout: errout:
set_errno(err); set_errno(errcode);
errout_with_errno: errout_with_errno:
return NULL; return NULL;
} }

View File

@ -91,7 +91,7 @@ int fs_ioctl(int fd, int req, unsigned long arg)
int ioctl(int fd, int req, unsigned long arg) int ioctl(int fd, int req, unsigned long arg)
#endif #endif
{ {
int err; int errcode;
#if CONFIG_NFILE_DESCRIPTORS > 0 #if CONFIG_NFILE_DESCRIPTORS > 0
FAR struct file *filep; FAR struct file *filep;
FAR struct inode *inode; FAR struct inode *inode;
@ -112,7 +112,7 @@ int ioctl(int fd, int req, unsigned long arg)
else else
#endif #endif
{ {
err = EBADF; errcode = EBADF;
goto errout; goto errout;
} }
} }
@ -138,7 +138,7 @@ int ioctl(int fd, int req, unsigned long arg)
ret = (int)inode->u.i_ops->ioctl(filep, req, arg); ret = (int)inode->u.i_ops->ioctl(filep, req, arg);
if (ret < 0) if (ret < 0)
{ {
err = -ret; errcode = -ret;
goto errout; goto errout;
} }
} }
@ -147,7 +147,6 @@ int ioctl(int fd, int req, unsigned long arg)
#endif #endif
errout: errout:
set_errno(err); set_errno(errcode);
return ERROR; return ERROR;
} }

View File

@ -75,7 +75,7 @@ off_t file_seek(FAR struct file *filep, off_t offset, int whence)
{ {
FAR struct inode *inode; FAR struct inode *inode;
int ret; int ret;
int err = OK; int errcode = OK;
DEBUGASSERT(filep); DEBUGASSERT(filep);
inode = filep->f_inode; inode = filep->f_inode;
@ -87,7 +87,7 @@ off_t file_seek(FAR struct file *filep, off_t offset, int whence)
ret = (int)inode->u.i_ops->seek(filep, offset, whence); ret = (int)inode->u.i_ops->seek(filep, offset, whence);
if (ret < 0) if (ret < 0)
{ {
err = -ret; errcode = -ret;
goto errout; goto errout;
} }
} }
@ -108,17 +108,17 @@ off_t file_seek(FAR struct file *filep, off_t offset, int whence)
} }
else else
{ {
err = EINVAL; errcode = EINVAL;
goto errout; goto errout;
} }
break; break;
case SEEK_END: case SEEK_END:
err = ENOSYS; errcode = ENOSYS;
goto errout; goto errout;
default: default:
err = EINVAL; errcode = EINVAL;
goto errout; goto errout;
} }
} }
@ -126,7 +126,7 @@ off_t file_seek(FAR struct file *filep, off_t offset, int whence)
return filep->f_pos; return filep->f_pos;
errout: errout:
set_errno(err); set_errno(errcode);
return (off_t)ERROR; return (off_t)ERROR;
} }

View File

@ -77,14 +77,14 @@ static int poll_semtake(FAR sem_t *sem)
if (sem_wait(sem) < 0) if (sem_wait(sem) < 0)
{ {
int err = get_errno(); int errcode = get_errno();
/* The only case that an error should occur here is if the wait were /* The only case that an error should occur here is if the wait were
* awakened by a signal. * awakened by a signal.
*/ */
DEBUGASSERT(err == EINTR); DEBUGASSERT(errcode == EINTR);
return -err; return -errcode;
} }
return OK; return OK;
@ -329,7 +329,7 @@ int poll(FAR struct pollfd *fds, nfds_t nfds, int timeout)
{ {
sem_t sem; sem_t sem;
int count = 0; int count = 0;
int err; int errcode;
int ret; int ret;
sem_init(&sem, 0, 0); sem_init(&sem, 0, 0);
@ -378,10 +378,10 @@ int poll(FAR struct pollfd *fds, nfds_t nfds, int timeout)
* Preserve ret, if negative, since it holds the result of the wait. * Preserve ret, if negative, since it holds the result of the wait.
*/ */
err = poll_teardown(fds, nfds, &count, ret); errcode = poll_teardown(fds, nfds, &count, ret);
if (err < 0 && ret >= 0) if (errcode < 0 && ret >= 0)
{ {
ret = err; ret = errcode;
} }
} }

View File

@ -73,13 +73,13 @@ ssize_t file_write(FAR struct file *filep, FAR const void *buf, size_t nbytes)
{ {
FAR struct inode *inode; FAR struct inode *inode;
int ret; int ret;
int err; int errcode;
/* Was this file opened for write access? */ /* Was this file opened for write access? */
if ((filep->f_oflags & O_WROK) == 0) if ((filep->f_oflags & O_WROK) == 0)
{ {
err = EBADF; errcode = EBADF;
goto errout; goto errout;
} }
@ -88,7 +88,7 @@ ssize_t file_write(FAR struct file *filep, FAR const void *buf, size_t nbytes)
inode = filep->f_inode; inode = filep->f_inode;
if (!inode || !inode->u.i_ops || !inode->u.i_ops->write) if (!inode || !inode->u.i_ops || !inode->u.i_ops->write)
{ {
err = EBADF; errcode = EBADF;
goto errout; goto errout;
} }
@ -97,14 +97,14 @@ ssize_t file_write(FAR struct file *filep, FAR const void *buf, size_t nbytes)
ret = inode->u.i_ops->write(filep, buf, nbytes); ret = inode->u.i_ops->write(filep, buf, nbytes);
if (ret < 0) if (ret < 0)
{ {
err = -ret; errcode = -ret;
goto errout; goto errout;
} }
return ret; return ret;
errout: errout:
set_errno(err); set_errno(errcode);
return ERROR; return ERROR;
} }

View File

@ -138,7 +138,7 @@
/* Definitions to map some non-standard, BSD thread management interfaces to /* Definitions to map some non-standard, BSD thread management interfaces to
* the non-standard Linux-like prctl() interface. Since these are simple * the non-standard Linux-like prctl() interface. Since these are simple
* mappings to prctl, they will return 0 on success and -1 on failure with the * mappings to prctl, they will return 0 on success and -1 on failure with the
* err number in errno. This is an inconsistency with the pthread interfaces. * error number in errno. This is an inconsistency with the pthread interfaces.
*/ */
#define pthread_setname_np(thread, name) \ #define pthread_setname_np(thread, name) \

View File

@ -69,7 +69,7 @@
int fclose(FAR FILE *stream) int fclose(FAR FILE *stream)
{ {
int err = EINVAL; int errcode = EINVAL;
int ret = ERROR; int ret = ERROR;
int status; int status;
@ -89,7 +89,7 @@ int fclose(FAR FILE *stream)
if ((stream->fs_oflags & O_WROK) != 0) if ((stream->fs_oflags & O_WROK) != 0)
{ {
ret = lib_fflush(stream, true); ret = lib_fflush(stream, true);
err = errno; errcode = errno;
} }
/* Close the underlying file descriptor and save the return status */ /* Close the underlying file descriptor and save the return status */
@ -103,7 +103,7 @@ int fclose(FAR FILE *stream)
if (ret == OK) if (ret == OK)
{ {
ret = status; ret = status;
err = errno; errcode = errno;
} }
} }
@ -143,7 +143,7 @@ int fclose(FAR FILE *stream)
if (ret != OK) if (ret != OK)
{ {
set_errno(err); set_errno(errcode);
return EOF; return EOF;
} }

View File

@ -119,14 +119,14 @@ int chdir(FAR const char *path)
struct stat buf; struct stat buf;
char *oldpwd; char *oldpwd;
char *alloc; char *alloc;
int err; int errcode;
int ret; int ret;
/* Verify the input parameters */ /* Verify the input parameters */
if (!path) if (!path)
{ {
err = ENOENT; errcode = ENOENT;
goto errout; goto errout;
} }
@ -135,7 +135,7 @@ int chdir(FAR const char *path)
ret = stat(path, &buf); ret = stat(path, &buf);
if (ret != 0) if (ret != 0)
{ {
err = ENOENT; errcode = ENOENT;
goto errout; goto errout;
} }
@ -143,7 +143,7 @@ int chdir(FAR const char *path)
if (!S_ISDIR(buf.st_mode)) if (!S_ISDIR(buf.st_mode))
{ {
err = ENOTDIR; errcode = ENOTDIR;
goto errout; goto errout;
} }
@ -173,7 +173,7 @@ int chdir(FAR const char *path)
return OK; return OK;
errout: errout:
set_errno(err); set_errno(errcode);
return ERROR; return ERROR;
} }
#endif /* CONFIG_NFILE_DESCRIPTORS && !CONFIG_DISABLE_ENVIRON */ #endif /* CONFIG_NFILE_DESCRIPTORS && !CONFIG_DISABLE_ENVIRON */

View File

@ -94,12 +94,12 @@ FAR void *mm_sbrk(FAR struct mm_heap_s *heap, intptr_t incr,
uintptr_t allocbase; uintptr_t allocbase;
unsigned int pgincr; unsigned int pgincr;
size_t bytesize; size_t bytesize;
int err; int errcode;
DEBUGASSERT(incr >= 0); DEBUGASSERT(incr >= 0);
if (incr < 0) if (incr < 0)
{ {
err = ENOSYS; errcode = ENOSYS;
goto errout; goto errout;
} }
@ -119,7 +119,7 @@ FAR void *mm_sbrk(FAR struct mm_heap_s *heap, intptr_t incr,
if ((brkaddr > 0) && ((maxbreak - brkaddr) < (pgincr << MM_PGSHIFT))) if ((brkaddr > 0) && ((maxbreak - brkaddr) < (pgincr << MM_PGSHIFT)))
{ {
err = ENOMEM; errcode = ENOMEM;
goto errout; goto errout;
} }
@ -132,7 +132,7 @@ FAR void *mm_sbrk(FAR struct mm_heap_s *heap, intptr_t incr,
allocbase = pgalloc(brkaddr, pgincr); allocbase = pgalloc(brkaddr, pgincr);
if (allocbase == 0) if (allocbase == 0)
{ {
err = EAGAIN; errcode = EAGAIN;
goto errout; goto errout;
} }
@ -158,7 +158,7 @@ FAR void *mm_sbrk(FAR struct mm_heap_s *heap, intptr_t incr,
return (FAR void *)brkaddr; return (FAR void *)brkaddr;
errout: errout:
set_errno(err); set_errno(errcode);
return (FAR void *)-1; return (FAR void *)-1;
} }
#endif /* CONFIG_BUILD_KERNEL */ #endif /* CONFIG_BUILD_KERNEL */

View File

@ -212,14 +212,14 @@ ssize_t psock_pkt_send(FAR struct socket *psock, FAR const void *buf,
FAR struct net_driver_s *dev; FAR struct net_driver_s *dev;
struct send_s state; struct send_s state;
net_lock_t save; net_lock_t save;
int err; int errcode;
int ret = OK; int ret = OK;
/* Verify that the sockfd corresponds to valid, allocated socket */ /* Verify that the sockfd corresponds to valid, allocated socket */
if (!psock || psock->s_crefs <= 0) if (!psock || psock->s_crefs <= 0)
{ {
err = EBADF; errcode = EBADF;
goto errout; goto errout;
} }
@ -228,7 +228,7 @@ ssize_t psock_pkt_send(FAR struct socket *psock, FAR const void *buf,
dev = pkt_find_device((FAR struct pkt_conn_s *)psock->s_conn); dev = pkt_find_device((FAR struct pkt_conn_s *)psock->s_conn);
if (dev == NULL) if (dev == NULL)
{ {
err = ENODEV; errcode = ENODEV;
goto errout; goto errout;
} }
@ -296,7 +296,7 @@ ssize_t psock_pkt_send(FAR struct socket *psock, FAR const void *buf,
if (state.snd_sent < 0) if (state.snd_sent < 0)
{ {
err = state.snd_sent; errcode = state.snd_sent;
goto errout; goto errout;
} }
@ -306,7 +306,7 @@ ssize_t psock_pkt_send(FAR struct socket *psock, FAR const void *buf,
if (ret < 0) if (ret < 0)
{ {
err = -ret; errcode = -ret;
goto errout; goto errout;
} }
@ -315,7 +315,7 @@ ssize_t psock_pkt_send(FAR struct socket *psock, FAR const void *buf,
return state.snd_sent; return state.snd_sent;
errout: errout:
set_errno(err); set_errno(errcode);
return ERROR; return ERROR;
} }

View File

@ -127,7 +127,7 @@
int psock_accept(FAR struct socket *psock, FAR struct sockaddr *addr, int psock_accept(FAR struct socket *psock, FAR struct sockaddr *addr,
FAR socklen_t *addrlen, FAR struct socket *newsock) FAR socklen_t *addrlen, FAR struct socket *newsock)
{ {
int err; int errcode;
int ret; int ret;
DEBUGASSERT(psock != NULL); DEBUGASSERT(psock != NULL);
@ -136,7 +136,7 @@ int psock_accept(FAR struct socket *psock, FAR struct sockaddr *addr,
if (psock->s_type != SOCK_STREAM) if (psock->s_type != SOCK_STREAM)
{ {
err = EOPNOTSUPP; errcode = EOPNOTSUPP;
goto errout; goto errout;
} }
@ -144,7 +144,7 @@ int psock_accept(FAR struct socket *psock, FAR struct sockaddr *addr,
if (!_SS_ISLISTENING(psock->s_flags)) if (!_SS_ISLISTENING(psock->s_flags))
{ {
err = EINVAL; errcode = EINVAL;
goto errout; goto errout;
} }
@ -167,7 +167,7 @@ int psock_accept(FAR struct socket *psock, FAR struct sockaddr *addr,
{ {
if (*addrlen < sizeof(struct sockaddr_in)) if (*addrlen < sizeof(struct sockaddr_in))
{ {
err = EBADF; errcode = EBADF;
goto errout; goto errout;
} }
} }
@ -179,7 +179,7 @@ int psock_accept(FAR struct socket *psock, FAR struct sockaddr *addr,
{ {
if (*addrlen < sizeof(struct sockaddr_in6)) if (*addrlen < sizeof(struct sockaddr_in6))
{ {
err = EBADF; errcode = EBADF;
goto errout; goto errout;
} }
} }
@ -191,7 +191,7 @@ int psock_accept(FAR struct socket *psock, FAR struct sockaddr *addr,
{ {
if (*addrlen < sizeof(sa_family_t)) if (*addrlen < sizeof(sa_family_t))
{ {
err = EBADF; errcode = EBADF;
goto errout; goto errout;
} }
} }
@ -200,7 +200,7 @@ int psock_accept(FAR struct socket *psock, FAR struct sockaddr *addr,
default: default:
DEBUGPANIC(); DEBUGPANIC();
err = EINVAL; errcode = EINVAL;
goto errout; goto errout;
} }
} }
@ -222,7 +222,7 @@ int psock_accept(FAR struct socket *psock, FAR struct sockaddr *addr,
ret = psock_local_accept(psock, addr, addrlen, &newsock->s_conn); ret = psock_local_accept(psock, addr, addrlen, &newsock->s_conn);
if (ret < 0) if (ret < 0)
{ {
err = -ret; errcode = -ret;
goto errout; goto errout;
} }
} }
@ -242,7 +242,7 @@ int psock_accept(FAR struct socket *psock, FAR struct sockaddr *addr,
if (ret < 0) if (ret < 0)
{ {
net_unlock(state); net_unlock(state);
err = -ret; errcode = -ret;
goto errout; goto errout;
} }
@ -259,7 +259,7 @@ int psock_accept(FAR struct socket *psock, FAR struct sockaddr *addr,
*/ */
net_unlock(state); net_unlock(state);
err = -ret; errcode = -ret;
goto errout_after_accept; goto errout_after_accept;
} }
@ -277,7 +277,7 @@ errout_after_accept:
psock_close(newsock); psock_close(newsock);
errout: errout:
set_errno(err); set_errno(errcode);
return ERROR; return ERROR;
} }
@ -354,7 +354,7 @@ int accept(int sockfd, FAR struct sockaddr *addr, FAR socklen_t *addrlen)
FAR struct socket *psock = sockfd_socket(sockfd); FAR struct socket *psock = sockfd_socket(sockfd);
FAR struct socket *newsock; FAR struct socket *newsock;
int newfd; int newfd;
int err; int errcode;
int ret; int ret;
/* Verify that the sockfd corresponds to valid, allocated socket */ /* Verify that the sockfd corresponds to valid, allocated socket */
@ -369,12 +369,12 @@ int accept(int sockfd, FAR struct sockaddr *addr, FAR socklen_t *addrlen)
#if CONFIG_NFILE_DESCRIPTORS > 0 #if CONFIG_NFILE_DESCRIPTORS > 0
if ((unsigned int)sockfd < CONFIG_NFILE_DESCRIPTORS) if ((unsigned int)sockfd < CONFIG_NFILE_DESCRIPTORS)
{ {
err = ENOTSOCK; errcode = ENOTSOCK;
} }
else else
#endif #endif
{ {
err = EBADF; errcode = EBADF;
} }
goto errout; goto errout;
@ -387,14 +387,14 @@ int accept(int sockfd, FAR struct sockaddr *addr, FAR socklen_t *addrlen)
newfd = sockfd_allocate(0); newfd = sockfd_allocate(0);
if (newfd < 0) if (newfd < 0)
{ {
err = ENFILE; errcode = ENFILE;
goto errout; goto errout;
} }
newsock = sockfd_socket(newfd); newsock = sockfd_socket(newfd);
if (newsock == NULL) if (newsock == NULL)
{ {
err = ENFILE; errcode = ENFILE;
goto errout_with_socket; goto errout_with_socket;
} }
@ -413,7 +413,7 @@ errout_with_socket:
sockfd_release(newfd); sockfd_release(newfd);
errout: errout:
set_errno(err); set_errno(errcode);
return ERROR; return ERROR;
} }

View File

@ -156,14 +156,14 @@ int psock_bind(FAR struct socket *psock, const struct sockaddr *addr,
FAR const struct sockaddr_ll *lladdr = (const struct sockaddr_ll *)addr; FAR const struct sockaddr_ll *lladdr = (const struct sockaddr_ll *)addr;
#endif #endif
socklen_t minlen; socklen_t minlen;
int err; int errcode;
int ret = OK; int ret = OK;
/* Verify that the psock corresponds to valid, allocated socket */ /* Verify that the psock corresponds to valid, allocated socket */
if (!psock || psock->s_crefs <= 0) if (!psock || psock->s_crefs <= 0)
{ {
err = ENOTSOCK; errcode = ENOTSOCK;
goto errout; goto errout;
} }
@ -197,14 +197,14 @@ int psock_bind(FAR struct socket *psock, const struct sockaddr *addr,
default: default:
ndbg("ERROR: Unrecognized address family: %d\n", addr->sa_family); ndbg("ERROR: Unrecognized address family: %d\n", addr->sa_family);
err = EAFNOSUPPORT; errcode = EAFNOSUPPORT;
goto errout; goto errout;
} }
if (addrlen < minlen) if (addrlen < minlen)
{ {
ndbg("ERROR: Invalid address length: %d < %d\n", addrlen, minlen); ndbg("ERROR: Invalid address length: %d < %d\n", addrlen, minlen);
err = EBADF; errcode = EBADF;
goto errout; goto errout;
} }
@ -301,7 +301,7 @@ int psock_bind(FAR struct socket *psock, const struct sockaddr *addr,
#endif /* CONFIG_NET_UDP || CONFIG_NET_LOCAL_DGRAM */ #endif /* CONFIG_NET_UDP || CONFIG_NET_LOCAL_DGRAM */
default: default:
err = EBADF; errcode = EBADF;
goto errout; goto errout;
} }
@ -309,14 +309,14 @@ int psock_bind(FAR struct socket *psock, const struct sockaddr *addr,
if (ret < 0) if (ret < 0)
{ {
err = -ret; errcode = -ret;
goto errout; goto errout;
} }
return OK; return OK;
errout: errout:
set_errno(err); set_errno(errcode);
return ERROR; return ERROR;
} }

View File

@ -507,13 +507,13 @@ int psock_connect(FAR struct socket *psock, FAR const struct sockaddr *addr,
#if defined(CONFIG_NET_TCP) || defined(CONFIG_NET_UDP) || defined(CONFIG_NET_LOCAL) #if defined(CONFIG_NET_TCP) || defined(CONFIG_NET_UDP) || defined(CONFIG_NET_LOCAL)
int ret; int ret;
#endif #endif
int err; int errcode;
/* Verify that the psock corresponds to valid, allocated socket */ /* Verify that the psock corresponds to valid, allocated socket */
if (!psock || psock->s_crefs <= 0) if (!psock || psock->s_crefs <= 0)
{ {
err = EBADF; errcode = EBADF;
goto errout; goto errout;
} }
@ -526,7 +526,7 @@ int psock_connect(FAR struct socket *psock, FAR const struct sockaddr *addr,
{ {
if (addrlen < sizeof(struct sockaddr_in)) if (addrlen < sizeof(struct sockaddr_in))
{ {
err = EBADF; errcode = EBADF;
goto errout; goto errout;
} }
} }
@ -538,7 +538,7 @@ int psock_connect(FAR struct socket *psock, FAR const struct sockaddr *addr,
{ {
if (addrlen < sizeof(struct sockaddr_in6)) if (addrlen < sizeof(struct sockaddr_in6))
{ {
err = EBADF; errcode = EBADF;
goto errout; goto errout;
} }
} }
@ -550,7 +550,7 @@ int psock_connect(FAR struct socket *psock, FAR const struct sockaddr *addr,
{ {
if (addrlen < sizeof(sa_family_t)) if (addrlen < sizeof(sa_family_t))
{ {
err = EBADF; errcode = EBADF;
goto errout; goto errout;
} }
} }
@ -559,7 +559,7 @@ int psock_connect(FAR struct socket *psock, FAR const struct sockaddr *addr,
default: default:
DEBUGPANIC(); DEBUGPANIC();
err = EAFNOSUPPORT; errcode = EAFNOSUPPORT;
goto errout; goto errout;
} }
@ -574,7 +574,7 @@ int psock_connect(FAR struct socket *psock, FAR const struct sockaddr *addr,
if (_SS_ISCONNECTED(psock->s_flags)) if (_SS_ISCONNECTED(psock->s_flags))
{ {
err = EISCONN; errcode = EISCONN;
goto errout; goto errout;
} }
@ -604,7 +604,7 @@ int psock_connect(FAR struct socket *psock, FAR const struct sockaddr *addr,
if (ret < 0) if (ret < 0)
{ {
err = -ret; errcode = -ret;
goto errout; goto errout;
} }
} }
@ -644,7 +644,7 @@ int psock_connect(FAR struct socket *psock, FAR const struct sockaddr *addr,
if (ret < 0) if (ret < 0)
{ {
err = -ret; errcode = -ret;
goto errout; goto errout;
} }
} }
@ -652,14 +652,14 @@ int psock_connect(FAR struct socket *psock, FAR const struct sockaddr *addr,
#endif /* CONFIG_NET_UDP || CONFIG_NET_LOCAL_DGRAM */ #endif /* CONFIG_NET_UDP || CONFIG_NET_LOCAL_DGRAM */
default: default:
err = EBADF; errcode = EBADF;
goto errout; goto errout;
} }
return OK; return OK;
errout: errout:
set_errno(err); set_errno(errcode);
return ERROR; return ERROR;
} }

View File

@ -351,13 +351,13 @@ int getsockname(int sockfd, FAR struct sockaddr *addr, FAR socklen_t *addrlen)
{ {
FAR struct socket *psock = sockfd_socket(sockfd); FAR struct socket *psock = sockfd_socket(sockfd);
int ret; int ret;
int err; int errcode;
/* Verify that the sockfd corresponds to valid, allocated socket */ /* Verify that the sockfd corresponds to valid, allocated socket */
if (!psock || psock->s_crefs <= 0) if (!psock || psock->s_crefs <= 0)
{ {
err = EBADF; errcode = EBADF;
goto errout; goto errout;
} }
@ -368,7 +368,7 @@ int getsockname(int sockfd, FAR struct sockaddr *addr, FAR socklen_t *addrlen)
#ifdef CONFIG_DEBUG_FEATURES #ifdef CONFIG_DEBUG_FEATURES
if (!addr || !addrlen) if (!addr || !addrlen)
{ {
err = EINVAL; errcode = EINVAL;
goto errout; goto errout;
} }
#endif #endif
@ -391,7 +391,7 @@ int getsockname(int sockfd, FAR struct sockaddr *addr, FAR socklen_t *addrlen)
case PF_PACKET: case PF_PACKET:
default: default:
err = EAFNOSUPPORT; errcode = EAFNOSUPPORT;
goto errout; goto errout;
} }
@ -399,14 +399,14 @@ int getsockname(int sockfd, FAR struct sockaddr *addr, FAR socklen_t *addrlen)
if (ret < 0) if (ret < 0)
{ {
err = -ret; errcode = -ret;
goto errout; goto errout;
} }
return OK; return OK;
errout: errout:
set_errno(err); set_errno(errcode);
return ERROR; return ERROR;
} }

View File

@ -96,13 +96,13 @@
int psock_getsockopt(FAR struct socket *psock, int level, int option, int psock_getsockopt(FAR struct socket *psock, int level, int option,
FAR void *value, FAR socklen_t *value_len) FAR void *value, FAR socklen_t *value_len)
{ {
int err; int errcode;
/* Verify that the socket option if valid (but might not be supported ) */ /* Verify that the socket option if valid (but might not be supported ) */
if (!_SO_GETVALID(option) || !value || !value_len) if (!_SO_GETVALID(option) || !value || !value_len)
{ {
err = EINVAL; errcode = EINVAL;
goto errout; goto errout;
} }
@ -131,7 +131,7 @@ int psock_getsockopt(FAR struct socket *psock, int level, int option,
if (*value_len < sizeof(int)) if (*value_len < sizeof(int))
{ {
err = EINVAL; errcode = EINVAL;
goto errout; goto errout;
} }
@ -155,7 +155,7 @@ int psock_getsockopt(FAR struct socket *psock, int level, int option,
if (*value_len < sizeof(int)) if (*value_len < sizeof(int))
{ {
err = EINVAL; errcode = EINVAL;
goto errout; goto errout;
} }
@ -179,7 +179,7 @@ int psock_getsockopt(FAR struct socket *psock, int level, int option,
if (*value_len < sizeof(struct timeval)) if (*value_len < sizeof(struct timeval))
{ {
err = EINVAL; errcode = EINVAL;
goto errout; goto errout;
} }
@ -214,14 +214,14 @@ int psock_getsockopt(FAR struct socket *psock, int level, int option,
case SO_SNDLOWAT: /* Sets the minimum number of bytes to output */ case SO_SNDLOWAT: /* Sets the minimum number of bytes to output */
default: default:
err = ENOPROTOOPT; errcode = ENOPROTOOPT;
goto errout; goto errout;
} }
return OK; return OK;
errout: errout:
set_errno(err); set_errno(errcode);
return ERROR; return ERROR;
} }

View File

@ -84,7 +84,7 @@
int psock_listen(FAR struct socket *psock, int backlog) int psock_listen(FAR struct socket *psock, int backlog)
{ {
int err; int errcode;
DEBUGASSERT(psock != NULL); DEBUGASSERT(psock != NULL);
@ -92,7 +92,7 @@ int psock_listen(FAR struct socket *psock, int backlog)
if (psock->s_type != SOCK_STREAM || !psock->s_conn) if (psock->s_type != SOCK_STREAM || !psock->s_conn)
{ {
err = EOPNOTSUPP; errcode = EOPNOTSUPP;
goto errout; goto errout;
} }
@ -104,10 +104,10 @@ int psock_listen(FAR struct socket *psock, int backlog)
FAR struct local_conn_s *conn = FAR struct local_conn_s *conn =
(FAR struct local_conn_s *)psock->s_conn; (FAR struct local_conn_s *)psock->s_conn;
err = local_listen(conn, backlog); errcode = local_listen(conn, backlog);
if (err < 0) if (errcode < 0)
{ {
err = -err; errcode = -errcode;
goto errout; goto errout;
} }
} }
@ -123,17 +123,17 @@ int psock_listen(FAR struct socket *psock, int backlog)
if (conn->lport <= 0) if (conn->lport <= 0)
{ {
err = EOPNOTSUPP; errcode = EOPNOTSUPP;
goto errout; goto errout;
} }
/* Set up the backlog for this connection */ /* Set up the backlog for this connection */
#ifdef CONFIG_NET_TCPBACKLOG #ifdef CONFIG_NET_TCPBACKLOG
err = tcp_backlogcreate(conn, backlog); errcode = tcp_backlogcreate(conn, backlog);
if (err < 0) if (errcode < 0)
{ {
err = -err; errcode = -errcode;
goto errout; goto errout;
} }
#endif #endif
@ -150,7 +150,7 @@ int psock_listen(FAR struct socket *psock, int backlog)
return OK; return OK;
errout: errout:
set_errno(err); set_errno(errcode);
return ERROR; return ERROR;
} }
@ -190,7 +190,7 @@ errout:
int listen(int sockfd, int backlog) int listen(int sockfd, int backlog)
{ {
FAR struct socket *psock = sockfd_socket(sockfd); FAR struct socket *psock = sockfd_socket(sockfd);
int err; int errcode;
/* Verify that the sockfd corresponds to valid, allocated socket */ /* Verify that the sockfd corresponds to valid, allocated socket */
@ -204,15 +204,15 @@ int listen(int sockfd, int backlog)
#if CONFIG_NFILE_DESCRIPTORS > 0 #if CONFIG_NFILE_DESCRIPTORS > 0
if ((unsigned int)sockfd < CONFIG_NFILE_DESCRIPTORS) if ((unsigned int)sockfd < CONFIG_NFILE_DESCRIPTORS)
{ {
err = ENOTSOCK; errcode = ENOTSOCK;
} }
else else
#endif #endif
{ {
err = EBADF; errcode = EBADF;
} }
set_errno(err); set_errno(errcode);
return ERROR; return ERROR;
} }

View File

@ -507,13 +507,13 @@ static void local_close(FAR struct socket *psock)
int psock_close(FAR struct socket *psock) int psock_close(FAR struct socket *psock)
{ {
int err; int errcode;
/* Verify that the sockfd corresponds to valid, allocated socket */ /* Verify that the sockfd corresponds to valid, allocated socket */
if (!psock || psock->s_crefs <= 0) if (!psock || psock->s_crefs <= 0)
{ {
err = EBADF; errcode = EBADF;
goto errout; goto errout;
} }
@ -565,8 +565,8 @@ int psock_close(FAR struct socket *psock)
/* Break any current connections */ /* Break any current connections */
err = netclose_disconnect(psock); errcode = netclose_disconnect(psock);
if (err < 0) if (errcode < 0)
{ {
/* This would normally occur only if there is a /* This would normally occur only if there is a
* timeout from a lingering close. * timeout from a lingering close.
@ -662,7 +662,7 @@ int psock_close(FAR struct socket *psock)
#endif #endif
default: default:
err = EBADF; errcode = EBADF;
goto errout; goto errout;
} }
} }
@ -678,7 +678,7 @@ errout_with_psock:
#endif #endif
errout: errout:
set_errno(err); set_errno(errcode);
return ERROR; return ERROR;
} }

View File

@ -68,7 +68,7 @@ int net_dupsd(int sockfd, int minsd)
FAR struct socket *psock1; FAR struct socket *psock1;
FAR struct socket *psock2; FAR struct socket *psock2;
int sockfd2; int sockfd2;
int err; int errcode;
int ret; int ret;
/* Make sure that the minimum socket descriptor is within the legal range. /* Make sure that the minimum socket descriptor is within the legal range.
@ -99,7 +99,7 @@ int net_dupsd(int sockfd, int minsd)
if (!psock1 || psock1->s_crefs <= 0) if (!psock1 || psock1->s_crefs <= 0)
{ {
err = EBADF; errcode = EBADF;
goto errout; goto errout;
} }
@ -108,7 +108,7 @@ int net_dupsd(int sockfd, int minsd)
sockfd2 = sockfd_allocate(minsd); sockfd2 = sockfd_allocate(minsd);
if (sockfd2 < 0) if (sockfd2 < 0)
{ {
err = ENFILE; errcode = ENFILE;
goto errout; goto errout;
} }
@ -117,7 +117,7 @@ int net_dupsd(int sockfd, int minsd)
psock2 = sockfd_socket(sockfd2); psock2 = sockfd_socket(sockfd2);
if (!psock2) if (!psock2)
{ {
err = ENOSYS; /* should not happen */ errcode = ENOSYS; /* should not happen */
goto errout; goto errout;
} }
@ -126,7 +126,7 @@ int net_dupsd(int sockfd, int minsd)
ret = net_clone(psock1, psock2); ret = net_clone(psock1, psock2);
if (ret < 0) if (ret < 0)
{ {
err = -ret; errcode = -ret;
goto errout; goto errout;
} }
@ -136,10 +136,8 @@ int net_dupsd(int sockfd, int minsd)
errout: errout:
sched_unlock(); sched_unlock();
set_errno(err); set_errno(errcode);
return ERROR; return ERROR;
} }
#endif /* defined(CONFIG_NET) && CONFIG_NSOCKET_DESCRIPTORS > 0 */ #endif /* defined(CONFIG_NET) && CONFIG_NSOCKET_DESCRIPTORS > 0 */

View File

@ -71,7 +71,7 @@ int dup2(int sockfd1, int sockfd2)
{ {
FAR struct socket *psock1; FAR struct socket *psock1;
FAR struct socket *psock2; FAR struct socket *psock2;
int err; int errcode;
int ret; int ret;
/* Lock the scheduler throughout the following */ /* Lock the scheduler throughout the following */
@ -89,7 +89,7 @@ int dup2(int sockfd1, int sockfd2)
if (!psock1 || !psock2 || psock1->s_crefs <= 0) if (!psock1 || !psock2 || psock1->s_crefs <= 0)
{ {
err = EBADF; errcode = EBADF;
goto errout; goto errout;
} }
@ -107,7 +107,7 @@ int dup2(int sockfd1, int sockfd2)
ret = net_clone(psock1, psock2); ret = net_clone(psock1, psock2);
if (ret < 0) if (ret < 0)
{ {
err = -ret; errcode = -ret;
goto errout; goto errout;
} }
@ -116,10 +116,8 @@ int dup2(int sockfd1, int sockfd2)
errout: errout:
sched_unlock(); sched_unlock();
set_errno(err); set_errno(errcode);
return ERROR; return ERROR;
} }
#endif /* CONFIG_NET && CONFIG_NSOCKET_DESCRIPTORS > 0 */ #endif /* CONFIG_NET && CONFIG_NSOCKET_DESCRIPTORS > 0 */

View File

@ -604,14 +604,14 @@ ssize_t net_sendfile(int outfd, struct file *infile, off_t *offset,
FAR struct tcp_conn_s *conn; FAR struct tcp_conn_s *conn;
struct sendfile_s state; struct sendfile_s state;
net_lock_t save; net_lock_t save;
int err; int errcode;
/* Verify that the sockfd corresponds to valid, allocated socket */ /* Verify that the sockfd corresponds to valid, allocated socket */
if (!psock || psock->s_crefs <= 0) if (!psock || psock->s_crefs <= 0)
{ {
ndbg("ERROR: Invalid socket\n"); ndbg("ERROR: Invalid socket\n");
err = EBADF; errcode = EBADF;
goto errout; goto errout;
} }
@ -620,7 +620,7 @@ ssize_t net_sendfile(int outfd, struct file *infile, off_t *offset,
if (psock->s_type != SOCK_STREAM || !_SS_ISCONNECTED(psock->s_flags)) if (psock->s_type != SOCK_STREAM || !_SS_ISCONNECTED(psock->s_flags))
{ {
ndbg("ERROR: Not connected\n"); ndbg("ERROR: Not connected\n");
err = ENOTCONN; errcode = ENOTCONN;
goto errout; goto errout;
} }
@ -658,7 +658,7 @@ ssize_t net_sendfile(int outfd, struct file *infile, off_t *offset,
if (ret < 0) if (ret < 0)
{ {
ndbg("ERROR: Not reachable\n"); ndbg("ERROR: Not reachable\n");
err = ENETUNREACH; errcode = ENETUNREACH;
goto errout; goto errout;
} }
#endif /* CONFIG_NET_ARP_SEND || CONFIG_NET_ICMPv6_NEIGHBOR */ #endif /* CONFIG_NET_ARP_SEND || CONFIG_NET_ICMPv6_NEIGHBOR */
@ -688,7 +688,7 @@ ssize_t net_sendfile(int outfd, struct file *infile, off_t *offset,
if (state.snd_datacb == NULL) if (state.snd_datacb == NULL)
{ {
nlldbg("Failed to allocate data callback\n"); nlldbg("Failed to allocate data callback\n");
err = ENOMEM; errcode = ENOMEM;
goto errout_locked; goto errout_locked;
} }
@ -697,7 +697,7 @@ ssize_t net_sendfile(int outfd, struct file *infile, off_t *offset,
if (state.snd_ackcb == NULL) if (state.snd_ackcb == NULL)
{ {
nlldbg("Failed to allocate ack callback\n"); nlldbg("Failed to allocate ack callback\n");
err = ENOMEM; errcode = ENOMEM;
goto errout_datacb; goto errout_datacb;
} }
@ -754,9 +754,9 @@ errout_locked:
errout: errout:
if (err) if (errcode)
{ {
set_errno(err); set_errno(errcode);
return ERROR; return ERROR;
} }
else if (state.snd_sent < 0) else if (state.snd_sent < 0)

View File

@ -77,7 +77,7 @@ int net_vfcntl(int sockfd, int cmd, va_list ap)
{ {
FAR struct socket *psock = sockfd_socket(sockfd); FAR struct socket *psock = sockfd_socket(sockfd);
net_lock_t flags; net_lock_t flags;
int err = 0; int errcode = 0;
int ret = 0; int ret = 0;
ninfo("sockfd=%d cmd=%d\n", sockfd, cmd); ninfo("sockfd=%d cmd=%d\n", sockfd, cmd);
@ -86,7 +86,7 @@ int net_vfcntl(int sockfd, int cmd, va_list ap)
if (!psock || psock->s_crefs <= 0) if (!psock || psock->s_crefs <= 0)
{ {
err = EBADF; errcode = EBADF;
goto errout; goto errout;
} }
@ -126,7 +126,7 @@ int net_vfcntl(int sockfd, int cmd, va_list ap)
* successful execution of one of the exec functions. * successful execution of one of the exec functions.
*/ */
err = ENOSYS; /* F_GETFD and F_SETFD not implemented */ errcode = ENOSYS; /* F_GETFD and F_SETFD not implemented */
break; break;
case F_GETFL: case F_GETFL:
@ -263,20 +263,20 @@ int net_vfcntl(int sockfd, int cmd, va_list ap)
* not be done. * not be done.
*/ */
err = ENOSYS; /* F_GETOWN, F_SETOWN, F_GETLK, F_SETLK, F_SETLKW */ errcode = ENOSYS; /* F_GETOWN, F_SETOWN, F_GETLK, F_SETLK, F_SETLKW */
break; break;
default: default:
err = EINVAL; errcode = EINVAL;
break; break;
} }
net_unlock(flags); net_unlock(flags);
errout: errout:
if (err != 0) if (errcode != 0)
{ {
set_errno(err); set_errno(errcode);
return ERROR; return ERROR;
} }

View File

@ -1844,21 +1844,21 @@ ssize_t psock_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len,
FAR socklen_t *fromlen) FAR socklen_t *fromlen)
{ {
ssize_t ret; ssize_t ret;
int err; int errcode;
/* Verify that non-NULL pointers were passed */ /* Verify that non-NULL pointers were passed */
#ifdef CONFIG_DEBUG_FEATURES #ifdef CONFIG_DEBUG_FEATURES
if (!buf) if (!buf)
{ {
err = EINVAL; errcode = EINVAL;
goto errout; goto errout;
} }
#endif #endif
if (from && !fromlen) if (from && !fromlen)
{ {
err = EINVAL; errcode = EINVAL;
goto errout; goto errout;
} }
@ -1866,7 +1866,7 @@ ssize_t psock_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len,
if (!psock || psock->s_crefs <= 0) if (!psock || psock->s_crefs <= 0)
{ {
err = EBADF; errcode = EBADF;
goto errout; goto errout;
} }
@ -1908,13 +1908,13 @@ ssize_t psock_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len,
default: default:
DEBUGPANIC(); DEBUGPANIC();
err = EINVAL; errcode = EINVAL;
goto errout; goto errout;
} }
if (*fromlen < minlen) if (*fromlen < minlen)
{ {
err = EINVAL; errcode = EINVAL;
goto errout; goto errout;
} }
} }
@ -2002,7 +2002,7 @@ ssize_t psock_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len,
if (ret < 0) if (ret < 0)
{ {
err = -ret; errcode = -ret;
goto errout; goto errout;
} }
@ -2011,7 +2011,7 @@ ssize_t psock_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len,
return ret; return ret;
errout: errout:
set_errno(err); set_errno(errcode);
return ERROR; return ERROR;
} }

View File

@ -128,7 +128,7 @@ ssize_t psock_sendto(FAR struct socket *psock, FAR const void *buf,
#if defined(CONFIG_NET_UDP) || defined(CONFIG_NET_LOCAL_DGRAM) #if defined(CONFIG_NET_UDP) || defined(CONFIG_NET_LOCAL_DGRAM)
ssize_t nsent; ssize_t nsent;
#endif #endif
int err; int errcode;
/* If to is NULL or tolen is zero, then this function is same as send (for /* If to is NULL or tolen is zero, then this function is same as send (for
* connected socket types) * connected socket types)
@ -140,7 +140,7 @@ ssize_t psock_sendto(FAR struct socket *psock, FAR const void *buf,
return psock_send(psock, buf, len, flags); return psock_send(psock, buf, len, flags);
#else #else
ndbg("ERROR: No 'to' address\n"); ndbg("ERROR: No 'to' address\n");
err = EINVAL; errcode = EINVAL;
goto errout; goto errout;
#endif #endif
} }
@ -169,14 +169,14 @@ ssize_t psock_sendto(FAR struct socket *psock, FAR const void *buf,
default: default:
ndbg("ERROR: Unrecognized address family: %d\n", to->sa_family); ndbg("ERROR: Unrecognized address family: %d\n", to->sa_family);
err = EAFNOSUPPORT; errcode = EAFNOSUPPORT;
goto errout; goto errout;
} }
if (tolen < minlen) if (tolen < minlen)
{ {
ndbg("ERROR: Invalid address length: %d < %d\n", tolen, minlen); ndbg("ERROR: Invalid address length: %d < %d\n", tolen, minlen);
err = EBADF; errcode = EBADF;
goto errout; goto errout;
} }
@ -185,7 +185,7 @@ ssize_t psock_sendto(FAR struct socket *psock, FAR const void *buf,
if (!psock || psock->s_crefs <= 0) if (!psock || psock->s_crefs <= 0)
{ {
ndbg("ERROR: Invalid socket\n"); ndbg("ERROR: Invalid socket\n");
err = EBADF; errcode = EBADF;
goto errout; goto errout;
} }
@ -194,7 +194,7 @@ ssize_t psock_sendto(FAR struct socket *psock, FAR const void *buf,
if (psock->s_type != SOCK_DGRAM) if (psock->s_type != SOCK_DGRAM)
{ {
ndbg("ERROR: Connected socket\n"); ndbg("ERROR: Connected socket\n");
err = EISCONN; errcode = EISCONN;
goto errout; goto errout;
} }
@ -226,17 +226,17 @@ ssize_t psock_sendto(FAR struct socket *psock, FAR const void *buf,
if (nsent < 0) if (nsent < 0)
{ {
ndbg("ERROR: UDP or Unix domain sendto() failed: %ld\n", (long)nsent); ndbg("ERROR: UDP or Unix domain sendto() failed: %ld\n", (long)nsent);
err = -nsent; errcode = -nsent;
goto errout; goto errout;
} }
return nsent; return nsent;
#else #else
err = ENOSYS; errcode = ENOSYS;
#endif /* CONFIG_NET_UDP || CONFIG_NET_LOCAL_DGRAM */ #endif /* CONFIG_NET_UDP || CONFIG_NET_LOCAL_DGRAM */
errout: errout:
set_errno(err); set_errno(errcode);
return ERROR; return ERROR;
} }

View File

@ -106,13 +106,13 @@ int psock_setsockopt(FAR struct socket *psock, int level, int option,
FAR const void *value, socklen_t value_len) FAR const void *value, socklen_t value_len)
{ {
net_lock_t flags; net_lock_t flags;
int err; int errcode;
/* Verify that the socket option if valid (but might not be supported ) */ /* Verify that the socket option if valid (but might not be supported ) */
if (!_SO_SETVALID(option) || !value) if (!_SO_SETVALID(option) || !value)
{ {
err = EINVAL; errcode = EINVAL;
goto errout; goto errout;
} }
@ -141,7 +141,7 @@ int psock_setsockopt(FAR struct socket *psock, int level, int option,
if (value_len != sizeof(int)) if (value_len != sizeof(int))
{ {
err = EINVAL; errcode = EINVAL;
goto errout; goto errout;
} }
@ -180,7 +180,7 @@ int psock_setsockopt(FAR struct socket *psock, int level, int option,
if (tv == NULL || value_len != sizeof(struct timeval)) if (tv == NULL || value_len != sizeof(struct timeval))
{ {
err = EINVAL; errcode = EINVAL;
goto errout; goto errout;
} }
@ -223,7 +223,7 @@ int psock_setsockopt(FAR struct socket *psock, int level, int option,
if (value_len < sizeof(FAR struct linger)) if (value_len < sizeof(FAR struct linger))
{ {
err = EINVAL; errcode = EINVAL;
goto errout; goto errout;
} }
@ -268,14 +268,14 @@ int psock_setsockopt(FAR struct socket *psock, int level, int option,
case SO_TYPE: /* Reports the socket type */ case SO_TYPE: /* Reports the socket type */
default: default:
err = ENOPROTOOPT; errcode = ENOPROTOOPT;
goto errout; goto errout;
} }
return OK; return OK;
errout: errout:
set_errno(err); set_errno(errcode);
return ERROR; return ERROR;
} }

View File

@ -248,7 +248,7 @@ int psock_socket(int domain, int type, int protocol, FAR struct socket *psock)
#endif #endif
bool dgramok = false; bool dgramok = false;
int ret; int ret;
int err; int errcode;
/* Only PF_INET, PF_INET6 or PF_PACKET domains supported */ /* Only PF_INET, PF_INET6 or PF_PACKET domains supported */
@ -284,7 +284,7 @@ int psock_socket(int domain, int type, int protocol, FAR struct socket *psock)
#endif #endif
default: default:
err = EAFNOSUPPORT; errcode = EAFNOSUPPORT;
goto errout; goto errout;
} }
@ -305,7 +305,7 @@ int psock_socket(int domain, int type, int protocol, FAR struct socket *psock)
{ {
if ((protocol != 0 && protocol != IPPROTO_TCP) || !dgramok) if ((protocol != 0 && protocol != IPPROTO_TCP) || !dgramok)
{ {
err = EPROTONOSUPPORT; errcode = EPROTONOSUPPORT;
goto errout; goto errout;
} }
} }
@ -318,7 +318,7 @@ int psock_socket(int domain, int type, int protocol, FAR struct socket *psock)
{ {
if (protocol != 0 || !dgramok) if (protocol != 0 || !dgramok)
{ {
err = EPROTONOSUPPORT; errcode = EPROTONOSUPPORT;
goto errout; goto errout;
} }
} }
@ -336,7 +336,7 @@ int psock_socket(int domain, int type, int protocol, FAR struct socket *psock)
{ {
if ((protocol != 0 && protocol != IPPROTO_UDP) || !dgramok) if ((protocol != 0 && protocol != IPPROTO_UDP) || !dgramok)
{ {
err = EPROTONOSUPPORT; errcode = EPROTONOSUPPORT;
goto errout; goto errout;
} }
} }
@ -349,7 +349,7 @@ int psock_socket(int domain, int type, int protocol, FAR struct socket *psock)
{ {
if (protocol != 0 || !dgramok) if (protocol != 0 || !dgramok)
{ {
err = EPROTONOSUPPORT; errcode = EPROTONOSUPPORT;
goto errout; goto errout;
} }
} }
@ -362,7 +362,7 @@ int psock_socket(int domain, int type, int protocol, FAR struct socket *psock)
case SOCK_RAW: case SOCK_RAW:
if (dgramok) if (dgramok)
{ {
err = EPROTONOSUPPORT; errcode = EPROTONOSUPPORT;
goto errout; goto errout;
} }
@ -370,7 +370,7 @@ int psock_socket(int domain, int type, int protocol, FAR struct socket *psock)
#endif #endif
default: default:
err = EPROTONOSUPPORT; errcode = EPROTONOSUPPORT;
goto errout; goto errout;
} }
@ -389,7 +389,7 @@ int psock_socket(int domain, int type, int protocol, FAR struct socket *psock)
* not actually be initialized until the socket is connected. * not actually be initialized until the socket is connected.
*/ */
err = ENOMEM; /* Assume failure to allocate connection instance */ errcode = ENOMEM; /* Assume failure to allocate connection instance */
switch (type) switch (type)
{ {
#if defined(CONFIG_NET_TCP) || defined(CONFIG_NET_LOCAL_STREAM) #if defined(CONFIG_NET_TCP) || defined(CONFIG_NET_LOCAL_STREAM)
@ -423,7 +423,7 @@ int psock_socket(int domain, int type, int protocol, FAR struct socket *psock)
{ {
/* Failed to reserve a connection structure */ /* Failed to reserve a connection structure */
err = -ret; errcode = -ret;
goto errout; goto errout;
} }
} }
@ -461,7 +461,7 @@ int psock_socket(int domain, int type, int protocol, FAR struct socket *psock)
{ {
/* Failed to reserve a connection structure */ /* Failed to reserve a connection structure */
err = -ret; errcode = -ret;
goto errout; goto errout;
} }
} }
@ -476,7 +476,7 @@ int psock_socket(int domain, int type, int protocol, FAR struct socket *psock)
{ {
/* Failed to reserve a connection structure */ /* Failed to reserve a connection structure */
err = -ret; errcode = -ret;
goto errout; goto errout;
} }
} }
@ -490,7 +490,7 @@ int psock_socket(int domain, int type, int protocol, FAR struct socket *psock)
return OK; return OK;
errout: errout:
set_errno(err); set_errno(errcode);
return ERROR; return ERROR;
} }

View File

@ -936,20 +936,20 @@ ssize_t psock_tcp_send(FAR struct socket *psock, FAR const void *buf,
FAR struct tcp_wrbuffer_s *wrb; FAR struct tcp_wrbuffer_s *wrb;
net_lock_t save; net_lock_t save;
ssize_t result = 0; ssize_t result = 0;
int err; int errcode;
int ret = OK; int ret = OK;
if (!psock || psock->s_crefs <= 0) if (!psock || psock->s_crefs <= 0)
{ {
ndbg("ERROR: Invalid socket\n"); ndbg("ERROR: Invalid socket\n");
err = EBADF; errcode = EBADF;
goto errout; goto errout;
} }
if (psock->s_type != SOCK_STREAM || !_SS_ISCONNECTED(psock->s_flags)) if (psock->s_type != SOCK_STREAM || !_SS_ISCONNECTED(psock->s_flags))
{ {
ndbg("ERROR: Not connected\n"); ndbg("ERROR: Not connected\n");
err = ENOTCONN; errcode = ENOTCONN;
goto errout; goto errout;
} }
@ -986,7 +986,7 @@ ssize_t psock_tcp_send(FAR struct socket *psock, FAR const void *buf,
if (ret < 0) if (ret < 0)
{ {
ndbg("ERROR: Not reachable\n"); ndbg("ERROR: Not reachable\n");
err = ENETUNREACH; errcode = ENETUNREACH;
goto errout; goto errout;
} }
#endif /* CONFIG_NET_ARP_SEND || CONFIG_NET_ICMPv6_NEIGHBOR */ #endif /* CONFIG_NET_ARP_SEND || CONFIG_NET_ICMPv6_NEIGHBOR */
@ -1012,7 +1012,7 @@ ssize_t psock_tcp_send(FAR struct socket *psock, FAR const void *buf,
/* A buffer allocation error occurred */ /* A buffer allocation error occurred */
ndbg("ERROR: Failed to allocate write buffer\n"); ndbg("ERROR: Failed to allocate write buffer\n");
err = ENOMEM; errcode = ENOMEM;
goto errout_with_lock; goto errout_with_lock;
} }
@ -1030,7 +1030,7 @@ ssize_t psock_tcp_send(FAR struct socket *psock, FAR const void *buf,
/* A buffer allocation error occurred */ /* A buffer allocation error occurred */
ndbg("ERROR: Failed to allocate callback\n"); ndbg("ERROR: Failed to allocate callback\n");
err = ENOMEM; errcode = ENOMEM;
goto errout_with_wrb; goto errout_with_wrb;
} }
@ -1076,7 +1076,7 @@ ssize_t psock_tcp_send(FAR struct socket *psock, FAR const void *buf,
if (result < 0) if (result < 0)
{ {
err = result; errcode = result;
goto errout; goto errout;
} }
@ -1086,7 +1086,7 @@ ssize_t psock_tcp_send(FAR struct socket *psock, FAR const void *buf,
if (ret < 0) if (ret < 0)
{ {
err = -ret; errcode = -ret;
goto errout; goto errout;
} }
@ -1101,7 +1101,7 @@ errout_with_lock:
net_unlock(save); net_unlock(save);
errout: errout:
set_errno(err); set_errno(errcode);
return ERROR; return ERROR;
} }

View File

@ -719,7 +719,7 @@ ssize_t psock_tcp_send(FAR struct socket *psock,
FAR struct tcp_conn_s *conn = (FAR struct tcp_conn_s *)psock->s_conn; FAR struct tcp_conn_s *conn = (FAR struct tcp_conn_s *)psock->s_conn;
struct send_s state; struct send_s state;
net_lock_t save; net_lock_t save;
int err; int errcode;
int ret = OK; int ret = OK;
/* Verify that the sockfd corresponds to valid, allocated socket */ /* Verify that the sockfd corresponds to valid, allocated socket */
@ -727,7 +727,7 @@ ssize_t psock_tcp_send(FAR struct socket *psock,
if (!psock || psock->s_crefs <= 0) if (!psock || psock->s_crefs <= 0)
{ {
ndbg("ERROR: Invalid socket\n"); ndbg("ERROR: Invalid socket\n");
err = EBADF; errcode = EBADF;
goto errout; goto errout;
} }
@ -736,7 +736,7 @@ ssize_t psock_tcp_send(FAR struct socket *psock,
if (psock->s_type != SOCK_STREAM || !_SS_ISCONNECTED(psock->s_flags)) if (psock->s_type != SOCK_STREAM || !_SS_ISCONNECTED(psock->s_flags))
{ {
ndbg("ERROR: Not connected\n"); ndbg("ERROR: Not connected\n");
err = ENOTCONN; errcode = ENOTCONN;
goto errout; goto errout;
} }
@ -774,7 +774,7 @@ ssize_t psock_tcp_send(FAR struct socket *psock,
if (ret < 0) if (ret < 0)
{ {
ndbg("ERROR: Not reachable\n"); ndbg("ERROR: Not reachable\n");
err = ENETUNREACH; errcode = ENETUNREACH;
goto errout; goto errout;
} }
#endif /* CONFIG_NET_ARP_SEND || CONFIG_NET_ICMPv6_NEIGHBOR */ #endif /* CONFIG_NET_ARP_SEND || CONFIG_NET_ICMPv6_NEIGHBOR */
@ -857,7 +857,7 @@ ssize_t psock_tcp_send(FAR struct socket *psock,
if (state.snd_sent < 0) if (state.snd_sent < 0)
{ {
err = state.snd_sent; errcode = state.snd_sent;
goto errout; goto errout;
} }
@ -867,7 +867,7 @@ ssize_t psock_tcp_send(FAR struct socket *psock,
if (ret < 0) if (ret < 0)
{ {
err = -ret; errcode = -ret;
goto errout; goto errout;
} }
@ -876,7 +876,7 @@ ssize_t psock_tcp_send(FAR struct socket *psock,
return state.snd_sent; return state.snd_sent;
errout: errout:
set_errno(err); set_errno(errcode);
return ERROR; return ERROR;
} }

View File

@ -161,7 +161,7 @@ int waitid(idtype_t idtype, id_t id, FAR siginfo_t *info, int options)
bool retains; bool retains;
#endif #endif
sigset_t set; sigset_t set;
int err; int errcode;
int ret; int ret;
/* MISSING LOGIC: If WNOHANG is provided in the options, then this function /* MISSING LOGIC: If WNOHANG is provided in the options, then this function
@ -205,7 +205,7 @@ int waitid(idtype_t idtype, id_t id, FAR siginfo_t *info, int options)
{ {
/* There are no children */ /* There are no children */
err = ECHILD; errcode = ECHILD;
goto errout_with_errno; goto errout_with_errno;
} }
else if (idtype == P_PID) else if (idtype == P_PID)
@ -219,7 +219,7 @@ int waitid(idtype_t idtype, id_t id, FAR siginfo_t *info, int options)
if (!ctcb || ctcb->ppid != rtcb->pid) if (!ctcb || ctcb->ppid != rtcb->pid)
#endif #endif
{ {
err = ECHILD; errcode = ECHILD;
goto errout_with_errno; goto errout_with_errno;
} }
@ -233,7 +233,7 @@ int waitid(idtype_t idtype, id_t id, FAR siginfo_t *info, int options)
{ {
/* This specific pid is not a child */ /* This specific pid is not a child */
err = ECHILD; errcode = ECHILD;
goto errout_with_errno; goto errout_with_errno;
} }
} }
@ -243,7 +243,7 @@ int waitid(idtype_t idtype, id_t id, FAR siginfo_t *info, int options)
{ {
/* There are no children */ /* There are no children */
err = ECHILD; errcode = ECHILD;
goto errout_with_errno; goto errout_with_errno;
} }
else if (idtype == P_PID) else if (idtype == P_PID)
@ -257,7 +257,7 @@ int waitid(idtype_t idtype, id_t id, FAR siginfo_t *info, int options)
if (!ctcb || ctcb->ppid != rtcb->pid) if (!ctcb || ctcb->ppid != rtcb->pid)
#endif #endif
{ {
err = ECHILD; errcode = ECHILD;
goto errout_with_errno; goto errout_with_errno;
} }
} }
@ -327,7 +327,7 @@ int waitid(idtype_t idtype, id_t id, FAR siginfo_t *info, int options)
* to reported ECHILD than bogus status. * to reported ECHILD than bogus status.
*/ */
err = ECHILD; errcode = ECHILD;
goto errout_with_errno; goto errout_with_errno;
} }
} }
@ -346,7 +346,7 @@ int waitid(idtype_t idtype, id_t id, FAR siginfo_t *info, int options)
* Let's return ECHILD.. that is at least informative. * Let's return ECHILD.. that is at least informative.
*/ */
err = ECHILD; errcode = ECHILD;
goto errout_with_errno; goto errout_with_errno;
} }
#endif #endif
@ -400,7 +400,7 @@ int waitid(idtype_t idtype, id_t id, FAR siginfo_t *info, int options)
return OK; return OK;
errout_with_errno: errout_with_errno:
set_errno(err); set_errno(errcode);
errout: errout:
sched_unlock(); sched_unlock();
return ERROR; return ERROR;

View File

@ -180,7 +180,7 @@ pid_t waitpid(pid_t pid, int *stat_loc, int options)
FAR struct tcb_s *ctcb; FAR struct tcb_s *ctcb;
FAR struct task_group_s *group; FAR struct task_group_s *group;
bool mystat = false; bool mystat = false;
int err; int errcode;
int ret; int ret;
DEBUGASSERT(stat_loc); DEBUGASSERT(stat_loc);
@ -204,7 +204,7 @@ pid_t waitpid(pid_t pid, int *stat_loc, int options)
ctcb = sched_gettcb(pid); ctcb = sched_gettcb(pid);
if (!ctcb) if (!ctcb)
{ {
err = ECHILD; errcode = ECHILD;
goto errout_with_errno; goto errout_with_errno;
} }
@ -272,7 +272,7 @@ pid_t waitpid(pid_t pid, int *stat_loc, int options)
return pid; return pid;
errout_with_errno: errout_with_errno:
set_errno(err); set_errno(errcode);
errout: errout:
sched_unlock(); sched_unlock();
return ERROR; return ERROR;
@ -302,7 +302,7 @@ pid_t waitpid(pid_t pid, int *stat_loc, int options)
#endif #endif
FAR struct siginfo info; FAR struct siginfo info;
sigset_t set; sigset_t set;
int err; int errcode;
int ret; int ret;
DEBUGASSERT(stat_loc); DEBUGASSERT(stat_loc);
@ -337,7 +337,7 @@ pid_t waitpid(pid_t pid, int *stat_loc, int options)
if (rtcb->group->tg_children == NULL && retains) if (rtcb->group->tg_children == NULL && retains)
{ {
err = ECHILD; errcode = ECHILD;
goto errout_with_errno; goto errout_with_errno;
} }
else if (pid != (pid_t)-1) else if (pid != (pid_t)-1)
@ -351,7 +351,7 @@ pid_t waitpid(pid_t pid, int *stat_loc, int options)
if (!ctcb || ctcb->ppid != rtcb->pid) if (!ctcb || ctcb->ppid != rtcb->pid)
#endif #endif
{ {
err = ECHILD; errcode = ECHILD;
goto errout_with_errno; goto errout_with_errno;
} }
@ -363,7 +363,7 @@ pid_t waitpid(pid_t pid, int *stat_loc, int options)
if (group_findchild(rtcb->group, pid) == NULL) if (group_findchild(rtcb->group, pid) == NULL)
{ {
err = ECHILD; errcode = ECHILD;
goto errout_with_errno; goto errout_with_errno;
} }
} }
@ -375,7 +375,7 @@ pid_t waitpid(pid_t pid, int *stat_loc, int options)
{ {
/* There are no children */ /* There are no children */
err = ECHILD; errcode = ECHILD;
goto errout_with_errno; goto errout_with_errno;
} }
else if (pid != (pid_t)-1) else if (pid != (pid_t)-1)
@ -389,7 +389,7 @@ pid_t waitpid(pid_t pid, int *stat_loc, int options)
if (!ctcb || ctcb->ppid != rtcb->pid) if (!ctcb || ctcb->ppid != rtcb->pid)
#endif #endif
{ {
err = ECHILD; errcode = ECHILD;
goto errout_with_errno; goto errout_with_errno;
} }
} }
@ -472,7 +472,7 @@ pid_t waitpid(pid_t pid, int *stat_loc, int options)
* to reported ECHILD than bogus status. * to reported ECHILD than bogus status.
*/ */
err = ECHILD; errcode = ECHILD;
goto errout_with_errno; goto errout_with_errno;
} }
} }
@ -493,7 +493,7 @@ pid_t waitpid(pid_t pid, int *stat_loc, int options)
* Let's return ECHILD.. that is at least informative. * Let's return ECHILD.. that is at least informative.
*/ */
err = ECHILD; errcode = ECHILD;
goto errout_with_errno; goto errout_with_errno;
} }
@ -526,7 +526,7 @@ pid_t waitpid(pid_t pid, int *stat_loc, int options)
return (int)pid; return (int)pid;
errout_with_errno: errout_with_errno:
set_errno(err); set_errno(errcode);
errout_with_lock: errout_with_lock:
sched_unlock(); sched_unlock();

View File

@ -77,7 +77,7 @@
int prctl(int option, ...) int prctl(int option, ...)
{ {
va_list ap; va_list ap;
int err; int errcode;
va_start(ap, option); va_start(ap, option);
switch (option) switch (option)
@ -112,7 +112,7 @@ int prctl(int option, ...)
if (!tcb) if (!tcb)
{ {
sdbg("Pid does not correspond to a task: %d\n", pid); sdbg("Pid does not correspond to a task: %d\n", pid);
err = ESRCH; errcode = ESRCH;
goto errout; goto errout;
} }
@ -121,7 +121,7 @@ int prctl(int option, ...)
if (!name) if (!name)
{ {
sdbg("No name provide\n"); sdbg("No name provide\n");
err = EFAULT; errcode = EFAULT;
goto errout; goto errout;
} }
@ -145,13 +145,13 @@ int prctl(int option, ...)
break; break;
#else #else
sdbg("Option not enabled: %d\n", option); sdbg("Option not enabled: %d\n", option);
err = ENOSYS; errcode = ENOSYS;
goto errout; goto errout;
#endif #endif
default: default:
sdbg("Unrecognized option: %d\n", option); sdbg("Unrecognized option: %d\n", option);
err = EINVAL; errcode = EINVAL;
goto errout; goto errout;
} }
@ -166,6 +166,6 @@ int prctl(int option, ...)
errout: errout:
va_end(ap); va_end(ap);
set_errno(err); set_errno(errcode);
return ERROR; return ERROR;
} }

View File

@ -83,7 +83,7 @@ int task_restart(pid_t pid)
FAR struct task_tcb_s *tcb; FAR struct task_tcb_s *tcb;
FAR dq_queue_t *tasklist; FAR dq_queue_t *tasklist;
irqstate_t flags; irqstate_t flags;
int err; int errcode;
int status; int status;
/* Make sure this task does not become ready-to-run while we are futzing /* Make sure this task does not become ready-to-run while we are futzing
@ -99,7 +99,7 @@ int task_restart(pid_t pid)
{ {
/* Not implemented */ /* Not implemented */
err = ENOSYS; errcode = ENOSYS;
goto errout_with_lock; goto errout_with_lock;
} }
@ -115,7 +115,7 @@ int task_restart(pid_t pid)
{ {
/* There is no TCB with this pid or, if there is, it is not a task. */ /* There is no TCB with this pid or, if there is, it is not a task. */
err = ESRCH; errcode = ESRCH;
goto errout_with_lock; goto errout_with_lock;
} }
@ -133,7 +133,7 @@ int task_restart(pid_t pid)
{ {
/* Not implemented */ /* Not implemented */
err = ENOSYS; errcode = ENOSYS;
goto errout_with_lock; goto errout_with_lock;
} }
#endif /* CONFIG_SMP */ #endif /* CONFIG_SMP */
@ -197,7 +197,7 @@ int task_restart(pid_t pid)
if (status != OK) if (status != OK)
{ {
(void)task_delete(pid); (void)task_delete(pid);
err = -status; errcode = -status;
goto errout_with_lock; goto errout_with_lock;
} }
@ -205,7 +205,7 @@ int task_restart(pid_t pid)
return OK; return OK;
errout_with_lock: errout_with_lock:
set_errno(err); set_errno(errcode);
sched_unlock(); sched_unlock();
return ERROR; return ERROR;
} }

View File

@ -239,7 +239,7 @@ int main(int argc, char **argv, char **envp)
char *destfile; char *destfile;
FILE *src; FILE *src;
FILE *dest; FILE *dest;
int err; int errcode;
if (argc != 2) if (argc != 2)
{ {
@ -258,7 +258,7 @@ int main(int argc, char **argv, char **envp)
if (!destfile) if (!destfile)
{ {
fprintf(stderr, "getfilepath failed\n"); fprintf(stderr, "getfilepath failed\n");
err = 2; errcode = 2;
goto errout_with_srcfile; goto errout_with_srcfile;
} }
@ -266,7 +266,7 @@ int main(int argc, char **argv, char **envp)
if (!src) if (!src)
{ {
fprintf(stderr, "open %s failed: %s\n", srcfile, strerror(errno)); fprintf(stderr, "open %s failed: %s\n", srcfile, strerror(errno));
err = 3; errcode = 3;
goto errout_with_destfile; goto errout_with_destfile;
} }
@ -274,7 +274,7 @@ int main(int argc, char **argv, char **envp)
if (!dest) if (!dest)
{ {
fprintf(stderr, "open %s failed: %s\n", destfile, strerror(errno)); fprintf(stderr, "open %s failed: %s\n", destfile, strerror(errno));
err = 3; errcode = 3;
goto errout_with_destfile; goto errout_with_destfile;
} }
@ -285,7 +285,7 @@ int main(int argc, char **argv, char **envp)
if (parse_line(&hexline)) if (parse_line(&hexline))
{ {
fprintf(stderr, "Failed to parse line\n"); fprintf(stderr, "Failed to parse line\n");
err = 1; errcode = 1;
goto errout_with_destfile; goto errout_with_destfile;
} }
@ -325,5 +325,5 @@ errout_with_destfile:
free(destfile); free(destfile);
errout_with_srcfile: errout_with_srcfile:
free(srcfile); free(srcfile);
return err; return errcode;
} }