[PATCH] drm/xe: Fix warning on unreachable statement
Matthew Brost
matthew.brost at intel.com
Fri Jul 19 19:59:21 UTC 2024
On Fri, Jul 19, 2024 at 12:15:34PM -0700, Lucas De Marchi wrote:
> eu_type_to_str() relies on -Wswitch to warn (and -Werror) to make sure
> it handles all enum values. However it's perfectly legal to pass an int
> to that function so in the end that function may happen to return
> nothing. A smart compiler could notice eu_type is never assigned to
> anything other than those values.
>
> Trying to reproduce this issue, none of gcc-9, gcc-10 and gcc-13
> triggered for me, but this was reported in a different system with
> gcc-10:
>
> drivers/gpu/drm/xe/xe.o: warning: objtool: xe_gt_topology_dump() falls through to next function xe_gt_topology_init()
>
> Since that is not really possible, just take the simple approach and
> return NULL.
>
> Cc: Michal Wajdeczko <michal.wajdeczko at intel.com>
> Signed-off-by: Lucas De Marchi <lucas.demarchi at intel.com>
> ---
> drivers/gpu/drm/xe/xe_gt_topology.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_gt_topology.c b/drivers/gpu/drm/xe/xe_gt_topology.c
> index 5a1559edf3e9..0662f71c6ede 100644
> --- a/drivers/gpu/drm/xe/xe_gt_topology.c
> +++ b/drivers/gpu/drm/xe/xe_gt_topology.c
> @@ -233,7 +233,7 @@ static const char *eu_type_to_str(enum xe_gt_eu_type eu_type)
> return "simd8";
Typically elsewhere in the KMD issue done this:
default:
drm_warn(&xe->drm, "NOT POSSIBLE");
Never really agreed on approach but this is used in a lot of places.
Should we do this here?
Matt
> }
>
> - unreachable();
> + return NULL;
> }
>
> void
> --
> 2.43.0
>
More information about the Intel-xe
mailing list