tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: __dead functions



On Fri, Jul 18, 2008 at 16:50:11 +0300, Alexander Shishkin wrote:

> --- a/sys/kern/kern_lwp.c
> +++ b/sys/kern/kern_lwp.c
> @@ -837,6 +837,8 @@ lwp_exit(struct lwp *l)
>  #endif
>               lwp_exit_switchaway(l);
>       }
> +
> +     __NOTREACHED;
>  }

Is that really needed/correct?  lwp_exit_switchaway is declared dead
in this patch, so the body of the if should be covered by that.  What
is intended to happen is "current" is false?

So, from a quick look either this hunk is not necessary at all or it
should be replaced with an assertion.



> --- a/sys/sys/cdefs.h
> +++ b/sys/sys/cdefs.h
> @@ -164,6 +164,12 @@
>  #endif
>  
>  /*
> + * Explicitly specify that a certain point in the codepath should not
> + * be reached and indicate so to gcc.
> + */
> +#define __NOTREACHED for (;;)
> +
> +/*

This should be protected with GCC_PREREQ I guess.

I also think that explicit 

#define __NOTREACHED for (;;) continue

is better so that compiler barfs on something like an accidental
__NOTREACHED { /* ... */ }


-uwe


Home | Main Index | Thread Index | Old Index