History

drm/i915/uapi: Replace fake flex-array with flexible-array member

Zero-length arrays as fake flexible arrays are deprecated and we are moving towards adopting C99 flexible-array members instead. Address the following warning found with GCC-13 and -fstrict-flex-arrays=3 enabled: drivers/gpu/drm/i915/gem/i915_gem_context.c: In function ‘set_proto_ctx_engines.isra’: drivers/gpu/drm/i915/gem/i915_gem_context.c:769:41: warning: array subscript n is outside array bounds of ‘struct i915_engine_class_instance[0]’ [-Warray-bounds=] 769 | if (copy_from_user(&ci, &user->engines[n], sizeof(ci))) { | ^~~~~~~~~~~~~~~~~ ./include/uapi/drm/i915_drm.h:2494:43: note: while referencing ‘engines’ 2494 | struct i915_engine_class_instance engines[0]; This helps with the ongoing efforts to tighten the FORTIFY_SOURCE routines on memcpy() and help us make progress towards globally enabling -fstrict-flex-arrays=3 [1].

Gustavo A. R. Silva committed 3 years ago

Commit 02abecd1 parent 44df42e1 file · +1 −1Browse files

Unified · Split

include/uapi/drm/i915_drm.h+1−1
@@ -2491,7 +2491,7 @@ struct i915_context_param_engines { · 2490 unmodified lines
2491#define I915_CONTEXT_ENGINES_EXT_LOAD_BALANCE 0 /* see i915_context_engines_load_balance */2491#define I915_CONTEXT_ENGINES_EXT_LOAD_BALANCE 0 /* see i915_context_engines_load_balance */
2492#define I915_CONTEXT_ENGINES_EXT_BOND 1 /* see i915_context_engines_bond */2492#define I915_CONTEXT_ENGINES_EXT_BOND 1 /* see i915_context_engines_bond */
2493#define I915_CONTEXT_ENGINES_EXT_PARALLEL_SUBMIT 2 /* see i915_context_engines_parallel_submit */2493#define I915_CONTEXT_ENGINES_EXT_PARALLEL_SUBMIT 2 /* see i915_context_engines_parallel_submit */
2494 struct i915_engine_class_instance engines[0];2494 struct i915_engine_class_instance engines[];
2495} __attribute__((packed));2495} __attribute__((packed));
2496 2496
2497#define I915_DEFINE_CONTEXT_PARAM_ENGINES(name__, N__) struct { \2497#define I915_DEFINE_CONTEXT_PARAM_ENGINES(name__, N__) struct { \