Skip to content

Commit 4d69c58

Browse files
GustavoARSilvajankara
authored andcommitted
fsnotify: Avoid -Wflex-array-member-not-at-end warning
Use the `DEFINE_FLEX()` helper for an on-stack definition of a flexible structure where the size of the flexible-array member is known at compile-time, and refactor the rest of the code, accordingly. So, with these changes, fix the following warning: fs/notify/fdinfo.c:45:36: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end] Link: KSPP#202 Signed-off-by: Gustavo A. R. Silva <[email protected]> Signed-off-by: Jan Kara <[email protected]> Message-Id: <ZgImguNzJBiis9Mj@neat>
1 parent e659522 commit 4d69c58

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

fs/notify/fdinfo.c

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,29 +41,25 @@ static void show_fdinfo(struct seq_file *m, struct file *f,
4141
#if defined(CONFIG_EXPORTFS)
4242
static void show_mark_fhandle(struct seq_file *m, struct inode *inode)
4343
{
44-
struct {
45-
struct file_handle handle;
46-
u8 pad[MAX_HANDLE_SZ];
47-
} f;
44+
DEFINE_FLEX(struct file_handle, f, f_handle, handle_bytes, MAX_HANDLE_SZ);
4845
int size, ret, i;
4946

50-
f.handle.handle_bytes = sizeof(f.pad);
51-
size = f.handle.handle_bytes >> 2;
47+
size = f->handle_bytes >> 2;
5248

53-
ret = exportfs_encode_fid(inode, (struct fid *)f.handle.f_handle, &size);
49+
ret = exportfs_encode_fid(inode, (struct fid *)f->f_handle, &size);
5450
if ((ret == FILEID_INVALID) || (ret < 0)) {
5551
WARN_ONCE(1, "Can't encode file handler for inotify: %d\n", ret);
5652
return;
5753
}
5854

59-
f.handle.handle_type = ret;
60-
f.handle.handle_bytes = size * sizeof(u32);
55+
f->handle_type = ret;
56+
f->handle_bytes = size * sizeof(u32);
6157

6258
seq_printf(m, "fhandle-bytes:%x fhandle-type:%x f_handle:",
63-
f.handle.handle_bytes, f.handle.handle_type);
59+
f->handle_bytes, f->handle_type);
6460

65-
for (i = 0; i < f.handle.handle_bytes; i++)
66-
seq_printf(m, "%02x", (int)f.handle.f_handle[i]);
61+
for (i = 0; i < f->handle_bytes; i++)
62+
seq_printf(m, "%02x", (int)f->f_handle[i]);
6763
}
6864
#else
6965
static void show_mark_fhandle(struct seq_file *m, struct inode *inode)

0 commit comments

Comments
 (0)