* [PATCH][next] drm: i915_drm.h: Replace zero-length array with flexible-array member
@ 2020-03-03 22:06 ` Gustavo A. R. Silva
0 siblings, 0 replies; 9+ messages in thread
From: Gustavo A. R. Silva @ 2020-03-03 22:06 UTC (permalink / raw)
To: Jani Nikula, Joonas Lahtinen, Rodrigo Vivi, David Airlie, Daniel Vetter
Cc: intel-gfx, dri-devel, linux-kernel, Gustavo A. R. Silva
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 76497732932f ("cxgb3/l2t: Fix undefined behaviour")
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
include/uapi/drm/i915_drm.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/uapi/drm/i915_drm.h b/include/uapi/drm/i915_drm.h
index 2813e579b480..413d923b332a 100644
--- a/include/uapi/drm/i915_drm.h
+++ b/include/uapi/drm/i915_drm.h
@@ -1729,7 +1729,7 @@ struct i915_context_engines_load_balance {
__u64 mbz64; /* reserved for future use; must be zero */
- struct i915_engine_class_instance engines[0];
+ struct i915_engine_class_instance engines[];
} __attribute__((packed));
#define I915_DEFINE_CONTEXT_ENGINES_LOAD_BALANCE(name__, N__) struct { \
@@ -1767,7 +1767,7 @@ struct i915_context_engines_bond {
__u64 flags; /* all undefined flags must be zero */
__u64 mbz64[4]; /* reserved for future use; must be zero */
- struct i915_engine_class_instance engines[0];
+ struct i915_engine_class_instance engines[];
} __attribute__((packed));
#define I915_DEFINE_CONTEXT_ENGINES_BOND(name__, N__) struct { \
--
2.25.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH][next] drm: i915_drm.h: Replace zero-length array with flexible-array member
@ 2020-03-03 22:06 ` Gustavo A. R. Silva
0 siblings, 0 replies; 9+ messages in thread
From: Gustavo A. R. Silva @ 2020-03-03 22:06 UTC (permalink / raw)
To: Jani Nikula, Joonas Lahtinen, Rodrigo Vivi, David Airlie, Daniel Vetter
Cc: intel-gfx, linux-kernel, dri-devel, Gustavo A. R. Silva
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 76497732932f ("cxgb3/l2t: Fix undefined behaviour")
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
include/uapi/drm/i915_drm.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/uapi/drm/i915_drm.h b/include/uapi/drm/i915_drm.h
index 2813e579b480..413d923b332a 100644
--- a/include/uapi/drm/i915_drm.h
+++ b/include/uapi/drm/i915_drm.h
@@ -1729,7 +1729,7 @@ struct i915_context_engines_load_balance {
__u64 mbz64; /* reserved for future use; must be zero */
- struct i915_engine_class_instance engines[0];
+ struct i915_engine_class_instance engines[];
} __attribute__((packed));
#define I915_DEFINE_CONTEXT_ENGINES_LOAD_BALANCE(name__, N__) struct { \
@@ -1767,7 +1767,7 @@ struct i915_context_engines_bond {
__u64 flags; /* all undefined flags must be zero */
__u64 mbz64[4]; /* reserved for future use; must be zero */
- struct i915_engine_class_instance engines[0];
+ struct i915_engine_class_instance engines[];
} __attribute__((packed));
#define I915_DEFINE_CONTEXT_ENGINES_BOND(name__, N__) struct { \
--
2.25.0
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [Intel-gfx] [PATCH][next] drm: i915_drm.h: Replace zero-length array with flexible-array member
@ 2020-03-03 22:06 ` Gustavo A. R. Silva
0 siblings, 0 replies; 9+ messages in thread
From: Gustavo A. R. Silva @ 2020-03-03 22:06 UTC (permalink / raw)
To: Jani Nikula, Joonas Lahtinen, Rodrigo Vivi, David Airlie, Daniel Vetter
Cc: intel-gfx, linux-kernel, dri-devel, Gustavo A. R. Silva
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 76497732932f ("cxgb3/l2t: Fix undefined behaviour")
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
include/uapi/drm/i915_drm.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/uapi/drm/i915_drm.h b/include/uapi/drm/i915_drm.h
index 2813e579b480..413d923b332a 100644
--- a/include/uapi/drm/i915_drm.h
+++ b/include/uapi/drm/i915_drm.h
@@ -1729,7 +1729,7 @@ struct i915_context_engines_load_balance {
__u64 mbz64; /* reserved for future use; must be zero */
- struct i915_engine_class_instance engines[0];
+ struct i915_engine_class_instance engines[];
} __attribute__((packed));
#define I915_DEFINE_CONTEXT_ENGINES_LOAD_BALANCE(name__, N__) struct { \
@@ -1767,7 +1767,7 @@ struct i915_context_engines_bond {
__u64 flags; /* all undefined flags must be zero */
__u64 mbz64[4]; /* reserved for future use; must be zero */
- struct i915_engine_class_instance engines[0];
+ struct i915_engine_class_instance engines[];
} __attribute__((packed));
#define I915_DEFINE_CONTEXT_ENGINES_BOND(name__, N__) struct { \
--
2.25.0
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [Intel-gfx] ✗ Fi.CI.DOCS: warning for drm: i915_drm.h: Replace zero-length array with flexible-array member
2020-03-03 22:06 ` Gustavo A. R. Silva
(?)
(?)
@ 2020-03-04 3:38 ` Patchwork
-1 siblings, 0 replies; 9+ messages in thread
From: Patchwork @ 2020-03-04 3:38 UTC (permalink / raw)
To: Gustavo A. R. Silva; +Cc: intel-gfx
== Series Details ==
Series: drm: i915_drm.h: Replace zero-length array with flexible-array member
URL : https://patchwork.freedesktop.org/series/74225/
State : warning
== Summary ==
$ make htmldocs 2>&1 > /dev/null | grep i915
./drivers/gpu/drm/i915/display/intel_dpll_mgr.h:285: warning: Function parameter or member 'get_freq' not described in 'intel_shared_dpll_funcs'
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Intel-gfx] ✓ Fi.CI.BAT: success for drm: i915_drm.h: Replace zero-length array with flexible-array member
2020-03-03 22:06 ` Gustavo A. R. Silva
` (2 preceding siblings ...)
(?)
@ 2020-03-04 3:47 ` Patchwork
-1 siblings, 0 replies; 9+ messages in thread
From: Patchwork @ 2020-03-04 3:47 UTC (permalink / raw)
To: Gustavo A. R. Silva; +Cc: intel-gfx
== Series Details ==
Series: drm: i915_drm.h: Replace zero-length array with flexible-array member
URL : https://patchwork.freedesktop.org/series/74225/
State : success
== Summary ==
CI Bug Log - changes from CI_DRM_8061 -> Patchwork_16809
====================================================
Summary
-------
**SUCCESS**
No regressions found.
External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16809/index.html
Known issues
------------
Here are the changes found in Patchwork_16809 that come from known issues:
### IGT changes ###
#### Issues hit ####
* igt@gem_exec_suspend@basic-s4-devices:
- fi-tgl-y: [PASS][1] -> [FAIL][2] ([CI#94])
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8061/fi-tgl-y/igt@gem_exec_suspend@basic-s4-devices.html
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16809/fi-tgl-y/igt@gem_exec_suspend@basic-s4-devices.html
* igt@kms_addfb_basic@tile-pitch-mismatch:
- fi-tgl-y: [PASS][3] -> [DMESG-WARN][4] ([CI#94] / [i915#402]) +1 similar issue
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8061/fi-tgl-y/igt@kms_addfb_basic@tile-pitch-mismatch.html
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16809/fi-tgl-y/igt@kms_addfb_basic@tile-pitch-mismatch.html
* igt@kms_chamelium@common-hpd-after-suspend:
- fi-cml-u2: [PASS][5] -> [FAIL][6] ([i915#217])
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8061/fi-cml-u2/igt@kms_chamelium@common-hpd-after-suspend.html
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16809/fi-cml-u2/igt@kms_chamelium@common-hpd-after-suspend.html
#### Possible fixes ####
* igt@i915_selftest@live@gt_heartbeat:
- fi-bxt-dsi: [DMESG-FAIL][7] ([fdo#112406]) -> [PASS][8]
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8061/fi-bxt-dsi/igt@i915_selftest@live@gt_heartbeat.html
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16809/fi-bxt-dsi/igt@i915_selftest@live@gt_heartbeat.html
* igt@kms_addfb_basic@addfb25-bad-modifier:
- fi-tgl-y: [DMESG-WARN][9] ([CI#94] / [i915#402]) -> [PASS][10]
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8061/fi-tgl-y/igt@kms_addfb_basic@addfb25-bad-modifier.html
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16809/fi-tgl-y/igt@kms_addfb_basic@addfb25-bad-modifier.html
* igt@kms_chamelium@hdmi-hpd-fast:
- fi-icl-u2: [FAIL][11] ([i915#217]) -> [PASS][12]
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8061/fi-icl-u2/igt@kms_chamelium@hdmi-hpd-fast.html
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16809/fi-icl-u2/igt@kms_chamelium@hdmi-hpd-fast.html
#### Warnings ####
* igt@i915_pm_rpm@basic-pci-d3-state:
- fi-kbl-guc: [FAIL][13] ([i915#704]) -> [SKIP][14] ([fdo#109271])
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8061/fi-kbl-guc/igt@i915_pm_rpm@basic-pci-d3-state.html
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16809/fi-kbl-guc/igt@i915_pm_rpm@basic-pci-d3-state.html
* igt@kms_chamelium@hdmi-hpd-fast:
- fi-kbl-7500u: [FAIL][15] ([fdo#111096] / [i915#323]) -> [FAIL][16] ([i915#217])
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8061/fi-kbl-7500u/igt@kms_chamelium@hdmi-hpd-fast.html
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16809/fi-kbl-7500u/igt@kms_chamelium@hdmi-hpd-fast.html
[CI#94]: https://gitlab.freedesktop.org/gfx-ci/i915-infra/issues/94
[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[fdo#111096]: https://bugs.freedesktop.org/show_bug.cgi?id=111096
[fdo#112406]: https://bugs.freedesktop.org/show_bug.cgi?id=112406
[i915#217]: https://gitlab.freedesktop.org/drm/intel/issues/217
[i915#323]: https://gitlab.freedesktop.org/drm/intel/issues/323
[i915#402]: https://gitlab.freedesktop.org/drm/intel/issues/402
[i915#704]: https://gitlab.freedesktop.org/drm/intel/issues/704
Participating hosts (47 -> 36)
------------------------------
Missing (11): fi-bdw-5557u fi-byt-j1900 fi-byt-squawks fi-bsw-cyan fi-bwr-2160 fi-snb-2520m fi-gdg-551 fi-skl-lmem fi-bsw-nick fi-bdw-samus fi-snb-2600
Build changes
-------------
* CI: CI-20190529 -> None
* Linux: CI_DRM_8061 -> Patchwork_16809
CI-20190529: 20190529
CI_DRM_8061: e6398b7ae826a02206308a7e164bcf354bbf4993 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_5490: f98b33cbd5b57bae52b8e2fae2039e89ac877822 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_16809: 6878b4136f97dc0f1e2ab2a760db54ee55c961e0 @ git://anongit.freedesktop.org/gfx-ci/linux
== Linux commits ==
6878b4136f97 drm: i915_drm.h: Replace zero-length array with flexible-array member
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16809/index.html
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH][next] drm: i915_drm.h: Replace zero-length array with flexible-array member
2020-03-03 22:06 ` Gustavo A. R. Silva
(?)
@ 2020-03-04 9:27 ` Jani Nikula
-1 siblings, 0 replies; 9+ messages in thread
From: Jani Nikula @ 2020-03-04 9:27 UTC (permalink / raw)
To: Gustavo A. R. Silva, Joonas Lahtinen, Rodrigo Vivi, David Airlie,
Daniel Vetter
Cc: intel-gfx, dri-devel, linux-kernel, Gustavo A. R. Silva
On Tue, 03 Mar 2020, "Gustavo A. R. Silva" <gustavo@embeddedor.com> wrote:
> 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:
My earlier question about making the change in uapi was really about
potentially bumping up userspace compiler requirements, though I did not
actually say so. :)
I guess effectively uapi already requires C99 to build? And we
(i915_drm.h) have both [0] and []. So go for it.
What's your baseline? I think you've missed one instance of struct
i915_engine_class_instance engines[0];
BR,
Jani.
>
> 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 76497732932f ("cxgb3/l2t: Fix undefined behaviour")
>
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
> ---
> include/uapi/drm/i915_drm.h | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/include/uapi/drm/i915_drm.h b/include/uapi/drm/i915_drm.h
> index 2813e579b480..413d923b332a 100644
> --- a/include/uapi/drm/i915_drm.h
> +++ b/include/uapi/drm/i915_drm.h
> @@ -1729,7 +1729,7 @@ struct i915_context_engines_load_balance {
>
> __u64 mbz64; /* reserved for future use; must be zero */
>
> - struct i915_engine_class_instance engines[0];
> + struct i915_engine_class_instance engines[];
> } __attribute__((packed));
>
> #define I915_DEFINE_CONTEXT_ENGINES_LOAD_BALANCE(name__, N__) struct { \
> @@ -1767,7 +1767,7 @@ struct i915_context_engines_bond {
> __u64 flags; /* all undefined flags must be zero */
> __u64 mbz64[4]; /* reserved for future use; must be zero */
>
> - struct i915_engine_class_instance engines[0];
> + struct i915_engine_class_instance engines[];
> } __attribute__((packed));
>
> #define I915_DEFINE_CONTEXT_ENGINES_BOND(name__, N__) struct { \
--
Jani Nikula, Intel Open Source Graphics Center
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH][next] drm: i915_drm.h: Replace zero-length array with flexible-array member
@ 2020-03-04 9:27 ` Jani Nikula
0 siblings, 0 replies; 9+ messages in thread
From: Jani Nikula @ 2020-03-04 9:27 UTC (permalink / raw)
To: Gustavo A. R. Silva, Joonas Lahtinen, Rodrigo Vivi, David Airlie,
Daniel Vetter
Cc: intel-gfx, linux-kernel, dri-devel, Gustavo A. R. Silva
On Tue, 03 Mar 2020, "Gustavo A. R. Silva" <gustavo@embeddedor.com> wrote:
> 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:
My earlier question about making the change in uapi was really about
potentially bumping up userspace compiler requirements, though I did not
actually say so. :)
I guess effectively uapi already requires C99 to build? And we
(i915_drm.h) have both [0] and []. So go for it.
What's your baseline? I think you've missed one instance of struct
i915_engine_class_instance engines[0];
BR,
Jani.
>
> 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 76497732932f ("cxgb3/l2t: Fix undefined behaviour")
>
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
> ---
> include/uapi/drm/i915_drm.h | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/include/uapi/drm/i915_drm.h b/include/uapi/drm/i915_drm.h
> index 2813e579b480..413d923b332a 100644
> --- a/include/uapi/drm/i915_drm.h
> +++ b/include/uapi/drm/i915_drm.h
> @@ -1729,7 +1729,7 @@ struct i915_context_engines_load_balance {
>
> __u64 mbz64; /* reserved for future use; must be zero */
>
> - struct i915_engine_class_instance engines[0];
> + struct i915_engine_class_instance engines[];
> } __attribute__((packed));
>
> #define I915_DEFINE_CONTEXT_ENGINES_LOAD_BALANCE(name__, N__) struct { \
> @@ -1767,7 +1767,7 @@ struct i915_context_engines_bond {
> __u64 flags; /* all undefined flags must be zero */
> __u64 mbz64[4]; /* reserved for future use; must be zero */
>
> - struct i915_engine_class_instance engines[0];
> + struct i915_engine_class_instance engines[];
> } __attribute__((packed));
>
> #define I915_DEFINE_CONTEXT_ENGINES_BOND(name__, N__) struct { \
--
Jani Nikula, Intel Open Source Graphics Center
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Intel-gfx] [PATCH][next] drm: i915_drm.h: Replace zero-length array with flexible-array member
@ 2020-03-04 9:27 ` Jani Nikula
0 siblings, 0 replies; 9+ messages in thread
From: Jani Nikula @ 2020-03-04 9:27 UTC (permalink / raw)
To: Gustavo A. R. Silva, Joonas Lahtinen, Rodrigo Vivi, David Airlie,
Daniel Vetter
Cc: intel-gfx, linux-kernel, dri-devel, Gustavo A. R. Silva
On Tue, 03 Mar 2020, "Gustavo A. R. Silva" <gustavo@embeddedor.com> wrote:
> 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:
My earlier question about making the change in uapi was really about
potentially bumping up userspace compiler requirements, though I did not
actually say so. :)
I guess effectively uapi already requires C99 to build? And we
(i915_drm.h) have both [0] and []. So go for it.
What's your baseline? I think you've missed one instance of struct
i915_engine_class_instance engines[0];
BR,
Jani.
>
> 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 76497732932f ("cxgb3/l2t: Fix undefined behaviour")
>
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
> ---
> include/uapi/drm/i915_drm.h | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/include/uapi/drm/i915_drm.h b/include/uapi/drm/i915_drm.h
> index 2813e579b480..413d923b332a 100644
> --- a/include/uapi/drm/i915_drm.h
> +++ b/include/uapi/drm/i915_drm.h
> @@ -1729,7 +1729,7 @@ struct i915_context_engines_load_balance {
>
> __u64 mbz64; /* reserved for future use; must be zero */
>
> - struct i915_engine_class_instance engines[0];
> + struct i915_engine_class_instance engines[];
> } __attribute__((packed));
>
> #define I915_DEFINE_CONTEXT_ENGINES_LOAD_BALANCE(name__, N__) struct { \
> @@ -1767,7 +1767,7 @@ struct i915_context_engines_bond {
> __u64 flags; /* all undefined flags must be zero */
> __u64 mbz64[4]; /* reserved for future use; must be zero */
>
> - struct i915_engine_class_instance engines[0];
> + struct i915_engine_class_instance engines[];
> } __attribute__((packed));
>
> #define I915_DEFINE_CONTEXT_ENGINES_BOND(name__, N__) struct { \
--
Jani Nikula, Intel Open Source Graphics Center
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Intel-gfx] ✓ Fi.CI.IGT: success for drm: i915_drm.h: Replace zero-length array with flexible-array member
2020-03-03 22:06 ` Gustavo A. R. Silva
` (4 preceding siblings ...)
(?)
@ 2020-03-04 20:14 ` Patchwork
-1 siblings, 0 replies; 9+ messages in thread
From: Patchwork @ 2020-03-04 20:14 UTC (permalink / raw)
To: Gustavo A. R. Silva; +Cc: intel-gfx
== Series Details ==
Series: drm: i915_drm.h: Replace zero-length array with flexible-array member
URL : https://patchwork.freedesktop.org/series/74225/
State : success
== Summary ==
CI Bug Log - changes from CI_DRM_8061_full -> Patchwork_16809_full
====================================================
Summary
-------
**SUCCESS**
No regressions found.
Known issues
------------
Here are the changes found in Patchwork_16809_full that come from known issues:
### IGT changes ###
#### Issues hit ####
* igt@gem_busy@busy-vcs1:
- shard-iclb: [PASS][1] -> [SKIP][2] ([fdo#112080]) +16 similar issues
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8061/shard-iclb4/igt@gem_busy@busy-vcs1.html
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16809/shard-iclb6/igt@gem_busy@busy-vcs1.html
* igt@gem_exec_balancer@smoke:
- shard-iclb: [PASS][3] -> [SKIP][4] ([fdo#110854])
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8061/shard-iclb4/igt@gem_exec_balancer@smoke.html
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16809/shard-iclb7/igt@gem_exec_balancer@smoke.html
* igt@gem_exec_schedule@implicit-both-bsd1:
- shard-iclb: [PASS][5] -> [SKIP][6] ([fdo#109276] / [i915#677]) +2 similar issues
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8061/shard-iclb1/igt@gem_exec_schedule@implicit-both-bsd1.html
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16809/shard-iclb3/igt@gem_exec_schedule@implicit-both-bsd1.html
* igt@gem_exec_schedule@pi-common-bsd:
- shard-iclb: [PASS][7] -> [SKIP][8] ([i915#677]) +1 similar issue
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8061/shard-iclb6/igt@gem_exec_schedule@pi-common-bsd.html
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16809/shard-iclb1/igt@gem_exec_schedule@pi-common-bsd.html
* igt@gem_exec_schedule@preempt-other-chain-bsd:
- shard-iclb: [PASS][9] -> [SKIP][10] ([fdo#112146]) +5 similar issues
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8061/shard-iclb8/igt@gem_exec_schedule@preempt-other-chain-bsd.html
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16809/shard-iclb4/igt@gem_exec_schedule@preempt-other-chain-bsd.html
* igt@gem_exec_whisper@basic-queues-forked:
- shard-apl: [PASS][11] -> [INCOMPLETE][12] ([fdo#103927])
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8061/shard-apl6/igt@gem_exec_whisper@basic-queues-forked.html
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16809/shard-apl3/igt@gem_exec_whisper@basic-queues-forked.html
* igt@i915_pm_rps@reset:
- shard-iclb: [PASS][13] -> [FAIL][14] ([i915#413])
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8061/shard-iclb4/igt@i915_pm_rps@reset.html
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16809/shard-iclb7/igt@i915_pm_rps@reset.html
* igt@kms_atomic_transition@2x-modeset-transitions-fencing:
- shard-hsw: [PASS][15] -> [INCOMPLETE][16] ([i915#61])
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8061/shard-hsw1/igt@kms_atomic_transition@2x-modeset-transitions-fencing.html
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16809/shard-hsw5/igt@kms_atomic_transition@2x-modeset-transitions-fencing.html
* igt@kms_draw_crc@draw-method-rgb565-blt-xtiled:
- shard-skl: [PASS][17] -> [FAIL][18] ([i915#52] / [i915#54])
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8061/shard-skl3/igt@kms_draw_crc@draw-method-rgb565-blt-xtiled.html
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16809/shard-skl1/igt@kms_draw_crc@draw-method-rgb565-blt-xtiled.html
* igt@kms_flip@flip-vs-expired-vblank:
- shard-skl: [PASS][19] -> [FAIL][20] ([i915#79])
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8061/shard-skl3/igt@kms_flip@flip-vs-expired-vblank.html
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16809/shard-skl6/igt@kms_flip@flip-vs-expired-vblank.html
* igt@kms_flip@flip-vs-suspend:
- shard-kbl: [PASS][21] -> [DMESG-WARN][22] ([i915#180]) +2 similar issues
[21]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8061/shard-kbl6/igt@kms_flip@flip-vs-suspend.html
[22]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16809/shard-kbl1/igt@kms_flip@flip-vs-suspend.html
* igt@kms_hdr@bpc-switch-dpms:
- shard-skl: [PASS][23] -> [FAIL][24] ([i915#1188])
[23]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8061/shard-skl7/igt@kms_hdr@bpc-switch-dpms.html
[24]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16809/shard-skl3/igt@kms_hdr@bpc-switch-dpms.html
* igt@kms_plane@plane-panning-bottom-right-suspend-pipe-b-planes:
- shard-apl: [PASS][25] -> [DMESG-WARN][26] ([i915#180]) +2 similar issues
[25]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8061/shard-apl6/igt@kms_plane@plane-panning-bottom-right-suspend-pipe-b-planes.html
[26]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16809/shard-apl4/igt@kms_plane@plane-panning-bottom-right-suspend-pipe-b-planes.html
* igt@kms_plane_alpha_blend@pipe-a-constant-alpha-min:
- shard-skl: [PASS][27] -> [FAIL][28] ([fdo#108145])
[27]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8061/shard-skl6/igt@kms_plane_alpha_blend@pipe-a-constant-alpha-min.html
[28]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16809/shard-skl5/igt@kms_plane_alpha_blend@pipe-a-constant-alpha-min.html
* igt@kms_plane_alpha_blend@pipe-b-coverage-7efc:
- shard-skl: [PASS][29] -> [FAIL][30] ([fdo#108145] / [i915#265])
[29]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8061/shard-skl2/igt@kms_plane_alpha_blend@pipe-b-coverage-7efc.html
[30]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16809/shard-skl10/igt@kms_plane_alpha_blend@pipe-b-coverage-7efc.html
* igt@kms_psr2_su@page_flip:
- shard-iclb: [PASS][31] -> [SKIP][32] ([fdo#109642] / [fdo#111068])
[31]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8061/shard-iclb2/igt@kms_psr2_su@page_flip.html
[32]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16809/shard-iclb3/igt@kms_psr2_su@page_flip.html
* igt@kms_psr@psr2_primary_page_flip:
- shard-iclb: [PASS][33] -> [SKIP][34] ([fdo#109441]) +1 similar issue
[33]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8061/shard-iclb2/igt@kms_psr@psr2_primary_page_flip.html
[34]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16809/shard-iclb5/igt@kms_psr@psr2_primary_page_flip.html
* igt@prime_vgem@fence-wait-bsd2:
- shard-iclb: [PASS][35] -> [SKIP][36] ([fdo#109276]) +25 similar issues
[35]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8061/shard-iclb1/igt@prime_vgem@fence-wait-bsd2.html
[36]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16809/shard-iclb5/igt@prime_vgem@fence-wait-bsd2.html
#### Possible fixes ####
* igt@gem_ctx_shared@exec-single-timeline-bsd:
- shard-iclb: [SKIP][37] ([fdo#110841]) -> [PASS][38]
[37]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8061/shard-iclb2/igt@gem_ctx_shared@exec-single-timeline-bsd.html
[38]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16809/shard-iclb5/igt@gem_ctx_shared@exec-single-timeline-bsd.html
* igt@gem_exec_schedule@implicit-both-bsd2:
- shard-iclb: [SKIP][39] ([fdo#109276] / [i915#677]) -> [PASS][40] +1 similar issue
[39]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8061/shard-iclb8/igt@gem_exec_schedule@implicit-both-bsd2.html
[40]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16809/shard-iclb4/igt@gem_exec_schedule@implicit-both-bsd2.html
* igt@gem_exec_schedule@implicit-read-write-bsd:
- shard-iclb: [SKIP][41] ([i915#677]) -> [PASS][42]
[41]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8061/shard-iclb1/igt@gem_exec_schedule@implicit-read-write-bsd.html
[42]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16809/shard-iclb5/igt@gem_exec_schedule@implicit-read-write-bsd.html
* igt@gem_exec_schedule@preempt-bsd:
- shard-iclb: [SKIP][43] ([fdo#112146]) -> [PASS][44] +4 similar issues
[43]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8061/shard-iclb1/igt@gem_exec_schedule@preempt-bsd.html
[44]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16809/shard-iclb3/igt@gem_exec_schedule@preempt-bsd.html
* igt@gem_softpin@noreloc-s3:
- shard-apl: [DMESG-WARN][45] ([i915#180]) -> [PASS][46] +1 similar issue
[45]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8061/shard-apl3/igt@gem_softpin@noreloc-s3.html
[46]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16809/shard-apl7/igt@gem_softpin@noreloc-s3.html
* igt@i915_pm_dc@dc6-dpms:
- shard-iclb: [FAIL][47] -> [PASS][48]
[47]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8061/shard-iclb3/igt@i915_pm_dc@dc6-dpms.html
[48]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16809/shard-iclb6/igt@i915_pm_dc@dc6-dpms.html
* igt@i915_pm_rpm@system-suspend:
- shard-skl: [INCOMPLETE][49] ([i915#151] / [i915#69]) -> [PASS][50]
[49]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8061/shard-skl6/igt@i915_pm_rpm@system-suspend.html
[50]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16809/shard-skl5/igt@i915_pm_rpm@system-suspend.html
* igt@i915_suspend@fence-restore-untiled:
- shard-kbl: [INCOMPLETE][51] ([fdo#103665]) -> [PASS][52]
[51]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8061/shard-kbl4/igt@i915_suspend@fence-restore-untiled.html
[52]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16809/shard-kbl7/igt@i915_suspend@fence-restore-untiled.html
* igt@kms_big_fb@y-tiled-16bpp-rotate-0:
- shard-glk: [FAIL][53] ([i915#1119]) -> [PASS][54]
[53]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8061/shard-glk2/igt@kms_big_fb@y-tiled-16bpp-rotate-0.html
[54]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16809/shard-glk5/igt@kms_big_fb@y-tiled-16bpp-rotate-0.html
* igt@kms_draw_crc@draw-method-xrgb2101010-mmap-cpu-ytiled:
- shard-skl: [FAIL][55] ([i915#52] / [i915#54]) -> [PASS][56]
[55]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8061/shard-skl3/igt@kms_draw_crc@draw-method-xrgb2101010-mmap-cpu-ytiled.html
[56]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16809/shard-skl1/igt@kms_draw_crc@draw-method-xrgb2101010-mmap-cpu-ytiled.html
* igt@kms_pipe_crc_basic@suspend-read-crc-pipe-a:
- shard-kbl: [DMESG-WARN][57] ([i915#180]) -> [PASS][58] +1 similar issue
[57]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8061/shard-kbl3/igt@kms_pipe_crc_basic@suspend-read-crc-pipe-a.html
[58]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16809/shard-kbl2/igt@kms_pipe_crc_basic@suspend-read-crc-pipe-a.html
* igt@kms_plane_lowres@pipe-a-tiling-x:
- shard-glk: [FAIL][59] ([i915#899]) -> [PASS][60] +1 similar issue
[59]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8061/shard-glk1/igt@kms_plane_lowres@pipe-a-tiling-x.html
[60]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16809/shard-glk9/igt@kms_plane_lowres@pipe-a-tiling-x.html
* igt@kms_psr@psr2_cursor_plane_onoff:
- shard-iclb: [SKIP][61] ([fdo#109441]) -> [PASS][62] +2 similar issues
[61]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8061/shard-iclb1/igt@kms_psr@psr2_cursor_plane_onoff.html
[62]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16809/shard-iclb2/igt@kms_psr@psr2_cursor_plane_onoff.html
* igt@perf_pmu@busy-vcs1:
- shard-iclb: [SKIP][63] ([fdo#112080]) -> [PASS][64] +6 similar issues
[63]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8061/shard-iclb6/igt@perf_pmu@busy-vcs1.html
[64]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16809/shard-iclb1/igt@perf_pmu@busy-vcs1.html
* igt@prime_busy@hang-bsd2:
- shard-iclb: [SKIP][65] ([fdo#109276]) -> [PASS][66] +10 similar issues
[65]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8061/shard-iclb8/igt@prime_busy@hang-bsd2.html
[66]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16809/shard-iclb4/igt@prime_busy@hang-bsd2.html
[fdo#103665]: https://bugs.freedesktop.org/show_bug.cgi?id=103665
[fdo#103927]: https://bugs.freedesktop.org/show_bug.cgi?id=103927
[fdo#108145]: https://bugs.freedesktop.org/show_bug.cgi?id=108145
[fdo#109276]: https://bugs.freedesktop.org/show_bug.cgi?id=109276
[fdo#109441]: https://bugs.freedesktop.org/show_bug.cgi?id=109441
[fdo#109642]: https://bugs.freedesktop.org/show_bug.cgi?id=109642
[fdo#110841]: https://bugs.freedesktop.org/show_bug.cgi?id=110841
[fdo#110854]: https://bugs.freedesktop.org/show_bug.cgi?id=110854
[fdo#111068]: https://bugs.freedesktop.org/show_bug.cgi?id=111068
[fdo#112080]: https://bugs.freedesktop.org/show_bug.cgi?id=112080
[fdo#112146]: https://bugs.freedesktop.org/show_bug.cgi?id=112146
[i915#1119]: https://gitlab.freedesktop.org/drm/intel/issues/1119
[i915#1188]: https://gitlab.freedesktop.org/drm/intel/issues/1188
[i915#151]: https://gitlab.freedesktop.org/drm/intel/issues/151
[i915#180]: https://gitlab.freedesktop.org/drm/intel/issues/180
[i915#265]: https://gitlab.freedesktop.org/drm/intel/issues/265
[i915#413]: https://gitlab.freedesktop.org/drm/intel/issues/413
[i915#52]: https://gitlab.freedesktop.org/drm/intel/issues/52
[i915#54]: https://gitlab.freedesktop.org/drm/intel/issues/54
[i915#61]: https://gitlab.freedesktop.org/drm/intel/issues/61
[i915#677]: https://gitlab.freedesktop.org/drm/intel/issues/677
[i915#69]: https://gitlab.freedesktop.org/drm/intel/issues/69
[i915#79]: https://gitlab.freedesktop.org/drm/intel/issues/79
[i915#899]: https://gitlab.freedesktop.org/drm/intel/issues/899
Participating hosts (10 -> 10)
------------------------------
No changes in participating hosts
Build changes
-------------
* CI: CI-20190529 -> None
* Linux: CI_DRM_8061 -> Patchwork_16809
CI-20190529: 20190529
CI_DRM_8061: e6398b7ae826a02206308a7e164bcf354bbf4993 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_5490: f98b33cbd5b57bae52b8e2fae2039e89ac877822 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_16809: 6878b4136f97dc0f1e2ab2a760db54ee55c961e0 @ git://anongit.freedesktop.org/gfx-ci/linux
piglit_4509: fdc5a4ca11124ab8413c7988896eec4c97336694 @ git://anongit.freedesktop.org/piglit
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16809/index.html
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2020-03-04 20:14 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-03 22:06 [PATCH][next] drm: i915_drm.h: Replace zero-length array with flexible-array member Gustavo A. R. Silva
2020-03-03 22:06 ` [Intel-gfx] " Gustavo A. R. Silva
2020-03-03 22:06 ` Gustavo A. R. Silva
2020-03-04 3:38 ` [Intel-gfx] ✗ Fi.CI.DOCS: warning for " Patchwork
2020-03-04 3:47 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2020-03-04 9:27 ` [PATCH][next] " Jani Nikula
2020-03-04 9:27 ` [Intel-gfx] " Jani Nikula
2020-03-04 9:27 ` Jani Nikula
2020-03-04 20:14 ` [Intel-gfx] ✓ Fi.CI.IGT: success for " Patchwork
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.