git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Beller <stefanbeller@googlemail.com>
To: Thomas Rast <trast@inf.ethz.ch>
Cc: git@vger.kernel.org, peff@peff.net, gitster@pobox.com
Subject: Re: [PATCH] mailmap: fix check for freeing memory
Date: Tue, 20 Aug 2013 16:17:07 +0200	[thread overview]
Message-ID: <52137A63.3010609@googlemail.com> (raw)
In-Reply-To: <878uzw7a6l.fsf@linux-k42r.v.cablecom.net>

[-- Attachment #1: Type: text/plain, Size: 1828 bytes --]

On 08/20/2013 03:40 PM, Thomas Rast wrote:
> Stefan Beller <stefanbeller@googlemail.com> writes:
> 
>> The condition as it is written in that line was most likely intended to
>> check for the pointer passed to free(), rather than checking for the
>> 'repo_abbrev', which is already checked against being non null at the
>> beginning of the function.
> [...]
>> -			if (repo_abbrev)
>> +			if (*repo_abbrev)
>>  				free(*repo_abbrev);
> 
> But now the test is useless, because free(NULL) is defined to be a
> no-op.
> 

Yes, indeed. Thanks for reviewing.

Stepping two steps back, I am trying to figure out, what this repo_abrev
thing is doing, as I could find no documentation.

It's passed as a double pointer as declared in mailmap.h:
int read_mailmap(struct string_list *map, char **repo_abbrev);

However grepping for "read_mailmap(" (bracket to prevent finding 
read_mailmap_XXX as often used in mailmap.c itself) 
	grep -nHIirF --exclude-dir=.git -- "read_mailmap("
throughout all the sources I just find one occurence having the
second argument not being 'NULL' and that is in 
	builtin/shortlog.c:212:	read_mailmap(&log->mailmap, &log->common_repo_prefix);

which turns out to be:

void shortlog_init(struct shortlog *log)
{
	memset(log, 0, sizeof(*log));

	read_mailmap(&log->mailmap, &log->common_repo_prefix);
	...

So we're passing there an address, which was just set to zero.
This is the only occurence of passing a value at all and the value
being passed is 0, so the free in the original patch doesn't need 
that check either.

As I am resending the patch, could somebody please explain me
the mechanism of the "# repo-abbrev:" line? Even git itself doesn't
use it in the .mailmap file, but a quick google search shows up only
kernel repositories.

Stefan



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 899 bytes --]

  parent reply	other threads:[~2013-08-20 14:17 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-20 13:22 [PATCH] mailmap: fix check for freeing memory Stefan Beller
2013-08-20 13:40 ` Thomas Rast
2013-08-20 13:52   ` Jeff King
2013-08-20 14:17   ` Stefan Beller [this message]
2013-08-20 14:18     ` [PATCH] mailmap: remove redundant " Stefan Beller
2013-08-20 14:28       ` Jeff King
2013-08-20 14:23     ` [PATCH] mailmap: fix " Thomas Rast
2013-08-20 14:38       ` Stefan Beller
2013-08-20 16:12         ` Jeff King
2013-08-20 17:18           ` Junio C Hamano
2013-08-20 17:45             ` Jeff King
2013-08-20 14:27     ` Jeff King

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=52137A63.3010609@googlemail.com \
    --to=stefanbeller@googlemail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=peff@peff.net \
    --cc=trast@inf.ethz.ch \
    /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).