mirror of
https://github.com/apache/nuttx.git
synced 2026-06-07 09:18:00 +08:00
Fix issues detected by clang
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user