diff --git a/drivers/bch/bchlib_read.c b/drivers/bch/bchlib_read.c index 5257e6f2bb..786f603c8f 100644 --- a/drivers/bch/bchlib_read.c +++ b/drivers/bch/bchlib_read.c @@ -132,7 +132,6 @@ ssize_t bchlib_read(FAR void *handle, FAR char *buffer, size_t offset, size_t le /* Adjust pointers and counts */ - sectoffset = 0; sector++; if (sector >= bch->nsectors) @@ -167,7 +166,6 @@ ssize_t bchlib_read(FAR void *handle, FAR char *buffer, size_t offset, size_t le /* Adjust pointers and counts */ - sectoffset = 0; sector += nsectors; nbytes = nsectors * bch->sectsize; diff --git a/drivers/bch/bchlib_write.c b/drivers/bch/bchlib_write.c index 21fce2cd03..d4563e437a 100644 --- a/drivers/bch/bchlib_write.c +++ b/drivers/bch/bchlib_write.c @@ -132,7 +132,6 @@ ssize_t bchlib_write(FAR void *handle, FAR const char *buffer, size_t offset, si /* Adjust pointers and counts */ - sectoffset = 0; sector++; if (sector >= bch->nsectors) @@ -169,7 +168,6 @@ ssize_t bchlib_write(FAR void *handle, FAR const char *buffer, size_t offset, si /* Adjust pointers and counts */ - sectoffset = 0; sector += nsectors; nbytes = nsectors * bch->sectsize; diff --git a/libc/stdio/lib_libfwrite.c b/libc/stdio/lib_libfwrite.c index ea75da6d7f..26fc0b1845 100644 --- a/libc/stdio/lib_libfwrite.c +++ b/libc/stdio/lib_libfwrite.c @@ -94,7 +94,13 @@ ssize_t lib_fwrite(FAR const void *ptr, size_t count, FAR FILE *stream) /* Make sure that writing to this stream is allowed */ - if (!stream || (stream->fs_oflags & O_WROK) == 0) + if (stream == NULL) + { + set_errno(EBADF); + return ret; + } + + if ((stream->fs_oflags & O_WROK) == 0) { set_errno(EBADF); goto errout; diff --git a/libc/stdio/lib_vasprintf.c b/libc/stdio/lib_vasprintf.c index 5f0649a174..aa17757541 100644 --- a/libc/stdio/lib_vasprintf.c +++ b/libc/stdio/lib_vasprintf.c @@ -112,7 +112,7 @@ * ****************************************************************************/ -int vasprintf(FAR char **ptr, const char *fmt, va_list ap) +int vasprintf(FAR char **ptr, FAR const char *fmt, va_list ap) { struct lib_outstream_s nulloutstream; struct lib_memoutstream_s memoutstream; @@ -130,12 +130,12 @@ int vasprintf(FAR char **ptr, const char *fmt, va_list ap) va_copy(ap2, ap); #endif -/* First, use a nullstream to get the size of the buffer. The number + /* First, use a nullstream to get the size of the buffer. The number * of bytes returned may or may not include the null terminator. */ lib_nulloutstream(&nulloutstream); - nbytes = lib_vsprintf((FAR struct lib_outstream_s *)&nulloutstream, fmt, ap1); + (void)lib_vsprintf((FAR struct lib_outstream_s *)&nulloutstream, fmt, ap1); /* Then allocate a buffer to hold that number of characters, adding one * for the null terminator. diff --git a/mm/mm_heap/mm_realloc.c b/mm/mm_heap/mm_realloc.c index 5778975f50..ef592b7cf4 100644 --- a/mm/mm_heap/mm_realloc.c +++ b/mm/mm_heap/mm_realloc.c @@ -258,10 +258,6 @@ FAR void *mm_realloc(FAR struct mm_heap_s *heap, FAR void *oldmem, /* Return the previous free node to the nodelist (with the new size) */ mm_addfreechunk(heap, prev); - - /* Now we want to return newnode */ - - oldnode = newnode; } else { @@ -272,6 +268,8 @@ FAR void *mm_realloc(FAR struct mm_heap_s *heap, FAR void *oldmem, next->preceding = newnode->size | (next->preceding & MM_ALLOC_BIT); } + /* Now we want to return newnode */ + oldnode = newnode; oldsize = newnode->size; diff --git a/sched/semaphore/sem_timedwait.c b/sched/semaphore/sem_timedwait.c index 503aed2322..106a8bc404 100644 --- a/sched/semaphore/sem_timedwait.c +++ b/sched/semaphore/sem_timedwait.c @@ -179,7 +179,6 @@ int sem_timedwait(FAR sem_t *sem, FAR const struct timespec *abstime) /* Start the watchdog */ - errcode = OK; (void)wd_start(rtcb->waitdog, ticks, (wdentry_t)sem_timeout, 1, getpid()); /* Now perform the blocking wait */ @@ -196,6 +195,11 @@ int sem_timedwait(FAR sem_t *sem, FAR const struct timespec *abstime) wd_cancel(rtcb->waitdog); + if (errcode != OK) + { + goto errout_with_irqdisabled; + } + /* We can now restore interrupts and delete the watchdog */ /* Success exits */