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
@@ -173,7 +173,7 @@ static int bch_close(FAR struct file *filep)
/* Flush any dirty pages remaining in the cache */
bchlib_semtake(bch);
(void)bchlib_flushsector(bch);
bchlib_flushsector(bch);
/* Decrement the reference count (I don't use bchlib_decref() because I
* want the entire close operation to be atomic wrt other driver
+1 -1
View File
@@ -99,7 +99,7 @@ int bchdev_unregister(FAR const char *chardev)
ret = file_ioctl(&filestruct, DIOC_GETPRIV,
(unsigned long)((uintptr_t)&bch));
(void)file_close(&filestruct);
file_close(&filestruct);
if (ret < 0)
{
+1 -1
View File
@@ -181,7 +181,7 @@ int bchlib_readsector(FAR struct bchlib_s *bch, size_t sector)
{
inode = bch->inode;
(void)bchlib_flushsector(bch);
bchlib_flushsector(bch);
bch->sector = (size_t)-1;
ret = inode->u.i_bops->read(inode, bch->buffer, sector, 1);
+1 -15
View File
@@ -57,19 +57,5 @@
void bchlib_semtake(FAR struct bchlib_s *bch)
{
int ret;
do
{
/* Take the semaphore (perhaps waiting) */
ret = nxsem_wait(&bch->sem);
/* The only case that an error should occur here is if the wait was
* awakened by a signal.
*/
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
nxsem_wait_uninterruptible(&bch->sem);
}
+1 -1
View File
@@ -81,7 +81,7 @@ int bchlib_teardown(FAR void *handle)
/* Close the block driver */
(void)close_blockdriver(bch->inode);
close_blockdriver(bch->inode);
/* Free the BCH state structure */