From: Stefan Beller <sbeller@google.com>
To: gitster@pobox.com
Cc: git@vger.kernel.org, jrnieder@gmail.com, peff@peff.net,
Stefan Beller <sbeller@google.com>
Subject: [PATCH] revision.c: Remove unneeded check for NULL
Date: Fri, 26 Jun 2015 12:40:19 -0700 [thread overview]
Message-ID: <1435347619-29410-1-git-send-email-sbeller@google.com> (raw)
The function is called only from one place, which makes sure
to have `interesting_cache` not NULL. Additionally it is a
dereferenced a few lines before unconditionally, which would
result in a segmentation fault.
Signed-off-by: Stefan Beller <sbeller@google.com>
---
Notes:
> So I think the right solution is just to drop the conditional entirely.
> The current code is not wrong (it is always a noop). What you have here
> actually misbehaves; it does not update the cache slot when it has
> become UNINTERESTING. That does not produce wrong results, but it loses
> the benefit of the cache in some cases.
After reading the code a bit more, I agree.
> 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?
I completely reworded the commit message.
> Should there be
>
> if (!interesting_cache)
> die("BUG: &interesting_cache == NULL");
>
> checks at the top of still_interesting and everybody_uninteresting to
> futureproof this?
I don't think this is necessary as these functions are local functions
so when somebody wants to use them they will be aware of the limitations.
> This code seems to be underdocumented.
I am not a expert in this area of the code, so I hoped Peff
would document it if he feels like so.
revision.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/revision.c b/revision.c
index 3ff8723..ab97ffd 100644
--- a/revision.c
+++ b/revision.c
@@ -361,8 +361,8 @@ static int everybody_uninteresting(struct commit_list *orig,
list = list->next;
if (commit->object.flags & UNINTERESTING)
continue;
- if (interesting_cache)
- *interesting_cache = commit;
+
+ *interesting_cache = commit;
return 0;
}
return 1;
--
2.4.1.345.gab207b6.dirty
next reply other threads:[~2015-06-26 19:40 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-26 19:40 Stefan Beller [this message]
2015-06-27 6:07 ` [PATCH] revision.c: Remove unneeded check for NULL Jeff King
2015-06-30 22:48 ` Jonathan Nieder
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=1435347619-29410-1-git-send-email-sbeller@google.com \
--to=sbeller@google.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jrnieder@gmail.com \
--cc=peff@peff.net \
/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).