[FFmpeg-devel] [PATCH] Try to add some ways variables can be read in patcheck.

Benoit Fouet benoit.fouet
Fri Jun 11 10:58:58 CEST 2010


On Fri, 11 Jun 2010 10:41:45 +0200 Michael Niedermayer wrote:
> On Fri, Jun 11, 2010 at 08:55:36AM +0200, Benoit Fouet wrote:
> > On Fri, 11 Jun 2010 00:05:08 +0200 Michael Niedermayer wrote:
> > > On Thu, Jun 10, 2010 at 05:56:38PM +0200, Benoit Fouet wrote:
> > > > In if statement for instance, a variable is read when compared, or'd, and'd...
> > > > ---
> > > >  tools/patcheck |    2 +-
> > > >  1 files changed, 1 insertions(+), 1 deletions(-)
> > > > 
> > > > diff --git a/tools/patcheck b/tools/patcheck
> > > > index a6923c4..0ebfd43 100755
> > > > --- a/tools/patcheck
> > > > +++ b/tools/patcheck
> > > > @@ -112,7 +112,7 @@ for i in \
> > > >      ; do
> > > >      echo $i | grep '^NULL$' && continue
> > > >      egrep $i' *(\+|-|\*|/|\||&|%|)=[^=]' $* >/dev/null || echo "possibly never written:"$i >> $TMP
> > > > -    egrep '(=|\(|return).*'$i'[^=]*$'    $* >/dev/null || echo "possibly never read   :"$i >> $TMP
> > > > +    egrep '(=|\(|return).*'$i'(( *(&*|\|*|==))|[^=])*$'    $* >/dev/null || echo "possibly never read   :"$i >> $TMP
> > > 
> > > doesnt [^=] already match most of these things (except ==)?
> > > 
> > 
> > OK, tried to narrow the 'issue' a bit more.
> > What I was trying to fix was cases like:
> > if ($i && foo == bar)
> > 
> > So maybe just the following should do:
> > 
> > diff --git a/tools/patcheck b/tools/patcheck
> > index a6923c4..62ad086 100755
> > --- a/tools/patcheck
> > +++ b/tools/patcheck
> > @@ -112,7 +112,7 @@ for i in \
> >      ; do
> >      echo $i | grep '^NULL$' && continue
> >      egrep $i' *(\+|-|\*|/|\||&|%|)=[^=]' $* >/dev/null || echo "possibly never written:"$i >> $TMP
> > -    egrep '(=|\(|return).*'$i'[^=]*$'    $* >/dev/null || echo "possibly never read   :"$i >> $TMP
> > +    egrep '(=|\(|return).*'$i'(==|[^=])*$'    $* >/dev/null || echo "possibly never read   :"$i >> $TMP
> >      egrep -o $i' *((\+|-|\*|/|\||&|%|)=[^=]|\+\+|--) *(0x|)[0-9]*(;|)'   $* |\
> 
> looks ok if it works
> 

tested with:
$ cat foo 
+int i = 0;
+if (i && foo == bar)
$ ./tools/patcheck foo
[...]
possibly unused variables
possibly never read   :i
possibly constant     :i
[...]
$ [apply diff]
$ ./tools/patcheck foo
[...]
possibly unused variables
possibly constant     :i
[...]

Seems to work fine, so applied.

Ben



More information about the ffmpeg-devel mailing list