bug-gnulib
[Top][All Lists]
Advanced

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

Re: paying for the sin of no unit tests: useless-if-before-free bug


From: Jim Meyering
Subject: Re: paying for the sin of no unit tests: useless-if-before-free bug
Date: Thu, 01 May 2008 16:25:39 +0200

Jim Meyering <address@hidden> 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]