From: Jonathan Nieder <jrnieder@gmail.com>
To: Stefan Beller <sbeller@google.com>
Cc: peff@peff.net, git@vger.kernel.org
Subject: Re: [PATCH] revision.c: Correctly dereference interesting_cache
Date: Fri, 19 Jun 2015 14:00:24 -0700 [thread overview]
Message-ID: <20150619210023.GA4865@google.com> (raw)
In-Reply-To: <1434740483-31730-1-git-send-email-sbeller@google.com>
Hi,
Stefan Beller wrote:
> This was introduced at b6e8a3b5 (2015-04-17, limit_list: avoid
> quadratic behavior from still_interesting), which
> also introduced the check a few lines before, which already dereferences
> `interesting_cache`. So at this point `interesting_cache` is guaranteed to
> be not NULL.
The above is the rationale for the coverity warning, but it does not
explain why this change is safe.
> The code is called referencing the address of a local
> variable, so `interesting_cache` can actually never be NULL and trigger a
> segmentation fault by dereferencing it a few lines before this.
I'm having trouble parsing this sentence. Do you mean that limit_list()
only calls still_interesting() (and thus, indirectly,
everybody_uninteresting()), with the second parameter equal to the
address of the local interesting_cache variable, so it can never be
NULL?
That makes sense, but I had to look at the code and reread the above
sentence a few times before I understood.
Do you know what this code is trying to check for? What does it mean
for *interesting_cache to be NULL?
Should there be
if (!interesting_cache)
die("BUG: &interesting_cache == NULL");
checks at the top of still_interesting and everybody_uninteresting to
futureproof this?
What does the *interesting_cache variable represent, anyway?
This code seems to be underdocumented.
Thanks and hope that helps,
Jonathan
prev parent reply other threads:[~2015-06-19 21:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-19 19:01 [PATCH] revision.c: Correctly dereference interesting_cache Stefan Beller
2015-06-19 20:49 ` Jeff King
2015-06-19 21:00 ` Jonathan Nieder [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=20150619210023.GA4865@google.com \
--to=jrnieder@gmail.com \
--cc=git@vger.kernel.org \
--cc=peff@peff.net \
--cc=sbeller@google.com \
/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.
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).