mirror of
https://github.com/apache/nuttx.git
synced 2026-08-26 20:00:42 +00:00
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
a04e44ea75
commit
e86be98d14
1 changed files with 10 additions and 2 deletions
|
|
@ -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);
|
||||
if (fpos < 0)
|
||||
{
|
||||
ferr("ERRORL Seek to position %"PRIdOFF" failed\n", fpos);
|
||||
ferr("ERROR: Seek to position %"PRIdOFF" failed\n", fpos);
|
||||
return fpos;
|
||||
}
|
||||
|
||||
|
|
@ -109,7 +109,15 @@ static int msync_rammap(FAR struct mm_map_entry_s *entry, FAR void *start,
|
|||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue