summaryrefslogtreecommitdiffstats
path: root/fs/ext4/ext4_write.c
diff options
context:
space:
mode:
authorJean-Jacques Hiblot <jjhiblot@ti.com>2019-02-13 12:15:24 +0100
committerTom Rini <trini@konsulko.com>2019-04-09 15:34:15 -0400
commitb000180b0f467851525aae3d0dfb8ab3a9dbcf8f (patch)
tree8a2b6570dcf3c37f581346ae8366d32fe91d64a1 /fs/ext4/ext4_write.c
parent290100583dc70185e76ddaa00c1a50abd162a5ad (diff)
downloadu-boot-b000180b0f467851525aae3d0dfb8ab3a9dbcf8f.tar.gz
u-boot-b000180b0f467851525aae3d0dfb8ab3a9dbcf8f.tar.xz
u-boot-b000180b0f467851525aae3d0dfb8ab3a9dbcf8f.zip
fs: ext4: constify the buffer passed to write functions
There is no need to modify the buffer passed to ext4fs_write_file(). The memset() call is not required here and was likely copied from the equivalent part of the ext4fs_read_file() function where we do need it. Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com> Reviewed-by: Tom Rini <trini@konsulko.com>
Diffstat (limited to 'fs/ext4/ext4_write.c')
-rw-r--r--fs/ext4/ext4_write.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/fs/ext4/ext4_write.c b/fs/ext4/ext4_write.c
index 95ffa3dfad..b5b7ee8133 100644
--- a/fs/ext4/ext4_write.c
+++ b/fs/ext4/ext4_write.c
@@ -752,7 +752,7 @@ void ext4fs_deinit(void)
* contigous sectors as ext4fs_read_file
*/
static int ext4fs_write_file(struct ext2_inode *file_inode,
- int pos, unsigned int len, char *buf)
+ int pos, unsigned int len, const char *buf)
{
int i;
int blockcnt;
@@ -764,7 +764,7 @@ static int ext4fs_write_file(struct ext2_inode *file_inode,
int delayed_start = 0;
int delayed_extent = 0;
int delayed_next = 0;
- char *delayed_buf = NULL;
+ const char *delayed_buf = NULL;
/* Adjust len so it we can't read past the end of the file. */
if (len > filesize)
@@ -816,7 +816,6 @@ static int ext4fs_write_file(struct ext2_inode *file_inode,
(uint32_t) delayed_extent);
previous_block_number = -1;
}
- memset(buf, 0, fs->blksz - skipfirst);
}
buf += fs->blksz - skipfirst;
}
@@ -830,8 +829,8 @@ static int ext4fs_write_file(struct ext2_inode *file_inode,
return len;
}
-int ext4fs_write(const char *fname, unsigned char *buffer,
- unsigned long sizebytes)
+int ext4fs_write(const char *fname, const char *buffer,
+ unsigned long sizebytes)
{
int ret = 0;
struct ext2_inode *file_inode = NULL;
@@ -949,7 +948,7 @@ int ext4fs_write(const char *fname, unsigned char *buffer,
if (ext4fs_put_metadata(temp_ptr, itable_blkno))
goto fail;
/* copy the file content into data blocks */
- if (ext4fs_write_file(file_inode, 0, sizebytes, (char *)buffer) == -1) {
+ if (ext4fs_write_file(file_inode, 0, sizebytes, buffer) == -1) {
printf("Error in copying content\n");
/* FIXME: Deallocate data blocks */
goto fail;