projects
/
platform
/
kernel
/
opensbi-spacemit.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
e928472
)
lib: sbi: Fix bug in strncmp function when count is 0
author
Dong Du
<Dd_nirvana@sjtu.edu.cn>
Wed, 28 Jul 2021 16:15:35 +0000
(
00:15
+0800)
committer
Anup Patel
<anup@brainfault.org>
Sat, 7 Aug 2021 10:10:40 +0000
(15:40 +0530)
No need to compare characters when the count turns to 0.
Fix the issue in sbi_strncmp.
Signed-off-by: Dong Du <Dd_nirvana@sjtu.edu.cn>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
lib/sbi/sbi_string.c
patch
|
blob
|
history
diff --git
a/lib/sbi/sbi_string.c
b/lib/sbi/sbi_string.c
index
7805ba4
..
c87bce9
100644
(file)
--- a/
lib/sbi/sbi_string.c
+++ b/
lib/sbi/sbi_string.c
@@
-33,6
+33,10
@@
int sbi_strncmp(const char *a, const char *b, size_t count)
for (; count > 0 && *a == *b && *a != '\0'; a++, b++, count--)
;
+ /* No difference till the end */
+ if (!count)
+ return 0;
+
return *a - *b;
}