Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

fs: Replace zero-length array with flexible-array member

There is a regular need in the kernel to provide a way to declare having a
dynamically sized set of trailing elements in a structure. Kernel code should
always use “flexible array members”[1] for these cases. The older style of
one-element or zero-length arrays should no longer be used[2].

[1] https://en.wikipedia.org/wiki/Flexible_array_member
[2] https://www.kernel.org/doc/html/v5.9-rc1/process/deprecated.html#zero-length-and-one-element-arrays

Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>

+10 -10
+1 -1
fs/binfmt_elf.c
··· 1690 1690 struct elf_thread_core_info *next; 1691 1691 struct task_struct *task; 1692 1692 struct elf_prstatus prstatus; 1693 - struct memelfnote notes[0]; 1693 + struct memelfnote notes[]; 1694 1694 }; 1695 1695 1696 1696 struct elf_note_info {
+1 -1
fs/hfs/btree.h
··· 60 60 wait_queue_head_t lock_wq; 61 61 atomic_t refcnt; 62 62 unsigned int page_offset; 63 - struct page *page[0]; 63 + struct page *page[]; 64 64 }; 65 65 66 66 #define HFS_BNODE_ERROR 0
+1 -1
fs/hfsplus/hfsplus_fs.h
··· 117 117 wait_queue_head_t lock_wq; 118 118 atomic_t refcnt; 119 119 unsigned int page_offset; 120 - struct page *page[0]; 120 + struct page *page[]; 121 121 }; 122 122 123 123 #define HFS_BNODE_LOCK 0
+4 -4
fs/isofs/rock.h
··· 22 22 __u8 len_des; 23 23 __u8 len_src; 24 24 __u8 ext_ver; 25 - __u8 data[0]; 25 + __u8 data[]; 26 26 } __attribute__ ((packed)); 27 27 28 28 struct RR_RR_s { ··· 44 44 struct SL_component { 45 45 __u8 flags; 46 46 __u8 len; 47 - __u8 text[0]; 47 + __u8 text[]; 48 48 } __attribute__ ((packed)); 49 49 50 50 struct RR_SL_s { ··· 54 54 55 55 struct RR_NM_s { 56 56 __u8 flags; 57 - char name[0]; 57 + char name[]; 58 58 } __attribute__ ((packed)); 59 59 60 60 struct RR_CL_s { ··· 71 71 72 72 struct RR_TF_s { 73 73 __u8 flags; 74 - struct stamp times[0]; /* Variable number of these beasts */ 74 + struct stamp times[]; /* Variable number of these beasts */ 75 75 } __attribute__ ((packed)); 76 76 77 77 /* Linux-specific extension for transparent decompression */
+2 -2
fs/select.c
··· 97 97 struct poll_table_page { 98 98 struct poll_table_page * next; 99 99 struct poll_table_entry * entry; 100 - struct poll_table_entry entries[0]; 100 + struct poll_table_entry entries[]; 101 101 }; 102 102 103 103 #define POLL_TABLE_FULL(table) \ ··· 836 836 struct poll_list { 837 837 struct poll_list *next; 838 838 int len; 839 - struct pollfd entries[0]; 839 + struct pollfd entries[]; 840 840 }; 841 841 842 842 #define POLLFD_PER_PAGE ((PAGE_SIZE-sizeof(struct poll_list)) / sizeof(struct pollfd))
+1 -1
include/linux/fs.h
··· 3285 3285 */ 3286 3286 struct simple_transaction_argresp { 3287 3287 ssize_t size; 3288 - char data[0]; 3288 + char data[]; 3289 3289 }; 3290 3290 3291 3291 #define SIMPLE_TRANSACTION_LIMIT (PAGE_SIZE - sizeof(struct simple_transaction_argresp))