diff options
author | Ahmad Fatoum <a.fatoum@pengutronix.de> | 2022-09-05 11:55:42 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2022-09-12 12:05:01 +0200 |
commit | 0f3188c636fe9a39ebeb942e9fdcbd2f34c28b19 (patch) | |
tree | e8ce72ab8fc4455f5e8f923d99abb473012a81c9 /common/password.c | |
parent | bacabbbee24c290baa38b7db0e24007847addf93 (diff) | |
download | barebox-0f3188c636fe9a39ebeb942e9fdcbd2f34c28b19.tar.gz |
password: avoid static analyzer false positive
default_passwd is a compile-time constant. In case, where it's unset,
the function will early-return and the static analyzer will warn about
len being initialized, but never used, move the length calculation later
to avoid this false positive.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20220905095557.596891-18-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common/password.c')
-rw-r--r-- | common/password.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/common/password.c b/common/password.c index aea7c7ff5d..55b2d1093a 100644 --- a/common/password.c +++ b/common/password.c @@ -148,8 +148,7 @@ static unsigned char to_hexa(unsigned char c) static int read_default_passwd(unsigned char *sum, size_t length) { - int i = 0; - int len = strlen(default_passwd); + int len, i = 0; unsigned char *buf = (unsigned char *)default_passwd; unsigned char c; @@ -159,6 +158,7 @@ static int read_default_passwd(unsigned char *sum, size_t length) if (!sum || length < 1) return -EINVAL; + len = strlen(default_passwd); for (i = 0; i < len && length > 0; i++) { c = buf[i]; i++; |