diff --git a/arch/arm/src/lpc2378/lpc23xx_serial.c b/arch/arm/src/lpc2378/lpc23xx_serial.c index 90e62bf0a7..d582fe5de3 100644 --- a/arch/arm/src/lpc2378/lpc23xx_serial.c +++ b/arch/arm/src/lpc2378/lpc23xx_serial.c @@ -320,14 +320,14 @@ static inline void up_configbaud(struct up_dev_s *priv) /* Test values calculated for every multiplier/divisor combination */ uint32_t tdiv; - uint32_t terr; + uint32_t tmperr; int tmulval; int tdivaddval; /* Optimal multiplier/divider values */ uint32_t div = 0; - uint32_t err = 100000; + uint32_t errval = 100000; int mulval = 1; 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). */ - 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 * 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 */ @@ -373,16 +373,16 @@ static inline void up_configbaud(struct up_dev_s *priv) if (actualbaud <= priv->baud) { - terr = priv->baud - actualbaud; + tmperr = priv->baud - actualbaud; } else { - terr = actualbaud - priv->baud; + tmperr = actualbaud - priv->baud; } /* Is this the smallest error we have encountered? */ - if (terr < err) + if (tmperr < errval) { /* Yes, save these settings as the new, candidate optimal * settings @@ -391,7 +391,7 @@ static inline void up_configbaud(struct up_dev_s *priv) mulval = tmulval; divaddval = tdivaddval; div = tdiv; - err = terr; + errval = tmperr; } } } diff --git a/arch/arm/src/lpc31xx/lpc31_lowputc.c b/arch/arm/src/lpc31xx/lpc31_lowputc.c index 3e3213927f..7d1335fd5a 100644 --- a/arch/arm/src/lpc31xx/lpc31_lowputc.c +++ b/arch/arm/src/lpc31xx/lpc31_lowputc.c @@ -144,14 +144,14 @@ static inline void up_configbaud(void) /* Test values calculated for every multiplier/divisor combination */ uint32_t tdiv; - uint32_t terr; + uint32_t tmperr; int tmulval; int tdivaddval; /* Optimal multiplier/divider values */ uint32_t div = 0; - uint32_t err = 100000; + uint32_t errval = 100000; int mulval = 1; int divaddval = 0; @@ -176,13 +176,13 @@ static inline void up_configbaud(void) * 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 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 */ @@ -199,23 +199,23 @@ static inline void up_configbaud(void) if (actualbaud <= CONFIG_UART_BAUD) { - terr = CONFIG_UART_BAUD - actualbaud; + tmperr = CONFIG_UART_BAUD - actualbaud; } else { - terr = actualbaud - CONFIG_UART_BAUD; + tmperr = actualbaud - CONFIG_UART_BAUD; } /* Is this the smallest error we have encountered? */ - if (terr < err) + if (tmperr < errval) { /* Yes, save these settings as the new, candidate optimal settings */ - mulval = tmulval ; + mulval = tmulval ; divaddval = tdivaddval; div = tdiv; - err = terr; + errval = tmperr; } } } diff --git a/arch/arm/src/lpc31xx/lpc31_serial.c b/arch/arm/src/lpc31xx/lpc31_serial.c index 74a0db9ddd..e64e91352e 100644 --- a/arch/arm/src/lpc31xx/lpc31_serial.c +++ b/arch/arm/src/lpc31xx/lpc31_serial.c @@ -215,14 +215,14 @@ static inline void up_configbaud(void) /* Test values calculated for every multiplier/divisor combination */ uint32_t tdiv; - uint32_t terr; + uint32_t tmperr; int tmulval; int tdivaddval; /* Optimal multiplier/divider values */ uint32_t div = 0; - uint32_t err = 100000; + uint32_t errval = 100000; int mulval = 1; int divaddval = 0; @@ -247,13 +247,13 @@ static inline void up_configbaud(void) * 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 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 */ @@ -270,23 +270,23 @@ static inline void up_configbaud(void) if (actualbaud <= CONFIG_UART_BAUD) { - terr = CONFIG_UART_BAUD - actualbaud; + tmperr = CONFIG_UART_BAUD - actualbaud; } else { - terr = actualbaud - CONFIG_UART_BAUD; + tmperr = actualbaud - CONFIG_UART_BAUD; } /* Is this the smallest error we have encountered? */ - if (terr < err) + if (tmperr < errval) { /* Yes, save these settings as the new, candidate optimal settings */ - mulval = tmulval ; + mulval = tmulval ; divaddval = tdivaddval; div = tdiv; - err = terr; + errval = tmperr; } } } diff --git a/arch/arm/src/lpc43xx/spifi/src/spifilib_dev_common.c b/arch/arm/src/lpc43xx/spifi/src/spifilib_dev_common.c index 8adc8f762b..c3e0a7b53b 100644 --- a/arch/arm/src/lpc43xx/spifi/src/spifilib_dev_common.c +++ b/arch/arm/src/lpc43xx/spifi/src/spifilib_dev_common.c @@ -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) { uint32_t sendBytes; - SPIFI_ERR_T err = SPIFI_ERR_NONE; + SPIFI_ERR_T errcode = SPIFI_ERR_NONE; /* Program using up to page size */ - while ((bytes > 0) && (err == SPIFI_ERR_NONE)) { + while ((bytes > 0) && (errcode == SPIFI_ERR_NONE)) { sendBytes = bytes; if (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; writeBuff += (sendBytes >> 2); bytes -= sendBytes; } - return err; + return errcode; } /* 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) { 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 */ - while ((bytes > 0) && (err == SPIFI_ERR_NONE)) { + while ((bytes > 0) && (errcode == SPIFI_ERR_NONE)) { readBytes = bytes; if (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; readBuff += (readBytes / sizeof(uint32_t)); bytes -= readBytes; } - return err; + return errcode; } /* Erase multiple blocks */ 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) { 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 */ for (; (numBlocks); ++firstBlock, --numBlocks) { - err = pHandle->pFamFx->eraseBlock(pHandle, firstBlock); - if (err != SPIFI_ERR_NONE) { + errcode = pHandle->pFamFx->eraseBlock(pHandle, firstBlock); + if (errcode != SPIFI_ERR_NONE) { break; } } - return err; + return errcode; } /* Erase multiple blocks by address range */ SPIFI_ERR_T spifiEraseByAddr(const SPIFI_HANDLE_T *pHandle, uint32_t firstAddr, uint32_t lastAddr) { uint32_t firstBlock, lastBlock; - SPIFI_ERR_T err = SPIFI_ERR_RANGE; + SPIFI_ERR_T errcode = SPIFI_ERR_RANGE; /* Get block numbers for addresses */ 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 */ if ((firstBlock != ~0UL) && (lastBlock != ~0UL)) { - err = spifiErase(pHandle, firstBlock, ((lastBlock - firstBlock) + 1)); + errcode = spifiErase(pHandle, firstBlock, ((lastBlock - firstBlock) + 1)); } - return err; + return errcode; } diff --git a/arch/rgmp/src/x86/com.c b/arch/rgmp/src/x86/com.c index 8a149bcadc..c31e301a7b 100644 --- a/arch/rgmp/src/x86/com.c +++ b/arch/rgmp/src/x86/com.c @@ -315,11 +315,11 @@ static void up_shutdown(struct uart_dev_s *dev) static int up_attach(struct uart_dev_s *dev) { 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) { uart_dev_t *dev; - int err; + int errcode; #ifdef CONFIG_COM1 dev = up_alloc_com(COM1, 4); if (dev == NULL) dbg("alloc com1 fail\n"); else { - err = uart_register("/dev/ttyS0", dev); - if (err) + errcode = uart_register("/dev/ttyS0", dev); + if (errcode) dbg("register com1 fail\n"); } #endif @@ -595,8 +595,8 @@ void up_serialinit(void) if (dev == NULL) dbg("alloc com2 fail\n"); else { - err = uart_register("/dev/ttyS1", dev); - if (err) + errcode = uart_register("/dev/ttyS1", dev); + if (errcode) dbg("register com2 fail\n"); } #endif @@ -605,8 +605,8 @@ void up_serialinit(void) if (dev == NULL) dbg("alloc com3 fail\n"); else { - err = uart_register("/dev/ttyS2", dev); - if (err) + errcode = uart_register("/dev/ttyS2", dev); + if (errcode) dbg("register com3 fail\n"); } #endif @@ -615,8 +615,8 @@ void up_serialinit(void) if (dev == NULL) dbg("alloc com4 fail\n"); else { - err = uart_register("/dev/ttyS3", dev); - if (err) + errcode = uart_register("/dev/ttyS3", dev); + if (errcode) dbg("register com4 fail\n"); } #endif diff --git a/binfmt/binfmt_exec.c b/binfmt/binfmt_exec.c index f3f62027eb..6352b0f981 100644 --- a/binfmt/binfmt_exec.c +++ b/binfmt/binfmt_exec.c @@ -86,7 +86,7 @@ int exec(FAR const char *filename, FAR char * const *argv, #if defined(CONFIG_SCHED_ONEXIT) && defined(CONFIG_SCHED_HAVE_PARENT) FAR struct binary_s *bin; int pid; - int err; + int errcode; int ret; /* Allocate the load information */ @@ -95,7 +95,7 @@ int exec(FAR const char *filename, FAR char * const *argv, if (!bin) { bdbg("ERROR: Failed to allocate binary_s\n"); - err = ENOMEM; + errcode = ENOMEM; goto errout; } @@ -110,8 +110,8 @@ int exec(FAR const char *filename, FAR char * const *argv, ret = binfmt_copyargv(bin, argv); if (ret < 0) { - err = -ret; - bdbg("ERROR: Failed to copy argv[]: %d\n", err); + errcode = -ret; + bdbg("ERROR: Failed to copy argv[]: %d\n", errcode); goto errout_with_bin; } @@ -120,8 +120,8 @@ int exec(FAR const char *filename, FAR char * const *argv, ret = load_module(bin); if (ret < 0) { - err = get_errno(); - bdbg("ERROR: Failed to load program '%s': %d\n", filename, err); + errcode = get_errno(); + bdbg("ERROR: Failed to load program '%s': %d\n", filename, errcode); goto errout_with_argv; } @@ -137,8 +137,8 @@ int exec(FAR const char *filename, FAR char * const *argv, pid = exec_module(bin); if (pid < 0) { - err = get_errno(); - bdbg("ERROR: Failed to execute program '%s': %d\n", filename, err); + errcode = get_errno(); + bdbg("ERROR: Failed to execute program '%s': %d\n", filename, errcode); goto errout_with_lock; } @@ -149,8 +149,8 @@ int exec(FAR const char *filename, FAR char * const *argv, ret = schedule_unload(pid, bin); if (ret < 0) { - err = get_errno(); - bdbg("ERROR: Failed to schedule unload '%s': %d\n", filename, err); + errcode = get_errno(); + bdbg("ERROR: Failed to schedule unload '%s': %d\n", filename, errcode); } sched_unlock(); @@ -164,12 +164,12 @@ errout_with_argv: errout_with_bin: kmm_free(bin); errout: - set_errno(err); + set_errno(errcode); return ERROR; #else struct binary_s bin; - int err; + int errcode; int ret; /* Load the module into memory */ @@ -182,8 +182,8 @@ errout: ret = load_module(&bin); if (ret < 0) { - err = get_errno(); - bdbg("ERROR: Failed to load program '%s': %d\n", filename, err); + errcode = get_errno(); + bdbg("ERROR: Failed to load program '%s': %d\n", filename, errcode); goto errout; } @@ -192,8 +192,8 @@ errout: ret = exec_module(&bin); if (ret < 0) { - err = get_errno(); - bdbg("ERROR: Failed to execute program '%s': %d\n", filename, err); + errcode = get_errno(); + bdbg("ERROR: Failed to execute program '%s': %d\n", filename, errcode); goto errout_with_module; } @@ -204,10 +204,9 @@ errout: errout_with_module: unload_module(&bin); errout: - set_errno(err); + set_errno(errcode); return ERROR; #endif } #endif /* !CONFIG_BINFMT_DISABLE */ - diff --git a/binfmt/binfmt_execmodule.c b/binfmt/binfmt_execmodule.c index 3afe49042e..32b35c15aa 100644 --- a/binfmt/binfmt_execmodule.c +++ b/binfmt/binfmt_execmodule.c @@ -142,7 +142,7 @@ int exec_module(FAR const struct binary_s *binp) #endif FAR uint32_t *stack; pid_t pid; - int err; + int errcode; int ret; /* Sanity checking */ @@ -150,7 +150,7 @@ int exec_module(FAR const struct binary_s *binp) #ifdef CONFIG_DEBUG_FEATURES if (!binp || !binp->entrypt || binp->stacksize <= 0) { - err = EINVAL; + errcode = EINVAL; goto errout; } #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)); if (!tcb) { - err = ENOMEM; + errcode = ENOMEM; goto errout; } @@ -173,7 +173,7 @@ int exec_module(FAR const struct binary_s *binp) if (ret < 0) { bdbg("ERROR: up_addrenv_select() failed: %d\n", ret); - err = -ret; + errcode = -ret; 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); if (!stack) { - err = ENOMEM; + errcode = ENOMEM; goto errout_with_addrenv; } @@ -202,8 +202,8 @@ int exec_module(FAR const struct binary_s *binp) stack, binp->stacksize, binp->entrypt, binp->argv); if (ret < 0) { - err = get_errno(); - bdbg("task_init() failed: %d\n", err); + errcode = get_errno(); + bdbg("task_init() failed: %d\n", errcode); goto errout_with_addrenv; } @@ -225,7 +225,7 @@ int exec_module(FAR const struct binary_s *binp) if (ret < 0) { bdbg("ERROR: up_addrenv_select() failed: %d\n", ret); - err = -ret; + errcode = -ret; goto errout_with_tcbinit; } #endif @@ -237,7 +237,7 @@ int exec_module(FAR const struct binary_s *binp) if (ret < 0) { bdbg("ERROR: shm_group_initialize() failed: %d\n", ret); - err = -ret; + errcode = -ret; goto errout_with_tcbinit; } #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); if (ret < 0) { - err = -ret; + errcode = -ret; bdbg("ERROR: up_addrenv_clone() failed: %d\n", ret); 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); if (ret < 0) { - err = get_errno(); - bdbg("task_activate() failed: %d\n", err); + errcode = get_errno(); + bdbg("task_activate() failed: %d\n", errcode); goto errout_with_tcbinit; } @@ -300,7 +300,7 @@ int exec_module(FAR const struct binary_s *binp) if (ret < 0) { bdbg("ERROR: up_addrenv_select() failed: %d\n", ret); - err = -ret; + errcode = -ret; goto errout_with_tcbinit; } #endif @@ -322,8 +322,8 @@ errout_with_tcb: kmm_free(tcb); errout: - set_errno(err); - bdbg("returning errno: %d\n", err); + set_errno(errcode); + bdbg("returning errno: %d\n", errcode); return ERROR; } diff --git a/drivers/analog/adc.c b/drivers/analog/adc.c index 92dd84d2b2..d11c962384 100644 --- a/drivers/analog/adc.c +++ b/drivers/analog/adc.c @@ -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; int nexttail; - int err = -ENOMEM; + int errcode = -ENOMEM; /* Check if adding this new message would over-run the drivers ability to enqueue * 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); } - err = OK; + errcode = OK; } - return err; + + return errcode; } /**************************************************************************** diff --git a/drivers/can.c b/drivers/can.c index 3e5e0750be..bd5cd96220 100644 --- a/drivers/can.c +++ b/drivers/can.c @@ -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 uint8_t *dest; int nexttail; - int err = -ENOMEM; + int errcode = -ENOMEM; int i; 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); } - err = OK; + errcode = OK; } #ifdef CONFIG_CAN_ERRORS else @@ -1124,7 +1124,7 @@ int can_receive(FAR struct can_dev_s *dev, FAR struct can_hdr_s *hdr, } #endif - return err; + return errcode; } /**************************************************************************** diff --git a/drivers/net/e1000.c b/drivers/net/e1000.c index 6f605554eb..c176abc732 100644 --- a/drivers/net/e1000.c +++ b/drivers/net/e1000.c @@ -1089,7 +1089,7 @@ static int e1000_probe(uint16_t addr, pci_id_t id) { uint32_t mmio_base, mmio_size; uint32_t size; - int err; + int errcode; void *kmem; void *omem; struct e1000_dev *dev; @@ -1107,7 +1107,7 @@ static int e1000_probe(uint16_t addr, pci_id_t id) /* enable device */ - if ((err = pci_enable_device(addr, PCI_BUS_MASTER)) < 0) + if ((errcode = pci_enable_device(addr, PCI_BUS_MASTER)) < 0) { 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_size = pci_resource_len(addr, 0); - err = rgmp_memmap_nocache(mmio_base, mmio_size, mmio_base); - if (err) + errcode = rgmp_memmap_nocache(mmio_base, mmio_size, mmio_base); + if (errcode) { 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.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; } @@ -1164,7 +1164,7 @@ static int e1000_probe(uint16_t addr, pci_id_t id) omem = kmem = memalign(PGSIZE, size); if (kmem == NULL) { - err = -ENOMEM; + errcode = -ENOMEM; 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 */ - err = netdev_register(&dev->netdev, NET_LL_ETHERNET); - if (err) + errcode = netdev_register(&dev->netdev, NET_LL_ETHERNET); + if (errcode) { goto err2; } @@ -1234,8 +1234,8 @@ err0: rgmp_memunmap(mmio_base, mmio_size); error: kmm_free(dev); - cprintf("e1000 device probe fail: %d\n", err); - return err; + cprintf("e1000 device probe fail: %d\n", errcode); + return errcode; } /**************************************************************************** diff --git a/drivers/net/vnet.c b/drivers/net/vnet.c index ef70eb100f..c96845c1b9 100644 --- a/drivers/net/vnet.c +++ b/drivers/net/vnet.c @@ -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) { - int err; + int errcode; /* 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 @@ -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 */ - err = vnet_xmit(vnet->vnet, (char *)vnet->sk_dev.d_buf, vnet->sk_dev.d_len); - if (err) + errcode = vnet_xmit(vnet->vnet, (char *)vnet->sk_dev.d_buf, vnet->sk_dev.d_len); + if (errcode) { /* When vnet_xmit fail, it means TX buffer is full. Watchdog * is of no use here because no TX done INT will happen. So diff --git a/drivers/pipes/pipe.c b/drivers/pipes/pipe.c index b4c6acd72c..715639d21c 100644 --- a/drivers/pipes/pipe.c +++ b/drivers/pipes/pipe.c @@ -189,7 +189,7 @@ int pipe(int fd[2]) FAR struct pipe_dev_s *dev = NULL; char devname[16]; int pipeno; - int err; + int errcode; int ret; /* Get exclusive access to the pipe allocation data */ @@ -208,7 +208,7 @@ int pipe(int fd[2]) if (pipeno < 0) { (void)sem_post(&g_pipesem); - err = -pipeno; + errcode = -pipeno; goto errout; } @@ -226,7 +226,7 @@ int pipe(int fd[2]) if (!dev) { (void)sem_post(&g_pipesem); - err = ENOMEM; + errcode = ENOMEM; goto errout_with_pipe; } @@ -238,7 +238,7 @@ int pipe(int fd[2]) if (ret != 0) { (void)sem_post(&g_pipesem); - err = -ret; + errcode = -ret; goto errout_with_dev; } @@ -254,7 +254,7 @@ int pipe(int fd[2]) fd[1] = open(devname, O_WRONLY); if (fd[1] < 0) { - err = -fd[1]; + errcode = -fd[1]; goto errout_with_driver; } @@ -263,7 +263,7 @@ int pipe(int fd[2]) fd[0] = open(devname, O_RDONLY); if (fd[0] < 0) { - err = -fd[0]; + errcode = -fd[0]; goto errout_with_wrfd; } @@ -285,7 +285,7 @@ errout_with_pipe: pipe_free(pipeno); errout: - set_errno(err); + set_errno(errcode); return ERROR; } diff --git a/fs/inode/fs_files.c b/fs/inode/fs_files.c index 7c4665640e..1667130c93 100644 --- a/fs/inode/fs_files.c +++ b/fs/inode/fs_files.c @@ -196,12 +196,12 @@ int file_dup2(FAR struct file *filep1, FAR struct file *filep2) { FAR struct filelist *list; FAR struct inode *inode; - int err; + int errcode; int ret; if (!filep1 || !filep1->f_inode || !filep2) { - err = EBADF; + errcode = EBADF; goto errout; } @@ -287,7 +287,7 @@ errout_with_inode: filep2->f_inode = NULL; errout_with_ret: - err = -ret; + errcode = -ret; if (list != NULL) { @@ -295,7 +295,7 @@ errout_with_ret: } errout: - set_errno(err); + set_errno(errcode); return ERROR; } diff --git a/fs/mmap/fs_munmap.c b/fs/mmap/fs_munmap.c index 12b084d85b..f15f34847a 100644 --- a/fs/mmap/fs_munmap.c +++ b/fs/mmap/fs_munmap.c @@ -115,7 +115,7 @@ int munmap(FAR void *start, size_t length) FAR void *newaddr; unsigned int offset; int ret; - int err; + int errcode; /* 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) { fdbg("Region not found\n"); - err = EINVAL; + errcode = EINVAL; goto errout_with_semaphore; } @@ -159,7 +159,7 @@ int munmap(FAR void *start, size_t length) if (offset + length < curr->length) { fdbg("Cannot umap without unmapping to the end\n"); - err = ENOSYS; + errcode = ENOSYS; goto errout_with_semaphore; } @@ -205,7 +205,7 @@ int munmap(FAR void *start, size_t length) errout_with_semaphore: sem_post(&g_rammaps.exclsem); - set_errno(err); + set_errno(errcode); return ERROR; } diff --git a/fs/mmap/fs_rammap.c b/fs/mmap/fs_rammap.c index 5f00032553..39ff5a24b1 100644 --- a/fs/mmap/fs_rammap.c +++ b/fs/mmap/fs_rammap.c @@ -121,7 +121,7 @@ FAR void *rammap(int fd, size_t length, off_t offset) FAR uint8_t *rdbuffer; ssize_t nread; off_t fpos; - int err; + int errcode; int ret; /* 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) { fdbg("Region allocation failed, length: %d\n", (int)length); - err = ENOMEM; + errcode = ENOMEM; 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); - err = EINVAL; + errcode = EINVAL; goto errout_with_region; } @@ -181,8 +181,8 @@ FAR void *rammap(int fd, size_t length, off_t offset) * signal. */ - err = get_errno(); - if (err != EINTR) + errcode = get_errno(); + if (errcode != EINTR) { /* All other read errors are bad. errno is already set. * (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. */ - 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 goto errout_with_region; #else @@ -234,7 +234,7 @@ FAR void *rammap(int fd, size_t length, off_t offset) errout_with_region: kumm_free(alloc); errout: - set_errno(err); + set_errno(errcode); return MAP_FAILED; errout_with_errno: diff --git a/fs/vfs/fs_close.c b/fs/vfs/fs_close.c index 3a52d0c086..a2b02b1d87 100644 --- a/fs/vfs/fs_close.c +++ b/fs/vfs/fs_close.c @@ -79,7 +79,7 @@ int close(int fd) { - int err; + int errcode; #if CONFIG_NFILE_DESCRIPTORS > 0 int ret; @@ -98,7 +98,7 @@ int close(int fd) else #endif { - err = EBADF; + errcode = EBADF; goto errout; } } @@ -119,7 +119,7 @@ int close(int fd) { /* An error occurred while closing the driver */ - err = -ret; + errcode = -ret; goto errout; } @@ -128,7 +128,6 @@ int close(int fd) #endif errout: - set_errno(err); + set_errno(errcode); return ERROR; } - diff --git a/fs/vfs/fs_fcntl.c b/fs/vfs/fs_fcntl.c index f4d67ae457..01ca8761fe 100644 --- a/fs/vfs/fs_fcntl.c +++ b/fs/vfs/fs_fcntl.c @@ -75,14 +75,14 @@ #if CONFIG_NFILE_DESCRIPTORS > 0 int file_vfcntl(FAR struct file *filep, int cmd, va_list ap) { - int err = 0; + int errcode = 0; int ret = OK; /* Was this file opened ? */ if (!filep->f_inode) { - err = EBADF; + errcode = EBADF; 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. */ - err = ENOSYS; + errcode = ENOSYS; break; 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. */ - err = EBADF; /* Only valid on socket descriptors */ + errcode = EBADF; /* Only valid on socket descriptors */ break; case F_GETLK: @@ -199,18 +199,18 @@ int file_vfcntl(FAR struct file *filep, int cmd, va_list ap) * not be done. */ - err = ENOSYS; /* Not implemented */ + errcode = ENOSYS; /* Not implemented */ break; default: - err = EINVAL; + errcode = EINVAL; break; } errout: - if (err != 0) + if (errcode != 0) { - set_errno(err); + set_errno(errcode); return ERROR; } diff --git a/fs/vfs/fs_fdopen.c b/fs/vfs/fs_fdopen.c index 882337da11..85abbf7989 100644 --- a/fs/vfs/fs_fdopen.c +++ b/fs/vfs/fs_fdopen.c @@ -129,7 +129,7 @@ FAR struct file_struct *fs_fdopen(int fd, int oflags, FAR struct tcb_s *tcb) { FAR struct streamlist *slist; FAR FILE *stream; - int err = OK; + int errcode = OK; int ret; int i; @@ -137,7 +137,7 @@ FAR struct file_struct *fs_fdopen(int fd, int oflags, FAR struct tcb_s *tcb) if (fd < 0) { - err = EBADF; + errcode = EBADF; goto errout; } @@ -173,7 +173,7 @@ FAR struct file_struct *fs_fdopen(int fd, int oflags, FAR struct tcb_s *tcb) #else /* No networking... it is just a bad descriptor */ - err = EBADF; + errcode = EBADF; goto errout; #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 */ - err = -ret; + errcode = -ret; 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) { - err = ENOMEM; + errcode = ENOMEM; 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 */ - err = ENFILE; + errcode = ENFILE; #if CONFIG_STDIO_BUFFER_SIZE > 0 errout_with_sem: @@ -274,7 +274,7 @@ errout_with_sem: sem_post(&slist->sl_sem); errout: - set_errno(err); + set_errno(errcode); errout_with_errno: return NULL; } diff --git a/fs/vfs/fs_ioctl.c b/fs/vfs/fs_ioctl.c index 593eae963a..238da907a7 100644 --- a/fs/vfs/fs_ioctl.c +++ b/fs/vfs/fs_ioctl.c @@ -91,7 +91,7 @@ int fs_ioctl(int fd, int req, unsigned long arg) int ioctl(int fd, int req, unsigned long arg) #endif { - int err; + int errcode; #if CONFIG_NFILE_DESCRIPTORS > 0 FAR struct file *filep; FAR struct inode *inode; @@ -112,7 +112,7 @@ int ioctl(int fd, int req, unsigned long arg) else #endif { - err = EBADF; + errcode = EBADF; 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); if (ret < 0) { - err = -ret; + errcode = -ret; goto errout; } } @@ -147,7 +147,6 @@ int ioctl(int fd, int req, unsigned long arg) #endif errout: - set_errno(err); + set_errno(errcode); return ERROR; } - diff --git a/fs/vfs/fs_lseek.c b/fs/vfs/fs_lseek.c index 7136d2ce11..be74239eca 100644 --- a/fs/vfs/fs_lseek.c +++ b/fs/vfs/fs_lseek.c @@ -75,7 +75,7 @@ off_t file_seek(FAR struct file *filep, off_t offset, int whence) { FAR struct inode *inode; int ret; - int err = OK; + int errcode = OK; DEBUGASSERT(filep); 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); if (ret < 0) { - err = -ret; + errcode = -ret; goto errout; } } @@ -108,17 +108,17 @@ off_t file_seek(FAR struct file *filep, off_t offset, int whence) } else { - err = EINVAL; + errcode = EINVAL; goto errout; } break; case SEEK_END: - err = ENOSYS; + errcode = ENOSYS; goto errout; default: - err = EINVAL; + errcode = EINVAL; goto errout; } } @@ -126,7 +126,7 @@ off_t file_seek(FAR struct file *filep, off_t offset, int whence) return filep->f_pos; errout: - set_errno(err); + set_errno(errcode); return (off_t)ERROR; } diff --git a/fs/vfs/fs_poll.c b/fs/vfs/fs_poll.c index 2910b30551..b4163230fe 100644 --- a/fs/vfs/fs_poll.c +++ b/fs/vfs/fs_poll.c @@ -77,14 +77,14 @@ static int poll_semtake(FAR sem_t *sem) 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 * awakened by a signal. */ - DEBUGASSERT(err == EINTR); - return -err; + DEBUGASSERT(errcode == EINTR); + return -errcode; } return OK; @@ -329,7 +329,7 @@ int poll(FAR struct pollfd *fds, nfds_t nfds, int timeout) { sem_t sem; int count = 0; - int err; + int errcode; int ret; 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. */ - err = poll_teardown(fds, nfds, &count, ret); - if (err < 0 && ret >= 0) + errcode = poll_teardown(fds, nfds, &count, ret); + if (errcode < 0 && ret >= 0) { - ret = err; + ret = errcode; } } diff --git a/fs/vfs/fs_write.c b/fs/vfs/fs_write.c index b7f71a2265..34b77e5a47 100644 --- a/fs/vfs/fs_write.c +++ b/fs/vfs/fs_write.c @@ -73,13 +73,13 @@ ssize_t file_write(FAR struct file *filep, FAR const void *buf, size_t nbytes) { FAR struct inode *inode; int ret; - int err; + int errcode; /* Was this file opened for write access? */ if ((filep->f_oflags & O_WROK) == 0) { - err = EBADF; + errcode = EBADF; 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; if (!inode || !inode->u.i_ops || !inode->u.i_ops->write) { - err = EBADF; + errcode = EBADF; 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); if (ret < 0) { - err = -ret; + errcode = -ret; goto errout; } return ret; errout: - set_errno(err); + set_errno(errcode); return ERROR; } diff --git a/include/pthread.h b/include/pthread.h index b2ebffda45..64228154f7 100644 --- a/include/pthread.h +++ b/include/pthread.h @@ -138,7 +138,7 @@ /* Definitions to map some non-standard, BSD thread management interfaces to * 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 - * 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) \ diff --git a/libc/stdio/lib_fclose.c b/libc/stdio/lib_fclose.c index 35301fc6bb..9700b2854f 100644 --- a/libc/stdio/lib_fclose.c +++ b/libc/stdio/lib_fclose.c @@ -69,7 +69,7 @@ int fclose(FAR FILE *stream) { - int err = EINVAL; + int errcode = EINVAL; int ret = ERROR; int status; @@ -89,7 +89,7 @@ int fclose(FAR FILE *stream) if ((stream->fs_oflags & O_WROK) != 0) { ret = lib_fflush(stream, true); - err = errno; + errcode = errno; } /* Close the underlying file descriptor and save the return status */ @@ -103,7 +103,7 @@ int fclose(FAR FILE *stream) if (ret == OK) { ret = status; - err = errno; + errcode = errno; } } @@ -143,7 +143,7 @@ int fclose(FAR FILE *stream) if (ret != OK) { - set_errno(err); + set_errno(errcode); return EOF; } diff --git a/libc/unistd/lib_chdir.c b/libc/unistd/lib_chdir.c index 4780a6b72e..16786a0f31 100644 --- a/libc/unistd/lib_chdir.c +++ b/libc/unistd/lib_chdir.c @@ -119,14 +119,14 @@ int chdir(FAR const char *path) struct stat buf; char *oldpwd; char *alloc; - int err; + int errcode; int ret; /* Verify the input parameters */ if (!path) { - err = ENOENT; + errcode = ENOENT; goto errout; } @@ -135,7 +135,7 @@ int chdir(FAR const char *path) ret = stat(path, &buf); if (ret != 0) { - err = ENOENT; + errcode = ENOENT; goto errout; } @@ -143,7 +143,7 @@ int chdir(FAR const char *path) if (!S_ISDIR(buf.st_mode)) { - err = ENOTDIR; + errcode = ENOTDIR; goto errout; } @@ -173,7 +173,7 @@ int chdir(FAR const char *path) return OK; errout: - set_errno(err); + set_errno(errcode); return ERROR; } #endif /* CONFIG_NFILE_DESCRIPTORS && !CONFIG_DISABLE_ENVIRON */ diff --git a/mm/mm_heap/mm_sbrk.c b/mm/mm_heap/mm_sbrk.c index 774d5d3f11..ddbf288d06 100644 --- a/mm/mm_heap/mm_sbrk.c +++ b/mm/mm_heap/mm_sbrk.c @@ -94,12 +94,12 @@ FAR void *mm_sbrk(FAR struct mm_heap_s *heap, intptr_t incr, uintptr_t allocbase; unsigned int pgincr; size_t bytesize; - int err; + int errcode; DEBUGASSERT(incr >= 0); if (incr < 0) { - err = ENOSYS; + errcode = ENOSYS; 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))) { - err = ENOMEM; + errcode = ENOMEM; goto errout; } @@ -132,7 +132,7 @@ FAR void *mm_sbrk(FAR struct mm_heap_s *heap, intptr_t incr, allocbase = pgalloc(brkaddr, pgincr); if (allocbase == 0) { - err = EAGAIN; + errcode = EAGAIN; goto errout; } @@ -158,7 +158,7 @@ FAR void *mm_sbrk(FAR struct mm_heap_s *heap, intptr_t incr, return (FAR void *)brkaddr; errout: - set_errno(err); + set_errno(errcode); return (FAR void *)-1; } #endif /* CONFIG_BUILD_KERNEL */ diff --git a/net/pkt/pkt_send.c b/net/pkt/pkt_send.c index 70c2a5e2f6..164f187ebc 100644 --- a/net/pkt/pkt_send.c +++ b/net/pkt/pkt_send.c @@ -212,14 +212,14 @@ ssize_t psock_pkt_send(FAR struct socket *psock, FAR const void *buf, FAR struct net_driver_s *dev; struct send_s state; net_lock_t save; - int err; + int errcode; int ret = OK; /* Verify that the sockfd corresponds to valid, allocated socket */ if (!psock || psock->s_crefs <= 0) { - err = EBADF; + errcode = EBADF; 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); if (dev == NULL) { - err = ENODEV; + errcode = ENODEV; goto errout; } @@ -296,7 +296,7 @@ ssize_t psock_pkt_send(FAR struct socket *psock, FAR const void *buf, if (state.snd_sent < 0) { - err = state.snd_sent; + errcode = state.snd_sent; goto errout; } @@ -306,7 +306,7 @@ ssize_t psock_pkt_send(FAR struct socket *psock, FAR const void *buf, if (ret < 0) { - err = -ret; + errcode = -ret; goto errout; } @@ -315,7 +315,7 @@ ssize_t psock_pkt_send(FAR struct socket *psock, FAR const void *buf, return state.snd_sent; errout: - set_errno(err); + set_errno(errcode); return ERROR; } diff --git a/net/socket/accept.c b/net/socket/accept.c index 11c2301ba8..59fa329bd8 100644 --- a/net/socket/accept.c +++ b/net/socket/accept.c @@ -127,7 +127,7 @@ int psock_accept(FAR struct socket *psock, FAR struct sockaddr *addr, FAR socklen_t *addrlen, FAR struct socket *newsock) { - int err; + int errcode; int ret; DEBUGASSERT(psock != NULL); @@ -136,7 +136,7 @@ int psock_accept(FAR struct socket *psock, FAR struct sockaddr *addr, if (psock->s_type != SOCK_STREAM) { - err = EOPNOTSUPP; + errcode = EOPNOTSUPP; goto errout; } @@ -144,7 +144,7 @@ int psock_accept(FAR struct socket *psock, FAR struct sockaddr *addr, if (!_SS_ISLISTENING(psock->s_flags)) { - err = EINVAL; + errcode = EINVAL; goto errout; } @@ -167,7 +167,7 @@ int psock_accept(FAR struct socket *psock, FAR struct sockaddr *addr, { if (*addrlen < sizeof(struct sockaddr_in)) { - err = EBADF; + errcode = EBADF; goto errout; } } @@ -179,7 +179,7 @@ int psock_accept(FAR struct socket *psock, FAR struct sockaddr *addr, { if (*addrlen < sizeof(struct sockaddr_in6)) { - err = EBADF; + errcode = EBADF; goto errout; } } @@ -191,7 +191,7 @@ int psock_accept(FAR struct socket *psock, FAR struct sockaddr *addr, { if (*addrlen < sizeof(sa_family_t)) { - err = EBADF; + errcode = EBADF; goto errout; } } @@ -200,7 +200,7 @@ int psock_accept(FAR struct socket *psock, FAR struct sockaddr *addr, default: DEBUGPANIC(); - err = EINVAL; + errcode = EINVAL; 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); if (ret < 0) { - err = -ret; + errcode = -ret; goto errout; } } @@ -242,7 +242,7 @@ int psock_accept(FAR struct socket *psock, FAR struct sockaddr *addr, if (ret < 0) { net_unlock(state); - err = -ret; + errcode = -ret; goto errout; } @@ -259,7 +259,7 @@ int psock_accept(FAR struct socket *psock, FAR struct sockaddr *addr, */ net_unlock(state); - err = -ret; + errcode = -ret; goto errout_after_accept; } @@ -277,7 +277,7 @@ errout_after_accept: psock_close(newsock); errout: - set_errno(err); + set_errno(errcode); 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 *newsock; int newfd; - int err; + int errcode; int ret; /* 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 ((unsigned int)sockfd < CONFIG_NFILE_DESCRIPTORS) { - err = ENOTSOCK; + errcode = ENOTSOCK; } else #endif { - err = EBADF; + errcode = EBADF; } goto errout; @@ -387,14 +387,14 @@ int accept(int sockfd, FAR struct sockaddr *addr, FAR socklen_t *addrlen) newfd = sockfd_allocate(0); if (newfd < 0) { - err = ENFILE; + errcode = ENFILE; goto errout; } newsock = sockfd_socket(newfd); if (newsock == NULL) { - err = ENFILE; + errcode = ENFILE; goto errout_with_socket; } @@ -413,7 +413,7 @@ errout_with_socket: sockfd_release(newfd); errout: - set_errno(err); + set_errno(errcode); return ERROR; } diff --git a/net/socket/bind.c b/net/socket/bind.c index 8095c71807..4580b4943b 100644 --- a/net/socket/bind.c +++ b/net/socket/bind.c @@ -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; #endif socklen_t minlen; - int err; + int errcode; int ret = OK; /* Verify that the psock corresponds to valid, allocated socket */ if (!psock || psock->s_crefs <= 0) { - err = ENOTSOCK; + errcode = ENOTSOCK; goto errout; } @@ -197,14 +197,14 @@ int psock_bind(FAR struct socket *psock, const struct sockaddr *addr, default: ndbg("ERROR: Unrecognized address family: %d\n", addr->sa_family); - err = EAFNOSUPPORT; + errcode = EAFNOSUPPORT; goto errout; } if (addrlen < minlen) { ndbg("ERROR: Invalid address length: %d < %d\n", addrlen, minlen); - err = EBADF; + errcode = EBADF; 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 */ default: - err = EBADF; + errcode = EBADF; goto errout; } @@ -309,14 +309,14 @@ int psock_bind(FAR struct socket *psock, const struct sockaddr *addr, if (ret < 0) { - err = -ret; + errcode = -ret; goto errout; } return OK; errout: - set_errno(err); + set_errno(errcode); return ERROR; } diff --git a/net/socket/connect.c b/net/socket/connect.c index 8365a5b3d5..aa9903c4d7 100644 --- a/net/socket/connect.c +++ b/net/socket/connect.c @@ -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) int ret; #endif - int err; + int errcode; /* Verify that the psock corresponds to valid, allocated socket */ if (!psock || psock->s_crefs <= 0) { - err = EBADF; + errcode = EBADF; goto errout; } @@ -526,7 +526,7 @@ int psock_connect(FAR struct socket *psock, FAR const struct sockaddr *addr, { if (addrlen < sizeof(struct sockaddr_in)) { - err = EBADF; + errcode = EBADF; goto errout; } } @@ -538,7 +538,7 @@ int psock_connect(FAR struct socket *psock, FAR const struct sockaddr *addr, { if (addrlen < sizeof(struct sockaddr_in6)) { - err = EBADF; + errcode = EBADF; goto errout; } } @@ -550,7 +550,7 @@ int psock_connect(FAR struct socket *psock, FAR const struct sockaddr *addr, { if (addrlen < sizeof(sa_family_t)) { - err = EBADF; + errcode = EBADF; goto errout; } } @@ -559,7 +559,7 @@ int psock_connect(FAR struct socket *psock, FAR const struct sockaddr *addr, default: DEBUGPANIC(); - err = EAFNOSUPPORT; + errcode = EAFNOSUPPORT; goto errout; } @@ -574,7 +574,7 @@ int psock_connect(FAR struct socket *psock, FAR const struct sockaddr *addr, if (_SS_ISCONNECTED(psock->s_flags)) { - err = EISCONN; + errcode = EISCONN; goto errout; } @@ -604,7 +604,7 @@ int psock_connect(FAR struct socket *psock, FAR const struct sockaddr *addr, if (ret < 0) { - err = -ret; + errcode = -ret; goto errout; } } @@ -644,7 +644,7 @@ int psock_connect(FAR struct socket *psock, FAR const struct sockaddr *addr, if (ret < 0) { - err = -ret; + errcode = -ret; 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 */ default: - err = EBADF; + errcode = EBADF; goto errout; } return OK; errout: - set_errno(err); + set_errno(errcode); return ERROR; } diff --git a/net/socket/getsockname.c b/net/socket/getsockname.c index 09c8fa0e65..3b895525ef 100644 --- a/net/socket/getsockname.c +++ b/net/socket/getsockname.c @@ -351,13 +351,13 @@ int getsockname(int sockfd, FAR struct sockaddr *addr, FAR socklen_t *addrlen) { FAR struct socket *psock = sockfd_socket(sockfd); int ret; - int err; + int errcode; /* Verify that the sockfd corresponds to valid, allocated socket */ if (!psock || psock->s_crefs <= 0) { - err = EBADF; + errcode = EBADF; goto errout; } @@ -368,7 +368,7 @@ int getsockname(int sockfd, FAR struct sockaddr *addr, FAR socklen_t *addrlen) #ifdef CONFIG_DEBUG_FEATURES if (!addr || !addrlen) { - err = EINVAL; + errcode = EINVAL; goto errout; } #endif @@ -391,7 +391,7 @@ int getsockname(int sockfd, FAR struct sockaddr *addr, FAR socklen_t *addrlen) case PF_PACKET: default: - err = EAFNOSUPPORT; + errcode = EAFNOSUPPORT; goto errout; } @@ -399,14 +399,14 @@ int getsockname(int sockfd, FAR struct sockaddr *addr, FAR socklen_t *addrlen) if (ret < 0) { - err = -ret; + errcode = -ret; goto errout; } return OK; errout: - set_errno(err); + set_errno(errcode); return ERROR; } diff --git a/net/socket/getsockopt.c b/net/socket/getsockopt.c index c2236e7591..5072f02067 100644 --- a/net/socket/getsockopt.c +++ b/net/socket/getsockopt.c @@ -96,13 +96,13 @@ int psock_getsockopt(FAR struct socket *psock, int level, int option, FAR void *value, FAR socklen_t *value_len) { - int err; + int errcode; /* Verify that the socket option if valid (but might not be supported ) */ if (!_SO_GETVALID(option) || !value || !value_len) { - err = EINVAL; + errcode = EINVAL; goto errout; } @@ -131,7 +131,7 @@ int psock_getsockopt(FAR struct socket *psock, int level, int option, if (*value_len < sizeof(int)) { - err = EINVAL; + errcode = EINVAL; goto errout; } @@ -155,7 +155,7 @@ int psock_getsockopt(FAR struct socket *psock, int level, int option, if (*value_len < sizeof(int)) { - err = EINVAL; + errcode = EINVAL; goto errout; } @@ -179,7 +179,7 @@ int psock_getsockopt(FAR struct socket *psock, int level, int option, if (*value_len < sizeof(struct timeval)) { - err = EINVAL; + errcode = EINVAL; 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 */ default: - err = ENOPROTOOPT; + errcode = ENOPROTOOPT; goto errout; } return OK; errout: - set_errno(err); + set_errno(errcode); return ERROR; } diff --git a/net/socket/listen.c b/net/socket/listen.c index c552d79402..0d91ccb586 100644 --- a/net/socket/listen.c +++ b/net/socket/listen.c @@ -84,7 +84,7 @@ int psock_listen(FAR struct socket *psock, int backlog) { - int err; + int errcode; 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) { - err = EOPNOTSUPP; + errcode = EOPNOTSUPP; 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 *)psock->s_conn; - err = local_listen(conn, backlog); - if (err < 0) + errcode = local_listen(conn, backlog); + if (errcode < 0) { - err = -err; + errcode = -errcode; goto errout; } } @@ -123,17 +123,17 @@ int psock_listen(FAR struct socket *psock, int backlog) if (conn->lport <= 0) { - err = EOPNOTSUPP; + errcode = EOPNOTSUPP; goto errout; } /* Set up the backlog for this connection */ #ifdef CONFIG_NET_TCPBACKLOG - err = tcp_backlogcreate(conn, backlog); - if (err < 0) + errcode = tcp_backlogcreate(conn, backlog); + if (errcode < 0) { - err = -err; + errcode = -errcode; goto errout; } #endif @@ -150,7 +150,7 @@ int psock_listen(FAR struct socket *psock, int backlog) return OK; errout: - set_errno(err); + set_errno(errcode); return ERROR; } @@ -190,7 +190,7 @@ errout: int listen(int sockfd, int backlog) { FAR struct socket *psock = sockfd_socket(sockfd); - int err; + int errcode; /* 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 ((unsigned int)sockfd < CONFIG_NFILE_DESCRIPTORS) { - err = ENOTSOCK; + errcode = ENOTSOCK; } else #endif { - err = EBADF; + errcode = EBADF; } - set_errno(err); + set_errno(errcode); return ERROR; } diff --git a/net/socket/net_close.c b/net/socket/net_close.c index 75ddb23b53..f400e21e4e 100644 --- a/net/socket/net_close.c +++ b/net/socket/net_close.c @@ -507,13 +507,13 @@ static void local_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 */ if (!psock || psock->s_crefs <= 0) { - err = EBADF; + errcode = EBADF; goto errout; } @@ -565,8 +565,8 @@ int psock_close(FAR struct socket *psock) /* Break any current connections */ - err = netclose_disconnect(psock); - if (err < 0) + errcode = netclose_disconnect(psock); + if (errcode < 0) { /* This would normally occur only if there is a * timeout from a lingering close. @@ -662,7 +662,7 @@ int psock_close(FAR struct socket *psock) #endif default: - err = EBADF; + errcode = EBADF; goto errout; } } @@ -678,7 +678,7 @@ errout_with_psock: #endif errout: - set_errno(err); + set_errno(errcode); return ERROR; } diff --git a/net/socket/net_dupsd.c b/net/socket/net_dupsd.c index 85d9b6f935..b5696871d2 100644 --- a/net/socket/net_dupsd.c +++ b/net/socket/net_dupsd.c @@ -68,7 +68,7 @@ int net_dupsd(int sockfd, int minsd) FAR struct socket *psock1; FAR struct socket *psock2; int sockfd2; - int err; + int errcode; int ret; /* 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) { - err = EBADF; + errcode = EBADF; goto errout; } @@ -108,7 +108,7 @@ int net_dupsd(int sockfd, int minsd) sockfd2 = sockfd_allocate(minsd); if (sockfd2 < 0) { - err = ENFILE; + errcode = ENFILE; goto errout; } @@ -117,7 +117,7 @@ int net_dupsd(int sockfd, int minsd) psock2 = sockfd_socket(sockfd2); if (!psock2) { - err = ENOSYS; /* should not happen */ + errcode = ENOSYS; /* should not happen */ goto errout; } @@ -126,7 +126,7 @@ int net_dupsd(int sockfd, int minsd) ret = net_clone(psock1, psock2); if (ret < 0) { - err = -ret; + errcode = -ret; goto errout; } @@ -136,10 +136,8 @@ int net_dupsd(int sockfd, int minsd) errout: sched_unlock(); - set_errno(err); + set_errno(errcode); return ERROR; } #endif /* defined(CONFIG_NET) && CONFIG_NSOCKET_DESCRIPTORS > 0 */ - - diff --git a/net/socket/net_dupsd2.c b/net/socket/net_dupsd2.c index 96c3d18315..7aa2634e21 100644 --- a/net/socket/net_dupsd2.c +++ b/net/socket/net_dupsd2.c @@ -71,7 +71,7 @@ int dup2(int sockfd1, int sockfd2) { FAR struct socket *psock1; FAR struct socket *psock2; - int err; + int errcode; int ret; /* Lock the scheduler throughout the following */ @@ -89,7 +89,7 @@ int dup2(int sockfd1, int sockfd2) if (!psock1 || !psock2 || psock1->s_crefs <= 0) { - err = EBADF; + errcode = EBADF; goto errout; } @@ -107,7 +107,7 @@ int dup2(int sockfd1, int sockfd2) ret = net_clone(psock1, psock2); if (ret < 0) { - err = -ret; + errcode = -ret; goto errout; } @@ -116,10 +116,8 @@ int dup2(int sockfd1, int sockfd2) errout: sched_unlock(); - set_errno(err); + set_errno(errcode); return ERROR; } #endif /* CONFIG_NET && CONFIG_NSOCKET_DESCRIPTORS > 0 */ - - diff --git a/net/socket/net_sendfile.c b/net/socket/net_sendfile.c index 0ab962d762..53a76349ad 100644 --- a/net/socket/net_sendfile.c +++ b/net/socket/net_sendfile.c @@ -604,14 +604,14 @@ ssize_t net_sendfile(int outfd, struct file *infile, off_t *offset, FAR struct tcp_conn_s *conn; struct sendfile_s state; net_lock_t save; - int err; + int errcode; /* Verify that the sockfd corresponds to valid, allocated socket */ if (!psock || psock->s_crefs <= 0) { ndbg("ERROR: Invalid socket\n"); - err = EBADF; + errcode = EBADF; 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)) { ndbg("ERROR: Not connected\n"); - err = ENOTCONN; + errcode = ENOTCONN; goto errout; } @@ -658,7 +658,7 @@ ssize_t net_sendfile(int outfd, struct file *infile, off_t *offset, if (ret < 0) { ndbg("ERROR: Not reachable\n"); - err = ENETUNREACH; + errcode = ENETUNREACH; goto errout; } #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) { nlldbg("Failed to allocate data callback\n"); - err = ENOMEM; + errcode = ENOMEM; goto errout_locked; } @@ -697,7 +697,7 @@ ssize_t net_sendfile(int outfd, struct file *infile, off_t *offset, if (state.snd_ackcb == NULL) { nlldbg("Failed to allocate ack callback\n"); - err = ENOMEM; + errcode = ENOMEM; goto errout_datacb; } @@ -754,9 +754,9 @@ errout_locked: errout: - if (err) + if (errcode) { - set_errno(err); + set_errno(errcode); return ERROR; } else if (state.snd_sent < 0) diff --git a/net/socket/net_vfcntl.c b/net/socket/net_vfcntl.c index a58756cb8e..a1cb386e76 100644 --- a/net/socket/net_vfcntl.c +++ b/net/socket/net_vfcntl.c @@ -77,7 +77,7 @@ int net_vfcntl(int sockfd, int cmd, va_list ap) { FAR struct socket *psock = sockfd_socket(sockfd); net_lock_t flags; - int err = 0; + int errcode = 0; int ret = 0; 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) { - err = EBADF; + errcode = EBADF; goto errout; } @@ -126,7 +126,7 @@ int net_vfcntl(int sockfd, int cmd, va_list ap) * 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; case F_GETFL: @@ -263,20 +263,20 @@ int net_vfcntl(int sockfd, int cmd, va_list ap) * 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; default: - err = EINVAL; + errcode = EINVAL; break; } net_unlock(flags); errout: - if (err != 0) + if (errcode != 0) { - set_errno(err); + set_errno(errcode); return ERROR; } diff --git a/net/socket/recvfrom.c b/net/socket/recvfrom.c index d095e19ad8..50b45bee9f 100644 --- a/net/socket/recvfrom.c +++ b/net/socket/recvfrom.c @@ -1844,21 +1844,21 @@ ssize_t psock_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len, FAR socklen_t *fromlen) { ssize_t ret; - int err; + int errcode; /* Verify that non-NULL pointers were passed */ #ifdef CONFIG_DEBUG_FEATURES if (!buf) { - err = EINVAL; + errcode = EINVAL; goto errout; } #endif if (from && !fromlen) { - err = EINVAL; + errcode = EINVAL; 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) { - err = EBADF; + errcode = EBADF; goto errout; } @@ -1908,13 +1908,13 @@ ssize_t psock_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len, default: DEBUGPANIC(); - err = EINVAL; + errcode = EINVAL; goto errout; } if (*fromlen < minlen) { - err = EINVAL; + errcode = EINVAL; goto errout; } } @@ -2002,7 +2002,7 @@ ssize_t psock_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len, if (ret < 0) { - err = -ret; + errcode = -ret; goto errout; } @@ -2011,7 +2011,7 @@ ssize_t psock_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len, return ret; errout: - set_errno(err); + set_errno(errcode); return ERROR; } diff --git a/net/socket/sendto.c b/net/socket/sendto.c index 193e3ae4fe..31a33f4142 100644 --- a/net/socket/sendto.c +++ b/net/socket/sendto.c @@ -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) ssize_t nsent; #endif - int err; + int errcode; /* If to is NULL or tolen is zero, then this function is same as send (for * 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); #else ndbg("ERROR: No 'to' address\n"); - err = EINVAL; + errcode = EINVAL; goto errout; #endif } @@ -169,14 +169,14 @@ ssize_t psock_sendto(FAR struct socket *psock, FAR const void *buf, default: ndbg("ERROR: Unrecognized address family: %d\n", to->sa_family); - err = EAFNOSUPPORT; + errcode = EAFNOSUPPORT; goto errout; } if (tolen < minlen) { ndbg("ERROR: Invalid address length: %d < %d\n", tolen, minlen); - err = EBADF; + errcode = EBADF; goto errout; } @@ -185,7 +185,7 @@ ssize_t psock_sendto(FAR struct socket *psock, FAR const void *buf, if (!psock || psock->s_crefs <= 0) { ndbg("ERROR: Invalid socket\n"); - err = EBADF; + errcode = EBADF; goto errout; } @@ -194,7 +194,7 @@ ssize_t psock_sendto(FAR struct socket *psock, FAR const void *buf, if (psock->s_type != SOCK_DGRAM) { ndbg("ERROR: Connected socket\n"); - err = EISCONN; + errcode = EISCONN; goto errout; } @@ -226,17 +226,17 @@ ssize_t psock_sendto(FAR struct socket *psock, FAR const void *buf, if (nsent < 0) { ndbg("ERROR: UDP or Unix domain sendto() failed: %ld\n", (long)nsent); - err = -nsent; + errcode = -nsent; goto errout; } return nsent; #else - err = ENOSYS; + errcode = ENOSYS; #endif /* CONFIG_NET_UDP || CONFIG_NET_LOCAL_DGRAM */ errout: - set_errno(err); + set_errno(errcode); return ERROR; } diff --git a/net/socket/setsockopt.c b/net/socket/setsockopt.c index 99ec9378ed..2086771b37 100644 --- a/net/socket/setsockopt.c +++ b/net/socket/setsockopt.c @@ -106,13 +106,13 @@ int psock_setsockopt(FAR struct socket *psock, int level, int option, FAR const void *value, socklen_t value_len) { net_lock_t flags; - int err; + int errcode; /* Verify that the socket option if valid (but might not be supported ) */ if (!_SO_SETVALID(option) || !value) { - err = EINVAL; + errcode = EINVAL; goto errout; } @@ -141,7 +141,7 @@ int psock_setsockopt(FAR struct socket *psock, int level, int option, if (value_len != sizeof(int)) { - err = EINVAL; + errcode = EINVAL; 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)) { - err = EINVAL; + errcode = EINVAL; goto errout; } @@ -223,7 +223,7 @@ int psock_setsockopt(FAR struct socket *psock, int level, int option, if (value_len < sizeof(FAR struct linger)) { - err = EINVAL; + errcode = EINVAL; goto errout; } @@ -268,14 +268,14 @@ int psock_setsockopt(FAR struct socket *psock, int level, int option, case SO_TYPE: /* Reports the socket type */ default: - err = ENOPROTOOPT; + errcode = ENOPROTOOPT; goto errout; } return OK; errout: - set_errno(err); + set_errno(errcode); return ERROR; } diff --git a/net/socket/socket.c b/net/socket/socket.c index 93fd41a278..56f6ddfe9c 100644 --- a/net/socket/socket.c +++ b/net/socket/socket.c @@ -248,7 +248,7 @@ int psock_socket(int domain, int type, int protocol, FAR struct socket *psock) #endif bool dgramok = false; int ret; - int err; + int errcode; /* 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 default: - err = EAFNOSUPPORT; + errcode = EAFNOSUPPORT; 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) { - err = EPROTONOSUPPORT; + errcode = EPROTONOSUPPORT; goto errout; } } @@ -318,7 +318,7 @@ int psock_socket(int domain, int type, int protocol, FAR struct socket *psock) { if (protocol != 0 || !dgramok) { - err = EPROTONOSUPPORT; + errcode = EPROTONOSUPPORT; 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) { - err = EPROTONOSUPPORT; + errcode = EPROTONOSUPPORT; goto errout; } } @@ -349,7 +349,7 @@ int psock_socket(int domain, int type, int protocol, FAR struct socket *psock) { if (protocol != 0 || !dgramok) { - err = EPROTONOSUPPORT; + errcode = EPROTONOSUPPORT; goto errout; } } @@ -362,7 +362,7 @@ int psock_socket(int domain, int type, int protocol, FAR struct socket *psock) case SOCK_RAW: if (dgramok) { - err = EPROTONOSUPPORT; + errcode = EPROTONOSUPPORT; goto errout; } @@ -370,7 +370,7 @@ int psock_socket(int domain, int type, int protocol, FAR struct socket *psock) #endif default: - err = EPROTONOSUPPORT; + errcode = EPROTONOSUPPORT; 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. */ - err = ENOMEM; /* Assume failure to allocate connection instance */ + errcode = ENOMEM; /* Assume failure to allocate connection instance */ switch (type) { #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 */ - err = -ret; + errcode = -ret; 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 */ - err = -ret; + errcode = -ret; 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 */ - err = -ret; + errcode = -ret; goto errout; } } @@ -490,7 +490,7 @@ int psock_socket(int domain, int type, int protocol, FAR struct socket *psock) return OK; errout: - set_errno(err); + set_errno(errcode); return ERROR; } diff --git a/net/tcp/tcp_send_buffered.c b/net/tcp/tcp_send_buffered.c index b5c729def9..f5a70176f2 100644 --- a/net/tcp/tcp_send_buffered.c +++ b/net/tcp/tcp_send_buffered.c @@ -936,20 +936,20 @@ ssize_t psock_tcp_send(FAR struct socket *psock, FAR const void *buf, FAR struct tcp_wrbuffer_s *wrb; net_lock_t save; ssize_t result = 0; - int err; + int errcode; int ret = OK; if (!psock || psock->s_crefs <= 0) { ndbg("ERROR: Invalid socket\n"); - err = EBADF; + errcode = EBADF; goto errout; } if (psock->s_type != SOCK_STREAM || !_SS_ISCONNECTED(psock->s_flags)) { ndbg("ERROR: Not connected\n"); - err = ENOTCONN; + errcode = ENOTCONN; goto errout; } @@ -986,7 +986,7 @@ ssize_t psock_tcp_send(FAR struct socket *psock, FAR const void *buf, if (ret < 0) { ndbg("ERROR: Not reachable\n"); - err = ENETUNREACH; + errcode = ENETUNREACH; goto errout; } #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 */ ndbg("ERROR: Failed to allocate write buffer\n"); - err = ENOMEM; + errcode = ENOMEM; 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 */ ndbg("ERROR: Failed to allocate callback\n"); - err = ENOMEM; + errcode = ENOMEM; goto errout_with_wrb; } @@ -1076,7 +1076,7 @@ ssize_t psock_tcp_send(FAR struct socket *psock, FAR const void *buf, if (result < 0) { - err = result; + errcode = result; goto errout; } @@ -1086,7 +1086,7 @@ ssize_t psock_tcp_send(FAR struct socket *psock, FAR const void *buf, if (ret < 0) { - err = -ret; + errcode = -ret; goto errout; } @@ -1101,7 +1101,7 @@ errout_with_lock: net_unlock(save); errout: - set_errno(err); + set_errno(errcode); return ERROR; } diff --git a/net/tcp/tcp_send_unbuffered.c b/net/tcp/tcp_send_unbuffered.c index d043a46250..53b8941499 100644 --- a/net/tcp/tcp_send_unbuffered.c +++ b/net/tcp/tcp_send_unbuffered.c @@ -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; struct send_s state; net_lock_t save; - int err; + int errcode; int ret = OK; /* 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) { ndbg("ERROR: Invalid socket\n"); - err = EBADF; + errcode = EBADF; 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)) { ndbg("ERROR: Not connected\n"); - err = ENOTCONN; + errcode = ENOTCONN; goto errout; } @@ -774,7 +774,7 @@ ssize_t psock_tcp_send(FAR struct socket *psock, if (ret < 0) { ndbg("ERROR: Not reachable\n"); - err = ENETUNREACH; + errcode = ENETUNREACH; goto errout; } #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) { - err = state.snd_sent; + errcode = state.snd_sent; goto errout; } @@ -867,7 +867,7 @@ ssize_t psock_tcp_send(FAR struct socket *psock, if (ret < 0) { - err = -ret; + errcode = -ret; goto errout; } @@ -876,7 +876,7 @@ ssize_t psock_tcp_send(FAR struct socket *psock, return state.snd_sent; errout: - set_errno(err); + set_errno(errcode); return ERROR; } diff --git a/sched/sched/sched_waitid.c b/sched/sched/sched_waitid.c index ca24507279..003f8b597f 100644 --- a/sched/sched/sched_waitid.c +++ b/sched/sched/sched_waitid.c @@ -161,7 +161,7 @@ int waitid(idtype_t idtype, id_t id, FAR siginfo_t *info, int options) bool retains; #endif sigset_t set; - int err; + int errcode; int ret; /* 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 */ - err = ECHILD; + errcode = ECHILD; goto errout_with_errno; } 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) #endif { - err = ECHILD; + errcode = ECHILD; 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 */ - err = ECHILD; + errcode = ECHILD; 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 */ - err = ECHILD; + errcode = ECHILD; goto errout_with_errno; } 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) #endif { - err = ECHILD; + errcode = ECHILD; 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. */ - err = ECHILD; + errcode = ECHILD; 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. */ - err = ECHILD; + errcode = ECHILD; goto errout_with_errno; } #endif @@ -400,7 +400,7 @@ int waitid(idtype_t idtype, id_t id, FAR siginfo_t *info, int options) return OK; errout_with_errno: - set_errno(err); + set_errno(errcode); errout: sched_unlock(); return ERROR; diff --git a/sched/sched/sched_waitpid.c b/sched/sched/sched_waitpid.c index aa5f2dccc6..0e3902342b 100644 --- a/sched/sched/sched_waitpid.c +++ b/sched/sched/sched_waitpid.c @@ -180,7 +180,7 @@ pid_t waitpid(pid_t pid, int *stat_loc, int options) FAR struct tcb_s *ctcb; FAR struct task_group_s *group; bool mystat = false; - int err; + int errcode; int ret; DEBUGASSERT(stat_loc); @@ -204,7 +204,7 @@ pid_t waitpid(pid_t pid, int *stat_loc, int options) ctcb = sched_gettcb(pid); if (!ctcb) { - err = ECHILD; + errcode = ECHILD; goto errout_with_errno; } @@ -272,7 +272,7 @@ pid_t waitpid(pid_t pid, int *stat_loc, int options) return pid; errout_with_errno: - set_errno(err); + set_errno(errcode); errout: sched_unlock(); return ERROR; @@ -302,7 +302,7 @@ pid_t waitpid(pid_t pid, int *stat_loc, int options) #endif FAR struct siginfo info; sigset_t set; - int err; + int errcode; int ret; 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) { - err = ECHILD; + errcode = ECHILD; goto errout_with_errno; } 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) #endif { - err = ECHILD; + errcode = ECHILD; 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) { - err = ECHILD; + errcode = ECHILD; goto errout_with_errno; } } @@ -375,7 +375,7 @@ pid_t waitpid(pid_t pid, int *stat_loc, int options) { /* There are no children */ - err = ECHILD; + errcode = ECHILD; goto errout_with_errno; } 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) #endif { - err = ECHILD; + errcode = ECHILD; 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. */ - err = ECHILD; + errcode = ECHILD; 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. */ - err = ECHILD; + errcode = ECHILD; goto errout_with_errno; } @@ -526,7 +526,7 @@ pid_t waitpid(pid_t pid, int *stat_loc, int options) return (int)pid; errout_with_errno: - set_errno(err); + set_errno(errcode); errout_with_lock: sched_unlock(); diff --git a/sched/task/task_prctl.c b/sched/task/task_prctl.c index 1908872536..654ecba481 100644 --- a/sched/task/task_prctl.c +++ b/sched/task/task_prctl.c @@ -77,7 +77,7 @@ int prctl(int option, ...) { va_list ap; - int err; + int errcode; va_start(ap, option); switch (option) @@ -112,7 +112,7 @@ int prctl(int option, ...) if (!tcb) { sdbg("Pid does not correspond to a task: %d\n", pid); - err = ESRCH; + errcode = ESRCH; goto errout; } @@ -121,7 +121,7 @@ int prctl(int option, ...) if (!name) { sdbg("No name provide\n"); - err = EFAULT; + errcode = EFAULT; goto errout; } @@ -145,13 +145,13 @@ int prctl(int option, ...) break; #else sdbg("Option not enabled: %d\n", option); - err = ENOSYS; + errcode = ENOSYS; goto errout; #endif default: sdbg("Unrecognized option: %d\n", option); - err = EINVAL; + errcode = EINVAL; goto errout; } @@ -166,6 +166,6 @@ int prctl(int option, ...) errout: va_end(ap); - set_errno(err); + set_errno(errcode); return ERROR; } diff --git a/sched/task/task_restart.c b/sched/task/task_restart.c index 9090d789ca..5f3b76958f 100644 --- a/sched/task/task_restart.c +++ b/sched/task/task_restart.c @@ -83,7 +83,7 @@ int task_restart(pid_t pid) FAR struct task_tcb_s *tcb; FAR dq_queue_t *tasklist; irqstate_t flags; - int err; + int errcode; int status; /* 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 */ - err = ENOSYS; + errcode = ENOSYS; 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. */ - err = ESRCH; + errcode = ESRCH; goto errout_with_lock; } @@ -133,7 +133,7 @@ int task_restart(pid_t pid) { /* Not implemented */ - err = ENOSYS; + errcode = ENOSYS; goto errout_with_lock; } #endif /* CONFIG_SMP */ @@ -197,7 +197,7 @@ int task_restart(pid_t pid) if (status != OK) { (void)task_delete(pid); - err = -status; + errcode = -status; goto errout_with_lock; } @@ -205,7 +205,7 @@ int task_restart(pid_t pid) return OK; errout_with_lock: - set_errno(err); + set_errno(errcode); sched_unlock(); return ERROR; } diff --git a/tools/pic32mx/mkpichex.c b/tools/pic32mx/mkpichex.c index 48cb02805f..1562031bc8 100644 --- a/tools/pic32mx/mkpichex.c +++ b/tools/pic32mx/mkpichex.c @@ -239,7 +239,7 @@ int main(int argc, char **argv, char **envp) char *destfile; FILE *src; FILE *dest; - int err; + int errcode; if (argc != 2) { @@ -258,7 +258,7 @@ int main(int argc, char **argv, char **envp) if (!destfile) { fprintf(stderr, "getfilepath failed\n"); - err = 2; + errcode = 2; goto errout_with_srcfile; } @@ -266,7 +266,7 @@ int main(int argc, char **argv, char **envp) if (!src) { fprintf(stderr, "open %s failed: %s\n", srcfile, strerror(errno)); - err = 3; + errcode = 3; goto errout_with_destfile; } @@ -274,7 +274,7 @@ int main(int argc, char **argv, char **envp) if (!dest) { fprintf(stderr, "open %s failed: %s\n", destfile, strerror(errno)); - err = 3; + errcode = 3; goto errout_with_destfile; } @@ -285,7 +285,7 @@ int main(int argc, char **argv, char **envp) if (parse_line(&hexline)) { fprintf(stderr, "Failed to parse line\n"); - err = 1; + errcode = 1; goto errout_with_destfile; } @@ -325,5 +325,5 @@ errout_with_destfile: free(destfile); errout_with_srcfile: free(srcfile); - return err; + return errcode; }