Jim Meyering <[EMAIL PROTECTED]> wrote: > I noticed that I'd broken my useless-if-before-free script. > It would only notice the useless tests if there were > a cast on the argument to the free-like function. > > I've just pushed this correction and will add unit tests.
FYI, I've written a cheap unit test in the form of a Makefile: For now at least, this isn't even a proposal. Actually this seems more appropriately run from a checked-out gnulib directory, e.g., as part of a "make check" rule. The test for vc-list-files is in the same category. -------------------------- u = ./useless-if-before-free SHELL = /bin/bash all: $u <(printf 'if (p) free(p);') > /dev/null $u <(printf 'if (p) free((void)p);') > /dev/null $u <(printf 'if (p) free( (void)p);') > /dev/null $u <(printf 'if (p) free((T *) p);') > /dev/null $u <(printf 'if (*p) free(*p);') > /dev/null $u <(printf 'if (p)\nfree(p);') > /dev/null $u <(printf 'if ( p ) free(p);') > /dev/null $u <(printf 'if (p) free( p );') > /dev/null $u <(printf 'if(p) free (p);') > /dev/null $u <(printf 'if(p){free (p);}') > /dev/null $u <(printf 'if(p){\nfree (p);}') > /dev/null $u --name=z <(printf 'if (p) z (p);') > /dev/null $u --name=z <(printf 'if(p)z(p);') > /dev/null test $$($u --name=z <(printf 'if(p)z(p);if(p)z(p);')|wc -l) = 2