zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.stephenson@samsung.com>
To: zsh-workers@zsh.org
Subject: Re: [PATCH] Fix a WARN_CREATE_GLOBAL false positive.
Date: Fri, 06 Dec 2013 09:23:09 +0000	[thread overview]
Message-ID: <20131206092309.1831da0c@pwslap01u.europe.root.pri> (raw)
In-Reply-To: <20131206074728.GA2313@tarsus.local2>

On Fri, 06 Dec 2013 09:47:28 +0200
Daniel Shahaf <d.s@daniel.shahaf.name> wrote:
> This seems to be a false positive:
> 
>     % zsh -fc 'setopt warn_create_global; (){ x=y =true }'
>     (anon): scalar parameter x created globally in function
> 
> Regression test attached.  I'm less sure about the patch, but it seems to
> work and is unlikely to break anything other than WARN_CREATE_GLOBAL.
>  		if (varspc) {
> -		    addvars(state, varspc, ADDVAR_EXPORT|ADDVAR_RESTRICT);
> +		    int addflags = ADDVAR_EXPORT|ADDVAR_RESTRICT;
> +		    if (forked)
> +			addflags |= ADDVAR_RESTORE;
> +		    addvars(state, varspc, addflags);
>  		    if (errflag)
>  			_exit(1);
>  		}

It looks plausible.  "forked" is a local variable in execcmd() saying we
forked to execute whatever it is, so it indicates the variable can't
leak from the current command context.  ADVAR_RESTORE is only a signal
to quieten the warning (it could be better named; the name comes from
the other time it's set rather than it's real purpose).  So it certainly
looks better than before.

Thanks
pws


      reply	other threads:[~2013-12-06  9:33 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-06  7:47 Daniel Shahaf
2013-12-06  9:23 ` Peter Stephenson [this message]

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=20131206092309.1831da0c@pwslap01u.europe.root.pri \
    --to=p.stephenson@samsung.com \
    --cc=zsh-workers@zsh.org \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).