diff options
author | Christopher Haster <chaster@utexas.edu> | 2021-01-11 09:13:18 +0300 |
---|---|---|
committer | Christopher Haster <chaster@utexas.edu> | 2021-01-11 09:14:34 +0300 |
commit | 47d6b2fcf34c231c491ae4a81dda2b3787f1156b (patch) | |
tree | 1a961d290bd9dba96c3c8511a8d79493497895cb /lfs.c | |
parent | 745d98cde08850cd0322daed86e5584a891095eb (diff) |
Removed unnecessary truncate condition thanks to new seek optimization
Diffstat (limited to 'lfs.c')
-rw-r--r-- | lfs.c | 10 |
1 files changed, 4 insertions, 6 deletions
@@ -3114,16 +3114,14 @@ static int lfs_file_rawtruncate(lfs_t *lfs, lfs_file_t *file, lfs_off_t size) { file->flags |= LFS_F_DIRTY | LFS_F_READING; } else if (size > oldsize) { // flush+seek if not already at end - if (file->pos != oldsize) { - lfs_soff_t res = lfs_file_rawseek(lfs, file, 0, LFS_SEEK_END); - if (res < 0) { - return (int)res; - } + lfs_soff_t res = lfs_file_rawseek(lfs, file, 0, LFS_SEEK_END); + if (res < 0) { + return (int)res; } // fill with zeros while (file->pos < size) { - lfs_ssize_t res = lfs_file_rawwrite(lfs, file, &(uint8_t){0}, 1); + res = lfs_file_rawwrite(lfs, file, &(uint8_t){0}, 1); if (res < 0) { return (int)res; } |