Fix wait loop and void cast (#24)

* Simplify EINTR/ECANCEL error handling

1. Add semaphore uninterruptible wait function
2 .Replace semaphore wait loop with a single uninterruptible wait
3. Replace all sem_xxx to nxsem_xxx

* Unify the void cast usage

1. Remove void cast for function because many place ignore the returned value witout cast
2. Replace void cast for variable with UNUSED macro
This commit is contained in:
Xiang Xiao
2020-01-02 10:49:34 -06:00
committed by Gregory Nutt
parent 316675f4db
commit 6a3c2aded6
1602 changed files with 6311 additions and 10874 deletions
+1 -1
View File
@@ -86,7 +86,7 @@ int close(int fd)
/* close() is a cancellation point */
(void)enter_cancellation_point();
enter_cancellation_point();
/* Did we get a valid file descriptor? */
+1 -1
View File
@@ -285,7 +285,7 @@ int fcntl(int fd, int cmd, ...)
/* fcntl() is a cancellation point */
(void)enter_cancellation_point();
enter_cancellation_point();
/* Setup to access the variable argument list */
+1 -1
View File
@@ -222,7 +222,7 @@ FAR struct file_struct *fs_fdopen(int fd, int oflags, FAR struct tcb_s *tcb)
#ifndef CONFIG_STDIO_DISABLE_BUFFERING
/* Initialize the semaphore the manages access to the buffer */
(void)nxsem_init(&stream->fs_sem, 0, 1);
nxsem_init(&stream->fs_sem, 0, 1);
#if CONFIG_STDIO_BUFFER_SIZE > 0
/* Allocate the IO buffer at the appropriate privilege level for
+1 -1
View File
@@ -110,7 +110,7 @@ int fsync(int fd)
/* fsync() is a cancellation point */
(void)enter_cancellation_point();
enter_cancellation_point();
/* Get the file structure corresponding to the file descriptor. */
+1 -1
View File
@@ -339,7 +339,7 @@ int open(FAR const char *path, int oflags, ...)
/* open() is a cancellation point */
(void)enter_cancellation_point();
enter_cancellation_point();
/* Let nx_vopen() do most of the work */
+5 -16
View File
@@ -72,18 +72,7 @@
static int poll_semtake(FAR sem_t *sem)
{
int ret;
/* Take the semaphore (perhaps waiting) */
ret = nxsem_wait(sem);
/* The only case that an error should occur here is if the wait were
* awakened by a signal.
*/
DEBUGASSERT(ret == OK || ret == -EINTR);
return ret;
return nxsem_wait(sem);
}
/****************************************************************************
@@ -204,16 +193,16 @@ static inline int poll_setup(FAR struct pollfd *fds, nfds_t nfds,
switch (fds[j].events & POLLMASK)
{
case POLLFD:
(void)poll_fdsetup(fds[j].fd, &fds[j], false);
poll_fdsetup(fds[j].fd, &fds[j], false);
break;
case POLLFILE:
(void)file_poll(fds[j].ptr, &fds[j], false);
file_poll(fds[j].ptr, &fds[j], false);
break;
#ifdef CONFIG_NET
case POLLSOCK:
(void)psock_poll(fds[j].ptr, &fds[j], false);
psock_poll(fds[j].ptr, &fds[j], false);
break;
#endif
@@ -452,7 +441,7 @@ int poll(FAR struct pollfd *fds, nfds_t nfds, int timeout)
/* poll() is a cancellation point */
(void)enter_cancellation_point();
enter_cancellation_point();
/* This semaphore is used for signaling and, hence, should not have
* priority inheritance enabled.
+1 -1
View File
@@ -143,7 +143,7 @@ ssize_t pread(int fd, FAR void *buf, size_t nbytes, off_t offset)
/* pread() is a cancellation point */
(void)enter_cancellation_point();
enter_cancellation_point();
/* Get the file structure corresponding to the file descriptor. */
+1 -1
View File
@@ -146,7 +146,7 @@ ssize_t pwrite(int fd, FAR const void *buf, size_t nbytes, off_t offset)
/* pread() is a cancellation point */
(void)enter_cancellation_point();
enter_cancellation_point();
/* Get the file structure corresponding to the file descriptor. */
+1 -1
View File
@@ -199,7 +199,7 @@ ssize_t read(int fd, FAR void *buf, size_t nbytes)
/* read() is a cancellation point */
(void)enter_cancellation_point();
enter_cancellation_point();
/* Let nx_read() do the real work */
+1 -1
View File
@@ -122,7 +122,7 @@ ssize_t readlink(FAR const char *path, FAR char *buf, size_t bufsize)
/* Copy the link target pathto the user-provided buffer. */
*buf = '\0';
(void)strncpy(buf, node->u.i_link, bufsize);
strncpy(buf, node->u.i_link, bufsize);
/* Release our reference on the inode and return the length */
+7 -7
View File
@@ -115,7 +115,7 @@ static int pseudorename(FAR const char *oldpath, FAR struct inode *oldinode,
subdirname = basename((FAR char *)oldpath);
(void)asprintf(&subdir, "/%s", subdirname);
asprintf(&subdir, "/%s", subdirname);
if (subdir == NULL)
{
ret = -ENOMEM;
@@ -179,7 +179,7 @@ next_subdir:
tmp = subdir;
subdir = NULL;
(void)asprintf(&subdir, "%s/%s", newpath, subdirname);
asprintf(&subdir, "%s/%s", newpath, subdirname);
if (tmp != NULL)
{
@@ -213,7 +213,7 @@ next_subdir:
* won't really be removed until we call inode_release();
*/
(void)inode_remove(newpath);
inode_remove(newpath);
}
inode_release(newinode);
@@ -274,7 +274,7 @@ next_subdir:
{
/* Remove the new node we just recreated */
(void)inode_remove(newpath);
inode_remove(newpath);
goto errout_with_sem;
}
@@ -415,8 +415,8 @@ next_subdir:
FAR char *tmp = subdir;
subdir = NULL;
(void)asprintf(&subdir, "%s/%s", newrelpath,
subdirname);
asprintf(&subdir, "%s/%s", newrelpath,
subdirname);
if (tmp != NULL)
{
@@ -450,7 +450,7 @@ next_subdir:
* should check that.
*/
(void)oldinode->u.i_mops->unlink(oldinode, newrelpath);
oldinode->u.i_mops->unlink(oldinode, newrelpath);
}
}
}
+1 -1
View File
@@ -103,7 +103,7 @@ int select(int nfds, FAR fd_set *readfds, FAR fd_set *writefds,
/* select() is cancellation point */
(void)enter_cancellation_point();
enter_cancellation_point();
/* How many pollfd structures do we need to allocate? */
+1 -1
View File
@@ -232,7 +232,7 @@ ssize_t write(int fd, FAR const void *buf, size_t nbytes)
/* write() is a cancellation point */
(void)enter_cancellation_point();
enter_cancellation_point();
/* Let nx_write() do all of the work */