On Sat, May 07, 2011 at 03:20:48PM +0300, Jaakko Heinonen wrote:
> On 2011-05-07, Kostik Belousov wrote:
> > > @@ -310,6 +310,7 @@ getenv(const char *name)
> > >   int len;
> > >  
> > >   if (dynamic_kenv) {
> > > +         WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, "getenv");
> > >           mtx_lock(&kenv_lock);
> > >           cp = _getenv_dynamic(name, NULL);
> > >           if (cp != NULL) {
> > 
> > This might be somewhat excessive. Since malloc() warns or panics anyway,
> > what about moving the WITNESS_WARN into "not found" branch ?
> 
> Is this better?
Most likely, at least this is exactly what I meant.

> 
> %%%
> Index: sys/kern/kern_environment.c
> ===================================================================
> --- sys/kern/kern_environment.c       (revision 221597)
> +++ sys/kern/kern_environment.c       (working copy)
> @@ -310,7 +310,6 @@ getenv(const char *name)
>       int len;
>  
>       if (dynamic_kenv) {
> -             WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, "getenv");
>               mtx_lock(&kenv_lock);
>               cp = _getenv_dynamic(name, NULL);
>               if (cp != NULL) {
> @@ -322,6 +321,8 @@ getenv(const char *name)
>               } else {
>                       mtx_unlock(&kenv_lock);
>                       ret = NULL;
> +                     WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL,
> +                         "getenv");
>               }
>       } else
>               ret = _getenv_static(name);
> %%%
> 
> -- 
> Jaakko

Attachment: pgpiJprkZdh3B.pgp
Description: PGP signature

Reply via email to