[haiku-commits] Re: haiku: hrev51672 - headers/private/graphics/common src/add-ons/media/plugins/ffmpeg src/add-ons/kernel/file_systems/btrfs src/add-ons/kernel/file_systems/userlandfs/kernel_add_on
- From: Hy Che <cvghy116@xxxxxxxxx>
- To: haiku-commits@xxxxxxxxxxxxx
- Date: Fri, 15 Dec 2017 06:09:18 +0700
btrfs: [] on the end of a struct field is a variable length array.
This throws an error in Clang, so just declare these as pointers.
diff --git a/src/add-ons/kernel/file_systems/btrfs/btrfs.h
b/src/add-ons/kernel/file_systems/btrfs/btrfs.h
index 57058f5..3d0e7bf 100644
--- a/src/add-ons/kernel/file_systems/btrfs/btrfs.h
+++ b/src/add-ons/kernel/file_systems/btrfs/btrfs.h
@@ -356,8 +356,8 @@ struct btrfs_dir_entry {
uint16 data_length;
uint16 name_length;
uint8 type;
- uint8 name[];
- uint8 data[]; // attribute data
+ uint8* name;
+ uint8* data; // attribute data
uint16 DataLength() const { return
B_LENDIAN_TO_HOST_INT16(data_length); }
uint16 NameLength() const { return
B_LENDIAN_TO_HOST_INT16(name_length); }
I understand why this causes error, because there are two flexible
array members in the struct when it should be one. This place is not
the only place using flexible array member, you can see here
(cgit.haiku-os.org/haiku/tree/src/add-ons/kernel/file_systems/btrfs/btrfs.h#n319)
Also the change is wrong because the structure read data from disk, it
stores data in an array thus name cannot be read correctly.
I will make a patch to fix this later
Other related posts: