util+treewide: container_of() cleanup

Replace mesa's slightly different container_of() with one more aligned
to the linux kernel's version which takes a type as the 2nd param.  This
avoids warnings like:

  freedreno_context.c:396:44: warning: variable 'batch' is uninitialized when used within its own initialization [-Wuninitialized]

At the same time, we can add additional build-time type-checking asserts

Signed-off-by: Rob Clark <robdclark@chromium.org>
Acked-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7941>
This commit is contained in:
Rob Clark
2020-12-05 11:56:45 -08:00
committed by Marge Bot
parent 6fe84c5dda
commit 790144e65a
18 changed files with 59 additions and 57 deletions

View File

@@ -96,8 +96,7 @@ struct radv_shader_output_values {
static inline struct radv_shader_context *
radv_shader_context_from_abi(struct ac_shader_abi *abi)
{
struct radv_shader_context *ctx = NULL;
return container_of(abi, ctx, abi);
return container_of(abi, struct radv_shader_context, abi);
}
static LLVMValueRef get_rel_patch_id(struct radv_shader_context *ctx)