mirror of
				https://github.com/eledio-devices/thirdparty-littlefs.git
				synced 2025-10-31 08:42:40 +01:00 
			
		
		
		
	Removed unnecessary truncate condition thanks to new seek optimization
This commit is contained in:
		
							
								
								
									
										4
									
								
								lfs.c
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								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; |         file->flags |= LFS_F_DIRTY | LFS_F_READING; | ||||||
|     } else if (size > oldsize) { |     } else if (size > oldsize) { | ||||||
|         // flush+seek if not already at end |         // flush+seek if not already at end | ||||||
|         if (file->pos != oldsize) { |  | ||||||
|         lfs_soff_t res = lfs_file_rawseek(lfs, file, 0, LFS_SEEK_END); |         lfs_soff_t res = lfs_file_rawseek(lfs, file, 0, LFS_SEEK_END); | ||||||
|         if (res < 0) { |         if (res < 0) { | ||||||
|             return (int)res; |             return (int)res; | ||||||
|         } |         } | ||||||
|         } |  | ||||||
|  |  | ||||||
|         // fill with zeros |         // fill with zeros | ||||||
|         while (file->pos < size) { |         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) { |             if (res < 0) { | ||||||
|                 return (int)res; |                 return (int)res; | ||||||
|             } |             } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user