Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/littlefs-project/littlefs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lfs.c
diff options
context:
space:
mode:
authorChristopher Haster <chaster@utexas.edu>2021-01-11 09:13:18 +0300
committerChristopher Haster <chaster@utexas.edu>2021-01-11 09:14:34 +0300
commit47d6b2fcf34c231c491ae4a81dda2b3787f1156b (patch)
tree1a961d290bd9dba96c3c8511a8d79493497895cb /lfs.c
parent745d98cde08850cd0322daed86e5584a891095eb (diff)
Removed unnecessary truncate condition thanks to new seek optimization
Diffstat (limited to 'lfs.c')
-rw-r--r--lfs.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/lfs.c b/lfs.c
index f54aa04..7b7d5b6 100644
--- a/lfs.c
+++ b/lfs.c
@@ -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;
}