Re: [PATCH] btrfs-progs: change btrfs_csum_final result param type to u8

2016-09-19 Thread David Sterba
On Sun, Sep 18, 2016 at 12:10:22AM +0100, Domagoj Tršan wrote:
> csum member of struct btrfs_super_block has array type of u8. It makes sense
> that function btrfs_csum_final should be also declared to accept u8 *. I
> changed the declaration of method void btrfs_csum_final(u32 crc, char 
> *result);
> to void btrfs_csum_final(u32 crc, u8 *result);
> Also, I changed definitions of various csum variables to be consistent with
> kernel code.

Aligning the progs code with kernel is useful, even the seemingly
trivial changes (through there will be always some differences). Feel
free to send more patches like that.

Patch applied, thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] btrfs-progs: change btrfs_csum_final result param type to u8

2016-09-17 Thread Domagoj Tršan
Signed-off-by: Domagoj Tršan 
---
 btrfs-image.c |  2 +-
 chunk-recover.c   |  2 +-
 cmds-check.c  |  2 +-
 cmds-inspect-dump-super.c |  2 +-
 disk-io.c | 10 +-
 disk-io.h |  2 +-
 file-item.c   |  2 +-
 free-space-cache.c|  2 +-
 super-recover.c   |  2 +-
 utils.c   |  2 +-
 10 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/btrfs-image.c b/btrfs-image.c
index 953d368..6de163c 100644
--- a/btrfs-image.c
+++ b/btrfs-image.c
@@ -163,7 +163,7 @@ static struct extent_buffer *alloc_dummy_eb(u64 bytenr, u32 
size);
 
 static void csum_block(u8 *buf, size_t len)
 {
-   char result[BTRFS_CRC32_SIZE];
+   u8 result[BTRFS_CRC32_SIZE];
u32 crc = ~(u32)0;
crc = crc32c(crc, buf + BTRFS_CSUM_SIZE, len - BTRFS_CSUM_SIZE);
btrfs_csum_final(crc, result);
diff --git a/chunk-recover.c b/chunk-recover.c
index 4a081db..32d2805 100644
--- a/chunk-recover.c
+++ b/chunk-recover.c
@@ -1914,7 +1914,7 @@ static int check_one_csum(int fd, u64 start, u32 len, u32 
tree_csum)
}
ret = 0;
csum_result = btrfs_csum_data(NULL, data, csum_result, len);
-   btrfs_csum_final(csum_result, (char *)&csum_result);
+   btrfs_csum_final(csum_result, (u8 *)&csum_result);
if (csum_result != tree_csum)
ret = 1;
 out:
diff --git a/cmds-check.c b/cmds-check.c
index a453696..a36693d 100644
--- a/cmds-check.c
+++ b/cmds-check.c
@@ -5740,7 +5740,7 @@ again:
 
csum = btrfs_csum_data(NULL, (char *)data + tmp,
   csum, root->sectorsize);
-   btrfs_csum_final(csum, (char *)&csum);
+   btrfs_csum_final(csum, (u8 *)&csum);
 
csum_offset = leaf_offset +
 tmp / root->sectorsize * csum_size;
