Skip to content

Commit

Permalink
fix build warning to [-Wstringop-overread].
Browse files Browse the repository at this point in the history
note/note_driver.c:639:21: warning: 'strlen' reading 1 or more bytes from a region of size 0 [-Wstringop-overread]
  639 |           namelen = strlen(tcb->name);
      |                     ^~~~~~~~~~~~~~~~~

Signed-off-by: cuiziwei <cuiziwei@xiaomi.com>
  • Loading branch information
cuiziweizw authored and xiaoxiang781216 committed Oct 13, 2024
1 parent 04f3ff5 commit 4b318cb
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions drivers/note/note_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ void sched_note_start(FAR struct tcb_s *tcb)
bool formatted = false;

#if CONFIG_TASK_NAME_SIZE > 0
int namelen;
int namelen = 0;
#endif

for (driver = g_note_drivers; *driver; driver++)
Expand Down Expand Up @@ -671,7 +671,10 @@ void sched_note_start(FAR struct tcb_s *tcb)
*/

#if CONFIG_TASK_NAME_SIZE > 0
namelen = strlen(tcb->name);
if (tcb->name[0] != '\0')
{
namelen = strlen(tcb->name);
}

DEBUGASSERT(namelen <= CONFIG_TASK_NAME_SIZE);
strlcpy(note.nsa_name, tcb->name, sizeof(note.nsa_name));
Expand Down

0 comments on commit 4b318cb

Please sign in to comment.