Fixed incorrect return value from lfs_file_seek

lfs_file_seek returned the _previous_ file offset on success, where
most standards return the _calculated_ offset on success.

This just falls into me not noticing a mistake, and shows why it's
always helpful to have a second set of eyes on code.
This commit is contained in:
Christopher Haster
2017-09-26 19:50:39 -05:00
parent 273cb7c9c8
commit 984340225b
2 changed files with 26 additions and 30 deletions

4
lfs.c
View File

@@ -1522,8 +1522,6 @@ lfs_soff_t lfs_file_seek(lfs_t *lfs, lfs_file_t *file,
}
// update pos
lfs_off_t pos = file->pos;
if (whence == LFS_SEEK_SET) {
file->pos = off;
} else if (whence == LFS_SEEK_CUR) {
@@ -1540,7 +1538,7 @@ lfs_soff_t lfs_file_seek(lfs_t *lfs, lfs_file_t *file,
file->pos = file->size + off;
}
return pos;
return file->pos;
}
lfs_soff_t lfs_file_tell(lfs_t *lfs, lfs_file_t *file) {