Gustavo A. R. Silva
bb4cf02d4c
netdevice: Replace zero-length array with flexible-array member
...
The current codebase makes use of the zero-length array language
extension to the C90 standard, but the preferred mechanism to declare
variable-length types such as these ones is a flexible array member[1][2],
introduced in C99:
struct foo {
int stuff;
struct boo array[];
};
By making use of the mechanism above, we will get a compiler warning
in case the flexible array does not occur last in the structure, which
will help us prevent some kind of undefined behavior bugs from being
inadvertently introduced[3] to the codebase from now on.
Also, notice that, dynamic memory allocations won't be affected by
this change:
"Flexible array members have incomplete type, and so the sizeof operator
may not be applied. As a quirk of the original implementation of
zero-length arrays, sizeof evaluates to zero."[1]
This issue was found with the help of Coccinelle.
[1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
[2] https://github.com/KSPP/linux/issues/21
[3] commit 7649773293 ("cxgb3/l2t: Fix undefined behaviour")
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com >
Signed-off-by: David S. Miller <davem@davemloft.net >
2020-03-02 11:16:27 -08:00
..
2019-08-09 09:15:05 +02:00
2020-02-08 13:26:41 -08:00
2019-11-27 08:15:00 -08:00
2020-01-21 11:06:12 +05:30
2020-02-08 14:04:19 -08:00
2020-02-16 18:30:41 -08:00
2020-01-29 09:51:36 -08:00
2020-02-08 10:01:33 +00:00
2020-02-04 07:17:41 +00:00
2020-01-31 14:40:36 -08:00
2020-02-27 16:40:05 -08:00
2020-01-28 16:02:33 -08:00
2020-01-27 17:49:15 +01:00
2020-02-22 12:00:06 +01:00
2019-12-30 14:27:53 +01:00
2020-02-08 17:15:08 -08:00
2019-12-19 01:07:53 +01:00
2020-01-27 14:35:32 +01:00
2020-01-13 11:44:09 -08:00
2020-01-20 10:29:56 -08:00
2020-01-20 10:29:56 -08:00
2020-02-15 12:51:22 -08:00
2020-02-08 14:04:19 -08:00
2020-01-23 12:37:18 +00:00
2020-02-07 17:39:56 -08:00
2020-02-10 11:14:22 -08:00
2020-01-24 21:03:53 +01:00
2019-06-05 17:37:17 +02:00
2020-01-31 10:30:36 -08:00
2020-02-04 03:05:26 +00:00
2020-02-04 03:05:26 +00:00
2020-01-29 18:16:16 -08:00
2020-02-20 17:52:34 -05:00
2020-01-22 23:04:52 +01:00
2020-02-28 01:21:02 +01:00
2020-02-27 18:50:19 -08:00
2020-01-22 23:04:52 +01:00
2020-01-31 13:14:26 -08:00
2020-01-27 10:24:32 +01:00
2020-02-21 11:22:15 -08:00
2019-06-12 20:27:13 +02:00
2020-01-21 13:28:24 +01:00
2018-04-11 10:28:38 -07:00
2019-09-04 13:38:26 +02:00
2020-01-27 19:59:55 +01:00
2020-01-27 10:24:32 +01:00
2019-06-05 17:36:37 +02:00
2020-02-03 16:56:48 +01:00
2020-02-08 14:04:19 -08:00
2020-01-23 00:35:50 +01:00
2020-02-04 03:05:27 +00:00
2020-02-28 12:08:37 -08:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2019-11-25 11:53:26 -08:00
2020-02-26 20:07:25 -08:00
2020-01-27 10:55:50 -08:00
2019-10-22 12:54:44 -07:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2019-10-17 16:23:25 +02:00
2020-01-27 11:09:31 +01:00
2020-02-29 21:48:54 -08:00
2020-02-03 17:27:38 -07:00
2020-01-29 15:45:47 -07:00
2019-10-17 16:44:36 +02:00
2020-01-13 14:15:27 +09:00
2020-02-24 16:20:09 -08:00
2020-02-07 14:48:39 -05:00
2020-02-07 14:48:38 -05:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2020-02-08 13:26:41 -08:00
2020-01-22 14:50:03 -08:00
2020-01-28 10:07:09 -08:00
2017-11-02 11:10:55 +01:00
2020-02-12 14:18:33 +01:00
2020-01-27 20:00:01 +01:00
2020-01-23 13:15:09 -08:00
2020-01-26 22:10:17 -05:00
2020-02-25 11:01:39 -08:00
2020-01-30 07:39:10 -08:00
2020-02-14 09:59:24 +01:00
2020-01-22 15:22:51 -05:00
2020-02-27 18:50:19 -08:00
2019-08-28 11:50:33 +02:00
2019-07-04 22:01:59 -04:00
2019-12-12 18:58:24 +01:00
2019-06-19 17:09:55 +02:00
2020-02-10 10:41:20 +01:00
2020-01-31 10:30:41 -08:00
2020-01-24 15:39:39 +01:00
2020-02-01 09:31:47 +01:00
2020-02-21 11:29:15 +01:00
2020-01-25 03:01:56 -05:00
2020-01-31 17:33:54 +00:00
2020-02-20 21:17:24 +01:00
2019-05-24 17:27:11 +02:00
2019-06-05 17:37:16 +02:00
2020-02-21 11:22:15 -08:00
2020-02-17 12:52:38 +01:00
2020-01-30 18:45:55 +01:00
2020-02-06 06:11:50 +00:00
2018-01-11 14:39:07 -06:00
2020-02-16 19:39:44 -08:00
2020-01-28 08:46:13 -08:00
2019-11-01 13:08:19 +01:00
2019-04-02 09:50:48 +02:00
2019-06-19 17:09:55 +02:00
2020-01-31 10:30:38 -08:00
2020-02-04 03:05:23 +00:00
2020-01-31 10:30:39 -08:00
2019-08-20 09:35:03 -03:00
2019-05-14 09:47:46 -07:00
2020-02-04 07:21:04 +00:00
2020-02-04 07:24:48 +00:00
2020-02-04 03:05:23 +00:00
2020-02-01 10:01:52 -08:00
2019-12-09 10:55:03 +01:00
2017-11-02 11:10:55 +01:00
2020-01-29 11:20:24 -08:00
2020-01-27 11:00:21 +01:00
2020-03-02 11:16:27 -08:00
2020-02-27 18:50:19 -08:00
2020-02-12 13:55:25 -05:00
2020-01-24 16:51:13 -05:00
2019-07-18 17:08:06 -07:00
2020-02-05 14:52:03 -08:00
2019-12-11 16:37:02 +08:00
2020-01-31 10:30:39 -08:00
2020-02-04 03:05:25 +00:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2020-01-29 17:00:02 -06:00
2020-01-31 11:15:59 -08:00
2020-01-20 17:04:02 -07:00
2020-02-09 12:04:09 -08:00
2020-02-24 15:31:23 -08:00
2020-02-27 12:02:14 -08:00
2019-11-15 23:49:22 +01:00
2020-02-12 11:54:08 -08:00
2019-11-13 11:41:50 +01:00
2020-01-23 13:15:09 -08:00
2019-05-24 17:36:45 +02:00
2020-02-20 21:17:24 +01:00
2017-11-02 11:10:55 +01:00
2020-02-04 03:05:26 +00:00
2020-01-29 11:20:24 -08:00
2019-06-15 12:25:49 +02:00
2020-02-04 03:05:25 +00:00
2019-12-30 20:31:40 -08:00
2020-02-07 14:48:37 -05:00
2020-01-25 12:18:50 -05:00
2020-01-24 10:24:31 -08:00
2020-02-17 10:55:14 +01:00
2020-01-24 10:37:27 -08:00
2020-01-24 10:24:31 -08:00
2020-01-24 10:24:31 -08:00
2020-01-20 16:19:10 +01:00
2018-06-15 13:37:07 +02:00
2017-11-02 11:10:55 +01:00
2019-09-16 11:43:38 -05:00
2018-07-25 11:22:19 +02:00
2018-09-25 20:17:35 -07:00
2020-01-29 19:38:34 -08:00
2019-04-19 15:09:10 +02:00
2019-11-14 13:15:12 -05:00
2020-02-04 03:05:26 +00:00
2019-06-05 17:36:37 +02:00
2017-11-02 11:10:55 +01:00
2020-02-07 14:48:37 -05:00
2019-05-30 11:26:32 -07:00
2020-02-28 12:12:53 -08:00
2020-02-21 22:29:45 +01:00
2020-02-04 03:05:24 +00:00
2020-01-24 20:40:09 +01:00
2019-12-03 07:04:30 -07:00
2019-03-26 14:39:24 -07:00
2019-07-25 15:43:26 +02:00
2018-10-09 11:20:55 +02:00
2019-07-03 17:52:50 -04:00
2020-02-04 03:05:26 +00:00
2018-04-28 15:01:14 -07:00
2009-04-10 15:48:52 +02:00
2017-11-02 11:10:55 +01:00
2020-02-11 10:11:02 +01:00
2020-01-31 10:30:40 -08:00
2020-02-05 18:53:05 +01:00
2018-02-05 21:34:50 +01:00
2017-08-18 14:07:26 -03:00
2020-01-29 19:38:34 -08:00
2019-12-04 19:44:11 -08:00
2020-02-26 20:07:25 -08:00
2017-11-02 11:10:55 +01:00
2020-01-29 17:45:20 +01:00
2020-01-31 10:30:40 -08:00
2020-02-21 11:22:15 -08:00
2020-02-21 11:22:15 -08:00
2019-08-01 20:51:22 +02:00
2019-08-28 11:50:43 +02:00
2020-02-11 16:39:18 -08:00
2020-02-10 12:26:44 -08:00
2020-02-21 11:22:15 -08:00
2019-06-19 23:45:09 -04:00
2020-01-31 10:30:39 -08:00
2019-12-10 10:12:55 +01:00
2017-11-02 11:10:55 +01:00
2019-05-15 17:35:54 +01:00
2019-10-31 15:12:23 +00:00
2019-09-13 21:15:39 +10:00
2019-08-27 09:22:38 -06:00
2020-01-17 22:33:37 -05:00
2020-01-31 10:30:40 -08:00