On Sat, 2020-02-22 at 16:20 +0000, Kyle Evans wrote:
> Author: kevans
> Date: Sat Feb 22 16:20:04 2020
> New Revision: 358248
> URL: https://svnweb.freebsd.org/changeset/base/358248
> 
> Log:
>   vm_radix: prefer __builtin_unreachable() to an unreachable panic()
>   
>   This provides the needed hint to GCC and offers an annotation for readers to
>   observe that it's in-fact impossible to hit this point. We'll get hit with a
>   a -Wswitch error if the enum applicable to the switch above were to get
>   expanded without the new value(s) being handled.
> 
> Modified:
>   head/sys/vm/vm_radix.c
> 
> Modified: head/sys/vm/vm_radix.c
> ==============================================================================
> --- head/sys/vm/vm_radix.c    Sat Feb 22 13:23:27 2020        (r358247)
> +++ head/sys/vm/vm_radix.c    Sat Feb 22 16:20:04 2020        (r358248)
> @@ -208,8 +208,7 @@ vm_radix_node_load(smrnode_t *p, enum vm_radix_access 
>       case SMR:
>               return (smr_entered_load(p, vm_radix_smr));
>       }
> -     /* This is unreachable, silence gcc. */
> -     panic("vm_radix_node_get: Unknown access type");
> +     __unreachable();
>  }
>  
>  static __inline void

What does __unreachable() do if the code ever becomes reachable?  Like
if a new enum value is added and this switch doesn't get updated?

-- Ian


_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to