]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
btrfs: constify input buffer parameter in compression code
authorDavid Sterba <dsterba@suse.com>
Mon, 7 Nov 2022 16:30:21 +0000 (17:30 +0100)
committerDavid Sterba <dsterba@suse.com>
Mon, 5 Dec 2022 17:00:55 +0000 (18:00 +0100)
The input buffers passed down to compression must never be changed,
switch type to u8 as it's a raw byte buffer and use const.

Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/compression.c
fs/btrfs/compression.h
fs/btrfs/lzo.c
fs/btrfs/zlib.c
fs/btrfs/zstd.c

index 42e6dde2ad598b31c2f7d90be826c4d3a3420699..30adf430241e14401ed639dee8a5b2507323a197 100644 (file)
@@ -119,7 +119,7 @@ static int compression_decompress_bio(struct list_head *ws,
 }
 
 static int compression_decompress(int type, struct list_head *ws,
-               unsigned char *data_in, struct page *dest_page,
+               const u8 *data_in, struct page *dest_page,
                unsigned long start_byte, size_t srclen, size_t destlen)
 {
        switch (type) {
@@ -1232,7 +1232,7 @@ static int btrfs_decompress_bio(struct compressed_bio *cb)
  * single page, and we want to read a single page out of it.
  * start_byte tells us the offset into the compressed data we're interested in
  */
-int btrfs_decompress(int type, unsigned char *data_in, struct page *dest_page,
+int btrfs_decompress(int type, const u8 *data_in, struct page *dest_page,
                     unsigned long start_byte, size_t srclen, size_t destlen)
 {
        struct list_head *workspace;
index b961462399aeb6841775dc047d9d5ae638208c94..6209d40a1e08e31a0adf5c5d4c7007d2e417e14f 100644 (file)
@@ -86,7 +86,7 @@ int btrfs_compress_pages(unsigned int type_level, struct address_space *mapping,
                         unsigned long *out_pages,
                         unsigned long *total_in,
                         unsigned long *total_out);
-int btrfs_decompress(int type, unsigned char *data_in, struct page *dest_page,
+int btrfs_decompress(int type, const u8 *data_in, struct page *dest_page,
                     unsigned long start_byte, size_t srclen, size_t destlen);
 int btrfs_decompress_buf2page(const char *buf, u32 buf_len,
                              struct compressed_bio *cb, u32 decompressed);
@@ -150,7 +150,7 @@ int zlib_compress_pages(struct list_head *ws, struct address_space *mapping,
                u64 start, struct page **pages, unsigned long *out_pages,
                unsigned long *total_in, unsigned long *total_out);
 int zlib_decompress_bio(struct list_head *ws, struct compressed_bio *cb);
-int zlib_decompress(struct list_head *ws, unsigned char *data_in,
+int zlib_decompress(struct list_head *ws, const u8 *data_in,
                struct page *dest_page, unsigned long start_byte, size_t srclen,
                size_t destlen);
 struct list_head *zlib_alloc_workspace(unsigned int level);
@@ -161,7 +161,7 @@ int lzo_compress_pages(struct list_head *ws, struct address_space *mapping,
                u64 start, struct page **pages, unsigned long *out_pages,
                unsigned long *total_in, unsigned long *total_out);
 int lzo_decompress_bio(struct list_head *ws, struct compressed_bio *cb);
-int lzo_decompress(struct list_head *ws, unsigned char *data_in,
+int lzo_decompress(struct list_head *ws, const u8 *data_in,
                struct page *dest_page, unsigned long start_byte, size_t srclen,
                size_t destlen);
 struct list_head *lzo_alloc_workspace(unsigned int level);
@@ -171,7 +171,7 @@ int zstd_compress_pages(struct list_head *ws, struct address_space *mapping,
                u64 start, struct page **pages, unsigned long *out_pages,
                unsigned long *total_in, unsigned long *total_out);
 int zstd_decompress_bio(struct list_head *ws, struct compressed_bio *cb);
-int zstd_decompress(struct list_head *ws, unsigned char *data_in,
+int zstd_decompress(struct list_head *ws, const u8 *data_in,
                struct page *dest_page, unsigned long start_byte, size_t srclen,
                size_t destlen);
 void zstd_init_workspace_manager(void);
index e7b1ceffcd33bfd40d9e8d1b0833dc82e19cf6f2..d5e78cbc8fbc7747abe7868cf8c3506a59a4ccaa 100644 (file)
@@ -427,7 +427,7 @@ out:
        return ret;
 }
 
-int lzo_decompress(struct list_head *ws, unsigned char *data_in,
+int lzo_decompress(struct list_head *ws, const u8 *data_in,
                struct page *dest_page, unsigned long start_byte, size_t srclen,
                size_t destlen)
 {
index c5275cb238377aaeba15708c3a868bae4b6cac66..01a13de11832097f01d745f4357276d6463bef52 100644 (file)
@@ -355,7 +355,7 @@ done:
        return ret;
 }
 
-int zlib_decompress(struct list_head *ws, unsigned char *data_in,
+int zlib_decompress(struct list_head *ws, const u8 *data_in,
                struct page *dest_page, unsigned long start_byte, size_t srclen,
                size_t destlen)
 {
index 4575b3703e74e14543f957821ff17662005a599c..e34f1ab99d56fe26d0d0a14658fd53205817f9a2 100644 (file)
@@ -616,7 +616,7 @@ done:
        return ret;
 }
 
-int zstd_decompress(struct list_head *ws, unsigned char *data_in,
+int zstd_decompress(struct list_head *ws, const u8 *data_in,
                struct page *dest_page, unsigned long start_byte, size_t srclen,
                size_t destlen)
 {