Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Matthew Brost <matthew.brost@intel.com>
To: Lucas De Marchi <lucas.demarchi@intel.com>
Cc: <intel-xe@lists.freedesktop.org>,
	Michal Wajdeczko <michal.wajdeczko@intel.com>
Subject: Re: [PATCH] drm/xe: Fix warning on unreachable statement
Date: Fri, 19 Jul 2024 19:59:21 +0000	[thread overview]
Message-ID: <ZprFmUmx4vK1v0HT@DUT025-TGLU.fm.intel.com> (raw)
In-Reply-To: <20240719191534.3845469-1-lucas.demarchi@intel.com>

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@intel.com>
> Signed-off-by: Lucas De Marchi <lucas.demarchi@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
> 

  parent reply	other threads:[~2024-07-19 20:00 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-19 19:15 [PATCH] drm/xe: Fix warning on unreachable statement Lucas De Marchi
2024-07-19 19:20 ` ✓ CI.Patch_applied: success for " Patchwork
2024-07-19 19:20 ` ✓ CI.checkpatch: " Patchwork
2024-07-19 19:21 ` ✗ CI.KUnit: failure " Patchwork
2024-07-19 19:59 ` Matthew Brost [this message]
2024-07-19 20:38   ` [PATCH] " Lucas De Marchi
2024-07-19 21:59 ` Michal Wajdeczko
2024-07-21 19:25 ` Nathan Chancellor
2024-07-22 16:39   ` Lucas De Marchi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZprFmUmx4vK1v0HT@DUT025-TGLU.fm.intel.com \
    --to=matthew.brost@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=lucas.demarchi@intel.com \
    --cc=michal.wajdeczko@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox