lib: sbi: Fix bug in strncmp function when count is 0
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>
This commit is contained in:
parent
e928472e67
commit
d244f3dbd6
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue