Skip to content

Commit

Permalink
xtensa: ISS: don't use string pointer before NULL check
Browse files Browse the repository at this point in the history
Move strlen call inside the if block that checks string pointer for NULL.
While at it also fix the following coccicheck warning:

./arch/xtensa/platforms/iss/console.c:204:10-11: WARNING comparing
pointer to 0.

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
  • Loading branch information
Max Filippov committed Aug 11, 2021
1 parent 43ba223 commit 13066c3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions arch/xtensa/platforms/iss/console.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,10 @@ late_initcall(rs_init);

static void iss_console_write(struct console *co, const char *s, unsigned count)
{
int len = strlen(s);

if (s != 0 && *s != 0)
if (s && *s != 0) {
int len = strlen(s);
simc_write(1, s, count < len ? count : len);
}
}

static struct tty_driver* iss_console_device(struct console *c, int *index)
Expand Down

0 comments on commit 13066c3

Please sign in to comment.