From: Junio C Hamano <gitster@pobox•com>
To: "René Scharfe" <l.s.r@web•de>
Cc: Johannes Schindelin <Johannes.Schindelin@gmx•de>,
Pranit Bauva <pranit.bauva@gmail•com>,
git@vger•kernel.org
Subject: Re: [PATCH] fixup! bisect--helper: `bisect_next_check` & bisect_voc shell function in C
Date: Mon, 13 Feb 2017 11:14:24 -0800 [thread overview]
Message-ID: <xmqqinodewdr.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <74dfcffe-274c-7045-420a-95612394d66b@web.de> ("René Scharfe"'s message of "Mon, 13 Feb 2017 19:27:01 +0100")
René Scharfe <l.s.r@web•de> writes:
> Initializing to NULL is still the correct thing to do, of course --
> together with removing the conditionals (or at least the negations).
So, let's give Pranit a concrete "here is what we want to see
squashed in", while you guys discuss peculiarity with various
platforms and their system headers, which admittedly is a more
interesting tangent ;-)
There are early returns with "goto finish" even before _syn
variables are first assigned to, so they would need to be
initialized to NULL. The other two get their initial values
right at the beginning, so they are OK.
builtin/bisect--helper.c | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c
index 8cd6527bd1..6949e8e5ca 100644
--- a/builtin/bisect--helper.c
+++ b/builtin/bisect--helper.c
@@ -280,7 +280,7 @@ static int bisect_next_check(const struct bisect_terms *terms,
int missing_good = 1, missing_bad = 1, retval = 0;
char *bad_ref = xstrfmt("refs/bisect/%s", terms->term_bad);
char *good_glob = xstrfmt("%s-*", terms->term_good);
- char *bad_syn, *good_syn;
+ char *bad_syn = NULL, *good_syn = NULL;
if (ref_exists(bad_ref))
missing_bad = 0;
@@ -341,14 +341,10 @@ static int bisect_next_check(const struct bisect_terms *terms,
}
goto finish;
finish:
- if (!bad_ref)
- free(bad_ref);
- if (!good_glob)
- free(good_glob);
- if (!bad_syn)
- free(bad_syn);
- if (!good_syn)
- free(good_syn);
+ free(bad_ref);
+ free(good_glob);
+ free(bad_syn);
+ free(good_syn);
return retval;
}
next prev parent reply other threads:[~2017-02-13 19:14 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-10 14:20 [PATCH] fixup! bisect--helper: `bisect_next_check` & bisect_voc shell function in C Johannes Schindelin
2017-02-10 15:30 ` Pranit Bauva
2017-02-10 20:47 ` René Scharfe
2017-02-13 16:23 ` Johannes Schindelin
2017-02-13 18:27 ` René Scharfe
2017-02-13 19:14 ` Junio C Hamano [this message]
2017-02-13 19:34 ` Pranit Bauva
2017-02-19 2:06 ` Junio C Hamano
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=xmqqinodewdr.fsf@gitster.mtv.corp.google.com \
--to=gitster@pobox$(echo .)com \
--cc=Johannes.Schindelin@gmx$(echo .)de \
--cc=git@vger$(echo .)kernel.org \
--cc=l.s.r@web$(echo .)de \
--cc=pranit.bauva@gmail$(echo .)com \
/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