yaffs: fix -Wstringop-overread compile warning in yaffs_fix_null_name
In yaffs_fix_null_name, "if (strnlen(name, YAFFS_MAX_NAME_LENGTH) == 0)" is used to judge if the "name" string is zero length. But this is wrong when the "name" char array size is less than YAFFS_MAX_NAME_LENGTH and this will trigger compile warnig as below: fs/yaffs2/yaffs_guts.c:4501:13: warning: ‘strnlen’ specified bound 255 exceeds source size 16 [-Wstringop-overread] 4501 | if (strnlen(name, YAFFS_MAX_NAME_LENGTH) == 0) { | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Let's use buffer_size to do this instead of YAFFS_MAX_NAME_LENGTH because buffer_size is passed to yaffs_fix_null_name by caller with appropriate value which is fixed to the size of "name" char array. Signed-off-by:Quanyang Wang <quanyang.wang@windriver.com> Signed-off-by:
Bruce Ashfield <bruce.ashfield@gmail.com>
Loading
Please register or sign in to comment