fs_rammap:Check last fileseek restore fpos
Summary: When restoring rammap fpos, we check the return value to avoid potential problems caused by no error return if the restore fails. Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
This commit is contained in:
parent
8155102f7d
commit
0ac21a911b
@ -78,7 +78,7 @@ static int msync_rammap(FAR struct mm_map_entry_s *entry, FAR void *start,
|
|||||||
fpos = file_seek(filep, entry->offset + offset, SEEK_SET);
|
fpos = file_seek(filep, entry->offset + offset, SEEK_SET);
|
||||||
if (fpos < 0)
|
if (fpos < 0)
|
||||||
{
|
{
|
||||||
ferr("ERRORL Seek to position %"PRIdOFF" failed\n", fpos);
|
ferr("ERROR: Seek to position %"PRIdOFF" failed\n", fpos);
|
||||||
return fpos;
|
return fpos;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,7 +109,15 @@ static int msync_rammap(FAR struct mm_map_entry_s *entry, FAR void *start,
|
|||||||
|
|
||||||
/* Restore file pos */
|
/* Restore file pos */
|
||||||
|
|
||||||
file_seek(filep, opos, SEEK_SET);
|
fpos = file_seek(filep, opos, SEEK_SET);
|
||||||
|
if (fpos < 0)
|
||||||
|
{
|
||||||
|
/* Ensure that we finally seek back to the current file pos */
|
||||||
|
|
||||||
|
ferr("ERROR: Seek back to position %"PRIdOFF" failed\n", fpos);
|
||||||
|
return fpos;
|
||||||
|
}
|
||||||
|
|
||||||
return nwrite >= 0 ? 0 : nwrite;
|
return nwrite >= 0 ? 0 : nwrite;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user