4a16cf71f9
Error: module/mod_insmod.c:203:3: error: 'strncpy' specified bound 16 equals destination size [-Werror=stringop-truncation] 203 | strncpy(modp->modname, modname, MODLIB_NAMEMAX); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ wqueue/kwork_thread.c: In function 'work_start_lowpri': Error: wqueue/kwork_thread.c:212:22: error: '%lx' directive output may be truncated writing between 1 and 16 bytes into a region of size 14 [-Werror=format-truncation=] 212 | snprintf(args, 16, "0x%" PRIxPTR, (uintptr_t)wqueue); local/local_sockif.c: In function 'local_getsockname': Error: local/local_sockif.c:392:11: error: 'strncpy' specified bound depends on the length of the source argument [-Werror=stringop-overflow=] 392 | strncpy(unaddr->sun_path, conn->lc_path, namelen); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ chip/esp32_wifi_utils.c: In function 'esp_wifi_scan_event_parse': Error: chip/esp32_wifi_utils.c:373:37: error: argument to 'sizeof' in 'memset' call is the same expression as the destination; did you mean to dereference it? [-Werror=sizeof-pointer-memaccess] memset(ap_list_buffer, 0x0, sizeof(ap_list_buffer)); ^ stdio/lib_fputs.c: In function 'fputs': Error: stdio/lib_fputs.c:99:9: error: nonnull argument 's' compared to NULL [-Werror=nonnull-compare] if (s == NULL || stream == NULL) ^ Error: stdio/lib_fputs.c:99:27: error: nonnull argument 'stream' compared to NULL [-Werror=nonnull-compare] if (s == NULL || stream == NULL) ^ stdio/lib_vfprintf.c: In function 'vfprintf': Error: stdio/lib_vfprintf.c:40:6: error: nonnull argument 'stream' compared to NULL [-Werror=nonnull-compare] if (stream) ^ string/lib_strdup.c: In function 'strdup': Error: string/lib_strdup.c:39:6: error: nonnull argument 's' compared to NULL [-Werror=nonnull-compare] if (s) ^ string/lib_strndup.c: In function 'strndup': Error: string/lib_strndup.c:56:6: error: nonnull argument 's' compared to NULL [-Werror=nonnull-compare] if (s) ^ string/lib_strpbrk.c: In function 'strpbrk': Error: string/lib_strpbrk.c:39:7: error: nonnull argument 'str' compared to NULL [-Werror=nonnull-compare] if (!str || !charset) ^~~~ Error: string/lib_strpbrk.c:39:15: error: nonnull argument 'charset' compared to NULL [-Werror=nonnull-compare] if (!str || !charset) ^~~~~~~~ string/lib_strrchr.c: In function 'strrchr': Error: string/lib_strrchr.c:40:6: error: nonnull argument 's' compared to NULL [-Werror=nonnull-compare] if (s) ^ Error: time/lib_asctimer.c:73:50: error: '%d' directive output may be truncated writing between 1 and 11 bytes into a region of size between 0 and 12 [-Werror=format-truncation=] snprintf(buf, 26, "%.3s %.3s%3d %.2d:%.2d:%.2d %d\n", ^~ time/lib_asctimer.c:73:21: note: directive argument in the range [-2147481748, 2147483647] snprintf(buf, 26, "%.3s %.3s%3d %.2d:%.2d:%.2d %d\n", ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ time/lib_asctimer.c:73:3: note: 'snprintf' output between 17 and 68 bytes into a destination of size 26 snprintf(buf, 26, "%.3s %.3s%3d %.2d:%.2d:%.2d %d\n", ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ g_wday_name[tp->tm_wday], g_mon_name[tp->tm_mon], ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ tp->tm_mday, tp->tm_hour, tp->tm_min, tp->tm_sec, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1900 + tp->tm_year); ~~~~~~~~~~~~~~~~~~~ Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
145 lines
3.7 KiB
C
145 lines
3.7 KiB
C
/****************************************************************************
|
|
* libs/libc/stdio/lib_fputs.c
|
|
*
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
* this work for additional information regarding copyright ownership. The
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
* "License"); you may not use this file except in compliance with the
|
|
* License. You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
* License for the specific language governing permissions and limitations
|
|
* under the License.
|
|
*
|
|
****************************************************************************/
|
|
|
|
/****************************************************************************
|
|
* Included Files
|
|
****************************************************************************/
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <errno.h>
|
|
|
|
#include <nuttx/arch.h>
|
|
|
|
#include "libc.h"
|
|
|
|
/****************************************************************************
|
|
* Public Functions
|
|
****************************************************************************/
|
|
|
|
/****************************************************************************
|
|
* Name: fputs
|
|
*
|
|
* Description:
|
|
* fputs() writes the string s to stream, without its trailing '\0'.
|
|
*
|
|
****************************************************************************/
|
|
|
|
#if defined(CONFIG_ARCH_ROMGETC)
|
|
int fputs(FAR const IPTR char *s, FAR FILE *stream)
|
|
{
|
|
int nput;
|
|
int ret;
|
|
char ch;
|
|
|
|
/* Write the string. Loop until the null terminator is encountered */
|
|
|
|
for (nput = 0, ch = up_romgetc(s); ch; nput++, s++, ch = up_romgetc(s))
|
|
{
|
|
/* Write the next character to the stream buffer */
|
|
|
|
ret = lib_fwrite(&ch, 1, stream);
|
|
if (ret <= 0)
|
|
{
|
|
return EOF;
|
|
}
|
|
|
|
/* Flush the buffer if a newline was written to the buffer */
|
|
|
|
if (ch == '\n' && (stream->fs_flags & __FS_FLAG_LBF) != 0)
|
|
{
|
|
ret = lib_fflush(stream, true);
|
|
if (ret < 0)
|
|
{
|
|
return EOF;
|
|
}
|
|
}
|
|
}
|
|
|
|
return nput;
|
|
}
|
|
|
|
#else
|
|
int fputs(FAR const IPTR char *s, FAR FILE *stream)
|
|
{
|
|
int nput;
|
|
|
|
/* If line buffering is enabled, then we will have to output one character
|
|
* at a time, checking for a newline character each time.
|
|
*/
|
|
|
|
if ((stream->fs_flags & __FS_FLAG_LBF) != 0)
|
|
{
|
|
int ret;
|
|
|
|
/* Write the string. Loop until the null terminator is encountered */
|
|
|
|
for (nput = 0; *s; nput++, s++)
|
|
{
|
|
/* Write the next character to the stream buffer */
|
|
|
|
ret = lib_fwrite(s, 1, stream);
|
|
if (ret <= 0)
|
|
{
|
|
return EOF;
|
|
}
|
|
|
|
/* Flush the buffer if a newline was written to the buffer */
|
|
|
|
if (*s == '\n')
|
|
{
|
|
ret = lib_fflush(stream, true);
|
|
if (ret < 0)
|
|
{
|
|
return EOF;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/* We can write the whole string in one operation without line buffering */
|
|
|
|
else
|
|
{
|
|
int ntowrite;
|
|
|
|
/* Get the length of the string. */
|
|
|
|
ntowrite = strlen(s);
|
|
if (ntowrite == 0)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
/* Write the string */
|
|
|
|
nput = lib_fwrite(s, ntowrite, stream);
|
|
if (nput < 0)
|
|
{
|
|
return EOF;
|
|
}
|
|
}
|
|
|
|
return nput;
|
|
}
|
|
#endif
|