Re: [PATCH] Silence Valgrind about SelectConfigFiles()

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Aleksander Alekseev <aleksander(at)tigerdata(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: [PATCH] Silence Valgrind about SelectConfigFiles()
Date: 2025-08-14 00:25:41
Message-ID: 22115.1755131141@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Aleksander Alekseev <aleksander(at)tigerdata(dot)com> writes:
>> You didn't say what the test condition was, but from the patch
>> I suppose it's a case where SelectConfigFiles is erroring out?

> Steps to reproduce:
> ...

Huh ... don't quite see where in that recipe we'd reach a
SelectConfigFiles error exit.

> It's not exciting at all but given the fact that this is the only
> "definitely lost" error I got it's worth fixing IMO ("broken windows"
> and all that). I should have also pointed out that SelectConfigFiles()
> sometimes calls free(configdir) and sometimes doesn't, which is
> inconsistent.

Yeah, I noticed that too, and it does offend my inner neatnik.

Instead of what you did, I'd be inclined to add

free(configdir);

return true;
+
+fail:
+ free(configdir);
+
+ return false;
}

and then s/return false/goto fail/ throughout, so as to avoid
duplicating the free() calls. It's a minor point as things stand,
but if more cleanup gets added to the function I think it'd be
easier to maintain this way.

> Sorry for little details in the first email - it's 2:30 AM in my time zone :)

No trouble.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas Munro 2025-08-14 00:42:09 Re: index prefetching
Previous Message Peter Geoghegan 2025-08-14 00:20:48 Re: index prefetching