diff options
author | Max Filippov <jcmvbkbc@gmail.com> | 2021-08-11 02:08:06 +0300 |
---|---|---|
committer | Max Filippov <jcmvbkbc@gmail.com> | 2021-08-11 21:36:10 +0300 |
commit | 13066c303769b5c6bc67c0b990a4eb80058fb1b4 (patch) | |
tree | cf8da77ec2e4af51ffd881cd7a799098695f0bc7 /arch/xtensa/platforms/iss | |
parent | 43ba2237281a59b40ea2393da9e89ea3a68de2a5 (diff) | |
download | linux-13066c303769b5c6bc67c0b990a4eb80058fb1b4.tar.xz |
xtensa: ISS: don't use string pointer before NULL check
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>
Diffstat (limited to 'arch/xtensa/platforms/iss')
-rw-r--r-- | arch/xtensa/platforms/iss/console.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/arch/xtensa/platforms/iss/console.c b/arch/xtensa/platforms/iss/console.c index 21184488c277..f6e5fc5579be 100644 --- a/arch/xtensa/platforms/iss/console.c +++ b/arch/xtensa/platforms/iss/console.c @@ -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) |