lkml.org 
[lkml]   [2023]   [Aug]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRE: [PATCH v5 1/8] x86/resctrl: Prepare for new domain scope
Date
> >I've sometimes had compilers complain about code written:
> >
> >static int get_domain_id_from_scope(int cpu, enum resctrl_scope scope)
> >{
> > switch (scope) {
> > case RESCTRL_L3_CACHE:
> > return get_cpu_cacheinfo_id(cpu, 3);
> > case RESCTRL_L2_CACHE:
> > return get_cpu_cacheinfo_id(cpu, 2);
> > default:
> > WARN_ON_ONCE(1);
> > return -1;
> > }
> >}
> >
> >because they failed to notice that every path in the switch does a "return and they
> >issue a warning that the function has no return value because they don't realize
> >that the end of the function can't be reached.
> >
> >So it's defensive programming against possible complier issues.
>
> I recall getting that error somewhere while playing around with a
> language server protocol for neovim a while ago but I tried to cause
> it today with gcc and clang and with some different flags and coulnd't.
> Are there some particular compilers or compiler flags that trigger
> that?

I think I saw this from an lkp report using clang. But it's quite possible
that the exact code construct was different in some way.

-Tony

\
 
 \ /
  Last update: 2023-08-31 19:27    [W:0.243 / U:0.128 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site