From: Jim Meyering <jim@meyering•net>
To: Junio C Hamano <gitster@pobox•com>
Cc: Jean-Luc Herren <jlh@gmx•ch>, git list <git@vger•kernel.org>
Subject: Re: [PATCH] Remove useless if-before-free tests.
Date: Sun, 24 Feb 2008 19:15:10 +0100 [thread overview]
Message-ID: <877igup6fl.fsf@rho.meyering.net> (raw)
In-Reply-To: <7vd4qo7fsc.fsf@gitster.siamese.dyndns.org> (Junio C. Hamano's message of "Fri, 22 Feb 2008 15:05:55 -0800")
Junio C Hamano <gitster@pobox•com> wrote:
...
>> If you're interested in automating detection of the useless
>> tests, you might like the useless-if-before-free script in gnulib:
>> [it *does* detect brace-enclosed free statements, and has a --name=S
>> option to make it detect free-like functions with different names]
>
> While I have your attention ;-)
Hi Jun,
No excuse required ;-)
> I am not interested in automating useless "if (x) free(x)" tests,
Yeah, that particular one is not a big deal, but whenever I take
the time to make a sweeping change, I find it's worth a little
more to automate a check to preserve the goal state.
> but one thing I recently wanted but did not know a handy
> tool for was to find all the calls to free() that free a pointer
> to an object of a particular type.
...
> I guess sparse could be hacked to do that, but do GNU folks have
> some checker like that?
A general purpose tool to do something like that would be very useful.
I thought of cscope and eclipse, but as far as I know,
neither of them can perform such a query.
This made me think of the dwarves package/paper:
7 dwarves
https://ols2006.108.redhat.com/2007/Reprints/melo-Reprint.pdf
This looked promising at first, but it annotates function _definitions_
for run-time data collection, while you want to look at uses, which
can be done statically:
3.4 ctracer
A class tracer, ctracer is an experiment in creating valid source
code from the DWARF information. For ctracer a method is any
function that receives as one of its parameters a pointer to a
specified struct. It looks for all such methods and generates
kprobes entry and exit functions. At these probe points it
collects information about the data structure internal state,
saving the values in its members in that point in time, and
records it in a relay buffer. The data is later collected in
userspace and post-processed, generating html + CSS callgraphs.
Too bad coverity is closed-source. I'll bet it could do this easily.
Maybe hacking sparse is the way to go, after all.
next prev parent reply other threads:[~2008-02-24 18:15 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-17 21:58 [PATCH] Remove useless if-before-free tests Jim Meyering
2008-02-17 22:09 ` David Symonds
2008-02-18 9:18 ` Jim Meyering
2008-02-18 9:36 ` Junio C Hamano
2008-02-17 22:16 ` Johannes Schindelin
2008-02-18 9:01 ` Jim Meyering
2008-02-18 14:27 ` Jean-Luc Herren
2008-02-20 10:26 ` Jim Meyering
2008-02-22 17:18 ` Junio C Hamano
2008-02-22 17:35 ` Jim Meyering
2008-02-22 17:40 ` Junio C Hamano
2008-02-22 22:08 ` Jim Meyering
2008-02-22 23:05 ` Junio C Hamano
2008-02-24 18:15 ` Jim Meyering [this message]
2009-02-26 13:48 ` Mike Ralphson
2008-02-26 6:59 ` Uwe Kleine-König
2008-02-23 13:30 ` Morten Welinder
2008-02-24 10:06 ` Johannes Schindelin
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=877igup6fl.fsf@rho.meyering.net \
--to=jim@meyering$(echo .)net \
--cc=git@vger$(echo .)kernel.org \
--cc=gitster@pobox$(echo .)com \
--cc=jlh@gmx$(echo .)ch \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox