mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 00:14:22 +08:00
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:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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 */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user