Squashed commit of the following:

binfmt/, configs/, grahics/, libc/, mm/, net/, sched/:  OS references to the errno variable should always use the set_errno(), get_errno() macros
    arch/arm/src/stm32 and stm32f7:  Architecture-specific code is not permitted to modify the errno variable.  drivers/ and libc/:  OS references to the errno variable should always use the set_errno(), get_errno() macros
This commit is contained in:
Gregory Nutt 2018-01-30 17:57:36 -06:00
parent 30f2927101
commit 3521aaf944
28 changed files with 30 additions and 34 deletions

View File

@ -1069,7 +1069,6 @@ FAR struct comp_dev_s* stm32_compinitialize(int intf)
if (ret < 0)
{
aerr("ERROR: Failed to initialize COMP%d: %d\n", intf, ret);
errno = -ret;
return NULL;
}

View File

@ -5313,7 +5313,6 @@ FAR struct hrtim_dev_s* stm32_hrtiminitialize(void)
if (ret < 0)
{
tmrerr("ERROR: Failed to initialize HRTIM1: %d\n", ret);
errno = -ret;
return NULL;
}

View File

@ -1402,7 +1402,6 @@ FAR struct opamp_dev_s* stm32_opampinitialize(int intf)
if (ret < 0)
{
aerr("ERROR: Failed to initialize OPAMP%d: %d\n", intf, ret);
errno = -ret;
return NULL;
}

View File

@ -2261,7 +2261,6 @@ FAR struct dma2d_layer_s *stm32_dma2dinitltdc(FAR struct stm32_ltdc_s *layer)
{
lcderr("ERROR: Returning -EINVAL, unsupported pixel format: %d\n",
layer->vinfo.fmt);
errno = -EINVAL;
return NULL;
}

View File

