[Mesa-dev] [PATCH mesa] intel: add comment explaining weird-looking code

Eric Engestrom eric.engestrom at intel.com
Thu Nov 1 15:44:53 UTC 2018


Clang throws warnings here (-Wgnu-variable-sized-type-not-at-end)
because of a variable-sized array at the end of
`drm_i915_query_topology_info` being aliased by the `data` field in
`topology`, but that's the point here, so let's explain it so that
the next me doesn't blindly listen to the compiler :)

Suggested-by: Brian Paul <brianp at vmware.com>
Signed-off-by: Eric Engestrom <eric.engestrom at intel.com>
---
 src/intel/dev/gen_device_info.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/intel/dev/gen_device_info.c b/src/intel/dev/gen_device_info.c
index 5dbd06075722f8cc644e..1be76f7bf6fa9da346a0 100644
--- a/src/intel/dev/gen_device_info.c
+++ b/src/intel/dev/gen_device_info.c
@@ -990,6 +990,11 @@ gen_device_info_update_from_masks(struct gen_device_info *devinfo,
                                   uint32_t subslice_mask,
                                   uint32_t n_eus)
 {
+   /*
+    * Note: the `data` field here is the necessary allocation for the
+    * zero-length `data` field in drm_i915_query_topology_info.
+    * Do not reorder!
+    */
    struct {
       struct drm_i915_query_topology_info base;
       uint8_t data[100];
-- 
Cheers,
  Eric



More information about the mesa-dev mailing list