Gustavo A. R. Silva
c0a744dcaa
UAPI: nfsfh.h: Replace one-element 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].
Use an anonymous union with a couple of anonymous structs in order to
keep userspace unchanged:
$ pahole -C nfs_fhbase_new fs/nfsd/nfsfh.o
struct nfs_fhbase_new {
union {
struct {
__u8 fb_version_aux; /* 0 1 */
__u8 fb_auth_type_aux; /* 1 1 */
__u8 fb_fsid_type_aux; /* 2 1 */
__u8 fb_fileid_type_aux; /* 3 1 */
__u32 fb_auth[1]; /* 4 4 */
}; /* 0 8 */
struct {
__u8 fb_version; /* 0 1 */
__u8 fb_auth_type; /* 1 1 */
__u8 fb_fsid_type; /* 2 1 */
__u8 fb_fileid_type; /* 3 1 */
__u32 fb_auth_flex[0]; /* 4 0 */
}; /* 0 4 */
}; /* 0 8 */
/* size: 8, cachelines: 1, members: 1 */
/* last cacheline: 8 bytes */
};
Also, this helps with the ongoing efforts to enable -Warray-bounds by
fixing the following warnings:
fs/nfsd/nfsfh.c: In function ‘nfsd_set_fh_dentry’:
fs/nfsd/nfsfh.c:191:41: warning: array subscript 1 is above array bounds of ‘__u32[1]’ {aka ‘unsigned int[1]’} [-Warray-bounds]
191 | ntohl((__force __be32)fh->fh_fsid[1])));
| ~~~~~~~~~~~^~~
./include/linux/kdev_t.h:12:46: note: in definition of macro ‘MKDEV’
12 | #define MKDEV(ma,mi) (((ma) << MINORBITS) | (mi))
| ^~
./include/uapi/linux/byteorder/little_endian.h:40:26: note: in expansion of macro ‘__swab32’
40 | #define __be32_to_cpu(x) __swab32((__force __u32)(__be32)(x))
| ^~~~~~~~
./include/linux/byteorder/generic.h:136:21: note: in expansion of macro ‘__be32_to_cpu’
136 | #define ___ntohl(x) __be32_to_cpu(x)
| ^~~~~~~~~~~~~
./include/linux/byteorder/generic.h:140:18: note: in expansion of macro ‘___ntohl’
140 | #define ntohl(x) ___ntohl(x)
| ^~~~~~~~
fs/nfsd/nfsfh.c:191:8: note: in expansion of macro ‘ntohl’
191 | ntohl((__force __be32)fh->fh_fsid[1])));
| ^~~~~
fs/nfsd/nfsfh.c:192:32: warning: array subscript 2 is above array bounds of ‘__u32[1]’ {aka ‘unsigned int[1]’} [-Warray-bounds]
192 | fh->fh_fsid[1] = fh->fh_fsid[2];
| ~~~~~~~~~~~^~~
fs/nfsd/nfsfh.c:192:15: warning: array subscript 1 is above array bounds of ‘__u32[1]’ {aka ‘unsigned int[1]’} [-Warray-bounds]
192 | fh->fh_fsid[1] = fh->fh_fsid[2];
| ~~~~~~~~~~~^~~
[1] https://en.wikipedia.org/wiki/Flexible_array_member
[2] https://www.kernel.org/doc/html/v5.10/process/deprecated.html#zero-length-and-one-element-arrays
Link: https://github.com/KSPP/linux/issues/79
Link: https://github.com/KSPP/linux/issues/109
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2021-03-31 15:59:14 -04:00
..
2020-12-09 15:41:21 +01:00
2020-07-15 20:34:11 -07:00
2020-12-10 09:31:40 +01:00
2020-12-14 09:16:22 -06:00
2019-06-05 10:55:30 -04:00
2020-01-21 11:41:36 +01:00
2020-08-22 10:53:12 +01:00
2019-09-07 17:44:25 +02:00
2021-01-25 18:44:44 +01:00
2020-05-28 11:22:14 +02:00
2021-02-28 00:24:41 +01:00
2019-10-04 14:25:17 -07:00
2020-05-04 11:30:15 -05:00
2019-10-04 14:25:17 -07:00
2019-10-04 14:25:17 -07:00
2021-03-31 15:59:14 -04:00
2020-07-21 22:05:32 -07:00
2020-11-19 11:25:47 +01:00
2020-12-28 14:21:31 +00:00
2021-01-07 00:06:39 +01:00
2020-10-03 17:28:45 -07:00
2021-01-18 18:38:47 +01:00
2019-12-18 18:07:31 +01:00
2021-02-09 10:58:19 +01:00
2019-06-26 20:14:13 -04:00
2019-04-25 19:33:34 +02:00
2020-07-13 17:01:44 -07:00
2020-07-21 11:21:44 -04:00
2020-08-12 10:58:00 -07:00
2019-03-07 18:32:01 -08:00
2021-02-06 09:22:10 +01:00
2021-02-06 09:22:10 +01:00
2021-01-09 09:21:03 -07:00
2021-02-15 18:28:30 +01:00
2020-10-09 12:47:02 -06:00
2021-02-24 17:20:21 +01:00
2019-07-25 11:05:10 +02:00
2020-01-10 17:20:07 +01:00
2020-12-09 19:16:10 +01:00
2020-12-08 15:54:16 +01:00
2020-11-20 09:43:29 +01:00
2020-09-01 19:38:33 -06:00
2021-01-12 17:31:14 +01:00
2020-10-02 17:58:52 -06:00
2019-10-07 07:55:17 -03:00
2019-10-01 17:19:41 -03:00
2020-10-29 18:39:43 -07:00
2019-10-09 22:31:14 -04:00
2020-12-04 12:06:15 +01:00
2019-07-16 19:23:23 -07:00
2019-09-25 17:51:39 -07:00
2020-12-15 12:13:36 -08:00
2020-09-17 18:46:04 +02:00
2019-08-02 14:44:02 +10:00
2021-02-16 20:36:39 -08:00
2019-11-15 14:38:29 +01:00
2019-10-28 13:41:01 -07:00
2021-01-22 11:32:08 -08:00
2020-05-04 11:30:15 -05:00
2021-02-11 09:45:25 -05:00
2020-04-27 16:29:41 +05:30
2019-12-17 21:37:40 +05:30
2020-09-10 09:10:06 +02:00
2019-03-20 21:11:22 -04:00
2020-09-04 12:46:07 +01:00
2020-07-19 19:20:22 -07:00
2021-02-03 18:37:28 -08:00
2020-12-15 12:13:36 -08:00
2020-12-03 00:12:08 -08:00
2020-07-27 23:24:00 +02:00
2020-06-24 21:34:11 +02:00
2020-05-14 16:44:25 +02:00
2020-05-12 19:34:57 +03:00
2020-05-12 19:34:52 +03:00
2020-06-05 16:19:28 -07:00
2021-02-26 09:41:03 -08:00
2019-03-27 13:30:07 -07:00
2020-07-06 21:37:08 -07:00
2020-05-28 22:09:47 -04:00
2020-11-16 11:41:12 -08:00
2021-01-27 15:13:52 +01:00
2021-02-07 14:51:19 -08:00
2021-03-16 15:20:16 +01:00
2019-11-05 18:20:55 -08:00
2020-10-03 14:18:29 -07:00
2021-02-08 13:01:24 +01:00
2021-02-15 11:43:33 +01:00
2019-09-04 12:43:54 +02:00
2021-02-04 09:29:57 -08:00
2020-11-27 15:48:31 +01:00
2020-07-27 12:20:40 -07:00
2020-07-23 17:55:20 +00:00
2021-01-22 09:58:57 +01:00
2021-01-22 09:59:00 +01:00
2020-07-19 19:20:22 -07:00
2020-10-31 13:16:02 -07:00
2020-12-11 19:45:53 +05:30
2020-11-06 14:29:11 +11:00
2020-05-04 11:30:15 -05:00
2021-01-19 19:30:32 -08:00
2020-10-30 17:49:19 -07:00
2020-10-29 18:39:43 -07:00
2021-02-04 09:29:57 -08:00
2020-03-16 01:42:31 -07:00
2020-11-09 16:41:40 -08:00
2020-08-22 12:44:37 -07:00
2019-03-21 13:19:15 -07:00
2021-02-04 09:29:57 -08:00
2019-04-19 13:58:17 -07:00
2020-05-01 12:24:40 -07:00
2020-07-13 15:32:56 -07:00
2020-04-20 12:43:24 -07:00
2019-01-22 17:18:09 -08:00
2020-07-24 17:12:41 -07:00
2020-08-27 07:55:59 -07:00
2020-09-03 15:17:28 -07:00
2020-09-08 16:31:14 -07:00
2021-02-26 09:41:03 -08:00
2021-02-23 20:32:11 -07:00
2020-10-01 14:52:46 +02:00
2019-07-04 02:29:49 +02:00
2019-07-25 11:05:10 +02:00
2020-09-15 09:57:45 -05:00
2021-01-26 18:39:45 -08:00
2020-07-27 16:34:12 +03:00
2019-08-22 17:24:51 +02:00
2020-01-04 13:55:09 -08:00
2020-11-16 16:27:03 +01:00
2019-03-05 21:07:14 -08:00
2020-12-15 12:13:36 -08:00
2019-09-08 15:37:04 +02:00
2020-11-04 16:43:38 +01:00
2020-05-19 15:19:06 +01:00
2020-08-31 14:40:29 -04:00
2019-07-02 18:56:01 +02:00
2021-03-02 14:30:54 -05:00
2021-03-03 16:55:02 -08:00
2020-12-15 12:13:36 -08:00
2019-03-07 18:31:59 -08:00
2020-11-26 14:19:10 +01:00
2020-05-21 08:20:35 -06:00
2020-03-29 22:30:57 -07:00
2020-05-27 11:10:05 +02:00
2021-02-09 12:27:32 +01:00
2020-07-19 18:05:49 -07:00
2020-12-14 11:47:37 -08:00
2021-01-12 17:05:37 +01:00
2020-08-18 15:44:44 +02:00
2020-09-25 14:23:27 +02:00
2021-02-24 13:38:34 -08:00
2020-05-06 17:45:45 -07:00
2020-09-15 22:13:31 +10:00
2021-01-24 14:43:45 +01:00
2021-02-15 15:09:14 -08:00
2020-12-15 12:13:36 -08:00
2020-09-10 12:25:51 -07:00
2021-01-23 12:38:42 -08:00
2019-11-15 14:38:29 +01:00
2020-07-25 19:34:47 -06:00
2020-06-24 14:36:33 -07:00
2020-05-04 11:30:15 -05:00
2020-03-29 22:32:36 -07:00
2020-10-14 20:28:05 -07:00
2020-12-15 12:13:36 -08:00
2020-05-22 14:00:38 -07:00
2021-01-25 09:36:25 -05:00
2020-10-16 09:28:43 -04:00
2020-07-13 17:52:46 -04:00
2019-04-25 14:18:14 -04:00
2020-10-02 09:37:41 -04:00
2019-07-12 11:05:40 -07:00
2020-09-22 13:58:40 +02:00
2021-02-12 11:00:07 +01:00
2019-11-06 06:17:38 +09:00
2021-01-04 11:42:26 -05:00
2020-11-27 11:03:06 -08:00
2020-12-15 16:49:59 -08:00
2020-04-02 17:57:10 +01:00
2021-02-21 12:49:32 -08:00
2019-10-02 20:32:27 -06:00
2020-09-04 12:34:50 +02:00
2021-02-16 17:51:13 -08:00
2021-01-22 20:41:29 -08:00
2019-01-22 10:21:45 +01:00
2019-07-30 20:34:34 +02:00
2019-12-01 14:00:59 -08:00
2020-12-21 17:36:48 -08:00
2021-02-06 00:21:42 +01:00
2020-05-21 17:04:07 -07:00
2019-04-16 23:05:21 +02:00
2020-04-30 15:19:33 +10:00
2020-07-19 19:22:56 -07:00
2020-08-18 13:39:23 +02:00
2020-01-07 16:07:01 -05:00
2020-07-10 14:50:51 +02:00
2020-06-25 16:26:25 -07:00
2020-08-04 20:16:37 -07:00
2019-11-15 14:38:29 +01:00
2020-12-11 12:47:17 +01:00
2021-01-28 11:31:43 +01:00
2020-03-29 22:30:57 -07:00
2021-01-25 15:14:16 -08:00
2020-11-24 10:10:59 -06:00
2021-01-16 23:19:26 +01:00
2021-02-08 16:47:02 -08:00
2020-10-05 16:35:57 +01:00
2019-12-04 19:44:12 -08:00
2020-02-12 17:57:51 -05:00
2020-10-30 15:24:11 -07:00
2020-07-14 16:29:42 -07:00
2019-11-04 07:11:31 -07:00
2020-08-03 17:57:40 -07:00
2020-12-04 13:30:50 -08:00
2019-11-15 14:38:29 +01:00
2021-01-15 17:14:49 +01:00
2020-03-24 15:59:34 -07:00
2019-11-15 14:38:29 +01:00
2020-12-01 17:56:13 -08:00
2020-11-09 15:34:44 -08:00
2020-02-27 18:50:19 -08:00
2019-08-03 11:02:46 -07:00
2019-04-19 14:07:40 -07:00
2020-12-03 10:03:14 -08:00
2020-02-21 11:22:15 -08:00
2020-01-15 11:00:39 -06:00
2021-01-26 18:39:45 -08:00
2020-07-28 22:25:30 -04:00
2019-12-18 18:07:31 +01:00
2021-02-11 18:25:05 -08:00
2021-02-02 14:50:15 +01:00
2021-01-07 16:17:32 +01:00
2020-07-07 15:55:21 +02:00
2019-12-18 18:07:33 +01:00
2020-02-21 11:22:15 -08:00
2019-12-18 18:07:33 +01:00
2019-10-04 14:25:17 -07:00
2020-09-18 13:58:37 -07:00
2020-09-18 13:58:37 -07:00
2020-11-27 14:32:37 -08:00
2020-08-12 10:57:59 -07:00
2019-12-09 09:59:07 +01:00
2020-03-29 23:29:08 +02:00
2019-05-22 10:36:35 -07:00
2019-08-14 16:52:13 +02:00
2020-12-15 12:13:46 -08:00
2019-11-15 14:38:29 +01:00
2021-01-14 13:54:00 +01:00
2020-09-26 10:22:29 +02:00
2021-01-26 19:14:33 +01:00
2020-07-10 13:45:32 +02:00
2020-07-10 13:45:32 +02:00
2021-02-23 07:52:56 -05:00
2020-06-03 11:27:43 +02:00
2020-10-07 14:23:44 -06:00
2021-02-01 13:20:06 -07:00
2020-10-23 11:55:28 -04:00
2020-10-23 11:55:28 -04:00
2020-12-07 14:02:37 +01:00
2020-08-05 09:30:19 -04:00
2020-08-05 09:30:20 -04:00
2020-08-05 11:08:39 -04:00
2020-08-03 16:11:42 -04:00
2020-08-05 11:08:39 -04:00
2020-08-05 11:08:39 -04:00
2020-09-10 11:39:22 +02:00
2020-11-20 10:44:41 +01:00
2020-12-18 16:14:31 -05:00
2020-08-05 11:08:40 -04:00
2020-08-05 11:08:40 -04:00
2020-08-05 11:08:40 -04:00
2020-09-10 10:05:58 +02:00
2020-08-05 11:08:41 -04:00
2020-09-10 10:05:58 +02:00
2020-08-05 11:08:40 -04:00
2020-06-02 02:45:13 -04:00
2020-08-05 11:08:40 -04:00
2020-12-14 19:33:39 -08:00
2019-07-25 11:05:10 +02:00
2019-08-01 21:49:46 +02:00
2020-05-19 15:19:06 +01:00
2019-12-16 19:22:22 -08:00
2020-07-31 09:24:23 +02:00
2019-07-25 11:05:10 +02:00
2020-06-12 13:23:34 -04:00
2020-07-13 15:32:56 -07:00
2020-06-24 07:51:01 +02:00