diff --git a/cmds-inspect-dump-super.c b/cmds-inspect-dump-super.c
index aab5075..2f2c628 100644
--- a/cmds-inspect-dump-super.c
+++ b/cmds-inspect-dump-super.c
@@ -37,7 +37,7 @@
 
 static int check_csum_sblock(void *sb, int csum_size)
 {
-   char result[BTRFS_CSUM_SIZE];
+   u8 result[BTRFS_CSUM_SIZE];
u32 crc = ~(u32)0;
 
crc = btrfs_csum_data(NULL, (char *)sb + BTRFS_CSUM_SIZE,
diff --git a/disk-io.c b/disk-io.c
index f5340c3..c16eda2 100644
--- a/disk-io.c
+++ b/disk-io.c
@@ -123,7 +123,7 @@ u32 btrfs_csum_data(struct btrfs_root *root, char *data, 
u32 seed, size_t len)
return crc32c(seed, data, len);
 }
 
-void btrfs_csum_final(u32 crc, char *result)
+void btrfs_csum_final(u32 crc, u8 *result)
 {
put_unaligned_le32(~crc, result);
 }
@@ -131,7 +131,7 @@ void btrfs_csum_final(u32 crc, char *result)
 static int __csum_tree_block_size(struct extent_buffer *buf, u16 csum_size,
  int verify, int silent)
 {
-   char result[BTRFS_CSUM_SIZE];
+   u8 result[BTRFS_CSUM_SIZE];
u32 len;
u32 crc = ~(u32)0;
 
@@ -1423,7 +1423,7 @@ struct btrfs_root *open_ctree_fd(int fp, const char 
*path, u64 sb_bytenr,
  */
 static int check_super(struct btrfs_super_block *sb, unsigned sbflags)
 {
-   char result[BTRFS_CSUM_SIZE];
+   u8 result[BTRFS_CSUM_SIZE];
u32 crc;
u16 csum_type;
int csum_size;
@@ -1647,7 +1647,7 @@ static int write_dev_supers(struct btrfs_root *root,
crc = ~(u32)0;
crc = btrfs_csum_data(NULL, (char *)sb + BTRFS_CSUM_SIZE, crc,
  BTRFS_SUPER_INFO_SIZE - BTRFS_CSUM_SIZE);
-   btrfs_csum_final(crc, (char *)&sb->csum[0]);
+   btrfs_csum_final(crc, &sb->csum[0]);
 
/*
 * super_copy is BTRFS_SUPER_INFO_SIZE bytes and is
@@ -1671,7 +1671,7 @@ static int write_dev_supers(struct btrfs_root *root,
crc = ~(u32)0;
crc = btrfs_csum_data(NULL, (char *)sb + BTRFS_CSUM_SIZE, crc,
  BTRFS_SUPER_INFO_SIZE - BTRFS_CSUM_SIZE);
-   btrfs_csum_final(crc, (char *)&sb->csum[0]);
+   btrfs_csum_final(crc, &sb->csum[0]);
 
/*
 * super_copy is BTRFS_SUPER_INFO_SIZE bytes and is
diff --git a/disk-io.h b/disk-io.h
index c404d3f..1080fc1 100644
--- a/disk-io.h
+++ b/disk-io.h
@@ -175,7 +175,7 @@ int btrfs_set_buffer_uptodate(struct extent_buffer *buf);
 int wait_on_tree_block_writeback(struct btrfs_root *root,
 struct extent_buffer *buf);
 u32 btrfs_csum_data(struct btrfs_root *root, char *data, u32 seed, size_t len);
-void btrfs_csum_final(u32 crc, char *result);
+void btrfs_csum_final(u32 crc, u8 *result);
 
 int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
 struct btrfs_root *root);
diff --git a/file-item.c b/file-item.c
index 7a3bbf3..dc3d404 100644
--- a/file-item.c
+++ b/file-item.c
@@

[PATCH] btrfs-progs: change btrfs_csum_final result param type to u8

2016-09-17 Thread Domagoj Tršan
csum member of struct btrfs_super_block has array type of u8. It makes sense
that function btrfs_csum_final should be also declared to accept u8 *. I
changed the declaration of method void btrfs_csum_final(u32 crc, char *result);
to void btrfs_csum_final(u32 crc, u8 *result);
Also, I changed definitions of various csum variables to be consistent with
kernel code. In kernel code they are defined as u8 result[BTRFS_CSUM_SIZE] but
here was as char result[BTRFS_CSUM_SIZE].

Domagoj Tršan (1):
  btrfs-progs: change btrfs_csum_final result param type to u8

 btrfs-image.c |  2 +-
 chunk-recover.c   |  2 +-
 cmds-check.c  |  2 +-
 cmds-inspect-dump-super.c |  2 +-
 disk-io.c | 10 +-
 disk-io.h |  2 +-
 file-item.c   |  2 +-
 free-space-cache.c|  2 +-
 super-recover.c   |  2 +-
 utils.c   |  2 +-
 10 files changed, 14 insertions(+), 14 deletions(-)

-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html