@ -101,7 +101,7 @@ static inline int elf_filelen(FAR struct elf_loadinfo_s *loadinfo,
ret = stat(filename, &buf);
if (ret < 0)
{
int errval = errno;
int errval = get_errno();
berr("Failed to stat file: %d\n", errval);
return -errval;
}
@ -165,7 +165,7 @@ int elf_init(FAR const char *filename, FAR struct elf_loadinfo_s *loadinfo)
loadinfo->filfd = open(filename, O_RDONLY);
if (loadinfo->filfd < 0)
{
int errval = errno;
int errval = get_errno();
berr("Failed to open ELF binary %s: %d\n", filename, errval);
return -errval;
}

View File

@ -127,7 +127,7 @@ int elf_read(FAR struct elf_loadinfo_s *loadinfo, FAR uint8_t *buffer,
rpos = lseek(loadinfo->filfd, offset, SEEK_SET);
if (rpos != offset)
{
int errval = errno;
int errval = get_errno();
berr("Failed to seek to position %lu: %d\n",
(unsigned long)offset, errval);
return -errval;

View File

@ -111,7 +111,7 @@ int nxflat_init(const char *filename, struct nxflat_loadinfo_s *loadinfo)
loadinfo->filfd = open(filename, O_RDONLY);
if (loadinfo->filfd < 0)
{
int errval = errno;
int errval = get_errno();
berr("Failed to open NXFLAT binary %s: %d\n", filename, errval);
return -errval;
}

View File

@ -131,7 +131,7 @@ int nxflat_read(struct nxflat_loadinfo_s *loadinfo, char *buffer,
rpos = lseek(loadinfo->filfd, offset, SEEK_SET);
if (rpos != offset)
{
int errval = errno;
int errval = get_errno();
berr("Failed to seek to position %d: %d\n", offset, errval);
return -errval;
}

View File

@ -144,7 +144,7 @@ int at25_main(int argc, char *argv)
fd = open(g_at25dev, O_WRONLY);
if (fd < 0)
{
int errcode = errno;
int errcode = get_errno();
fprintf(stderr, "ERROR: Failed to open %s: %d\n", g_at25dev, errcode);
return EXIT_FAILURE;
}
@ -205,7 +205,7 @@ int at25_main(int argc, char *argv)
nwritten = write(fd, src, memoutstream.public.nput);
if (nwritten <= 0)
{
int errcode = errno;
int errcode = get_errno();
if (errno != EINTR)
{
fprintf(stderr, "ERROR: Write failed: %d\n", errcode);
@ -235,7 +235,7 @@ int at25_main(int argc, char *argv)
fd = open(g_at25dev, O_RDONLY);
if (fd < 0)
{
int errcode = errno;
int errcode = get_errno();
fprintf(stderr, "ERROR: Failed to open %s: %d\n", g_at25dev, errcode);
return EXIT_FAILURE;
}
@ -254,7 +254,7 @@ int at25_main(int argc, char *argv)
nread = read(fd, g_iobuffer, rdsize);
if (nread <= 0)
{
int errcode = errno;
int errcode = get_errno();
if (errno != EINTR)
{
fprintf(stderr, "ERROR: Read failed: %d\n", errcode);

View File

@ -863,7 +863,7 @@ static int telnet_session(FAR struct telnet_session_s *session)
priv->td_minor);
ret = stat(session->ts_devpath, &statbuf);
DEBUGASSERT(ret >= 0 || errno == ENOENT);
DEBUGASSERT(ret >= 0 || get_errno() == ENOENT);
}
while (ret >= 0 && start != g_telnet_common.tc_minor);

View File

@ -190,7 +190,7 @@ int nx_start(void)
CONFIG_NXSTART_SERVERSTACK, nx_server, NULL);
if (server < 0)
{
int errcode = errno;
int errcode = get_errno();
DEBUGASSERT(errcode > 0);
gerr("ERROR: Failed to create nx_server kernel thread: %d\n", errcode);

View File

@ -98,7 +98,7 @@ static inline int modlib_filelen(FAR struct mod_loadinfo_s *loadinfo,
ret = stat(filename, &buf);
if (ret < 0)
{
int errval = errno;
int errval = get_errno();
serr("ERROR: Failed to stat file: %d\n", errval);
return -errval;
}
@ -163,7 +163,7 @@ int modlib_initialize(FAR const char *filename,
loadinfo->filfd = open(filename, O_RDONLY);
if (loadinfo->filfd < 0)
{
int errval = errno;
int errval = get_errno();
serr("ERROR: Failed to open ELF binary %s: %d\n", filename, errval);
return -errval;
}

View File

@ -121,7 +121,7 @@ int modlib_read(FAR struct mod_loadinfo_s *loadinfo, FAR uint8_t *buffer,
rpos = lseek(loadinfo->filfd, offset, SEEK_SET);
if (rpos != offset)
{
int errval = errno;
int errval = get_errno();
serr("ERROR: Failed to seek to position %lu: %d\n",
(unsigned long)offset, errval);
return -errval;

View File

@ -90,7 +90,7 @@ int dns_add_nameserver(FAR const struct sockaddr *addr, socklen_t addrlen)
stream = fopen(CONFIG_NETDB_RESOLVCONF_PATH, "at");
if (stream == NULL)
{
int errcode = errno;
int errcode = get_errno();
nerr("ERROR: Failed to open %s: %d\n",
CONFIG_NETDB_RESOLVCONF_PATH, errcode);
DEBUGASSERT(errcode > 0);

View File

@ -104,7 +104,7 @@ int dns_foreach_nameserver(dns_callback_t callback, FAR void *arg)
stream = fopen(CONFIG_NETDB_RESOLVCONF_PATH, "rb");
if (stream == NULL)
{
int errcode = errno;
int errcode = get_errno();
nerr("ERROR: Failed to open %s: %d\n",
CONFIG_NETDB_RESOLVCONF_PATH, errcode);
DEBUGASSERT(errcode > 0);

View File

@ -263,7 +263,7 @@ int lib_hostfile_lookup(FAR const void *addr, socklen_t len, int type,
stream = fopen(CONFIG_NETDB_HOSTCONF_PATH, "r");
if (stream == NULL)
{
int errcode = errno;
int errcode = get_errno();
nerr("ERROR: Failed to open the hosts file %s: %d\n",
CONFIG_NETDB_HOSTCONF_PATH, errcode);

View File

@ -597,7 +597,7 @@ static int lib_hostfile_lookup(FAR const char *name, FAR struct hostent *host,
stream = fopen(CONFIG_NETDB_HOSTCONF_PATH, "r");
if (stream == NULL)
{
int errcode = errno;
int errcode = get_errno();
nerr("ERROR: Failed to open the hosts file %s: %d\n",
CONFIG_NETDB_HOSTCONF_PATH, errcode);

View File

@ -85,7 +85,7 @@ int pthread_setcancelstate(int state, FAR int *oldstate)
ret = task_setcancelstate(state, oldstate);
if (ret < 0)
{
ret = errno;
ret = get_errno();
}
return ret;

View File

@ -85,7 +85,7 @@ int pthread_setcanceltype(int type, FAR int *oldtype)
ret = task_setcanceltype(type, oldtype);
if (ret < 0)
{
ret = errno;
ret = get_errno();
}
return ret;

View File

@ -89,7 +89,7 @@ int fclose(FAR FILE *stream)
if ((stream->fs_oflags & O_WROK) != 0)
{
ret = lib_fflush(stream, true);
errcode = errno;
errcode = get_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;
errcode = errno;
errcode = get_errno();
}
}

View File

@ -66,7 +66,7 @@ int wctomb(FAR char *s, wchar_t wc)
if ((size_t) wc >= 0x100)
{
errno = EILSEQ;
set_errno(EILSEQ);
return -1;
}

View File

@ -2374,7 +2374,7 @@ static time_t time1(FAR struct tm *const tmp,
if (tmp == NULL)
{
errno = EINVAL;
set_errno(EINVAL);
return -1;
}

View File

@ -98,7 +98,7 @@ int work_signal(int qid)
ret = kill(g_usrwork.pid, SIGWORK);
if (ret < 0)
{
int errcode = errno;
int errcode = get_errno();
ret = -errcode;
}
}

View File

@ -360,7 +360,7 @@ int work_usrstart(void)
DEBUGASSERT(g_usrwork.pid > 0);
if (g_usrwork.pid < 0)
{
int errcode = errno;
int errcode = get_errno();
DEBUGASSERT(errcode > 0);
return -errcode;
}

View File

@ -200,7 +200,7 @@ void mm_takesemaphore(FAR struct mm_heap_s *heap)
#if defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__)
DEBUGASSERT(ret == -EINTR);
#else
int errcode = errno;
int errcode = get_errno();
DEBUGASSERT(errcode == EINTR);
ret = -errcode;
#endif

View File

@ -170,7 +170,7 @@ int net_routesize(FAR const char *path, size_t entrysize)
* created yet?
*/
errcode = errno;
errcode = get_errno();
if (errcode == ENOENT)
{
/* The routing table file has not been created. Return size zero. */

View File

@ -162,7 +162,7 @@ int work_hpstart(void)
DEBUGASSERT(pid > 0);
if (pid < 0)
{
int errcode = errno;
int errcode = get_errno();
DEBUGASSERT(errcode > 0);
serr("ERROR: kthread_create failed: %d\n", errcode);

View File

@ -209,7 +209,7 @@ int work_lpstart(void)
DEBUGASSERT(pid > 0);
if (pid < 0)
{
int errcode = errno;
int errcode = get_errno();
DEBUGASSERT(errcode > 0);
serr("ERROR: kthread_create %d failed: %d\n", wndx, errcode);