Re: libpq: Remove redundant null pointer checks before free()

2022-06-19 Thread Tom Lane
Alvaro Herrera writes: > For PQclear() specifically, one thing that I thought a few days ago > would be useful would to have it return (PGresult *) NULL. Then the > very common pattern of doing "PQclear(res); res = NULL;" could be > simplified to "res = PQclear(res);", which is nicely compact and

Re: libpq: Remove redundant null pointer checks before free()

2022-06-19 Thread Alvaro Herrera
On 2022-Jun-17, Peter Eisentraut wrote: > From 355ef1a68be690d9bb8ee0524226abd648733ce0 Mon Sep 17 00:00:00 2001 > From: Peter Eisentraut > Date: Fri, 17 Jun 2022 12:09:32 +0200 > Subject: [PATCH v2 3/3] Remove redundant null pointer checks before PQclear > and PQconninfofree > > These function

Re: libpq: Remove redundant null pointer checks before free()

2022-06-17 Thread Tom Lane
Michael Paquier writes: > On Fri, Jun 17, 2022 at 09:03:23PM +0200, Peter Eisentraut wrote: >> I'm pretty sure PostgreSQL code already depends on this behavior anyway. >> The code just isn't consistent about it. > In the frontend, I'd like to think that you are right and that we have > already so

Re: libpq: Remove redundant null pointer checks before free()

2022-06-17 Thread Michael Paquier
On Fri, Jun 17, 2022 at 09:03:23PM +0200, Peter Eisentraut wrote: > I'm pretty sure PostgreSQL code already depends on this behavior anyway. > The code just isn't consistent about it. In the frontend, I'd like to think that you are right and that we have already some places doing that. The backen

Re: libpq: Remove redundant null pointer checks before free()

2022-06-17 Thread Tom Lane
Peter Eisentraut writes: > On 17.06.22 07:11, Tom Lane wrote: >> Notably, I think the choice >> that pfree(NULL) is disallowed traces directly to worries about >> coding-pattern-compatibility with pre-POSIX free(). Should we >> revisit that? > Yes please, and also repalloc(). repalloc no, becau

Re: libpq: Remove redundant null pointer checks before free()

2022-06-17 Thread Peter Eisentraut
On 17.06.22 07:11, Tom Lane wrote: Having said that, the pattern "if (x) free(x);" is absolutely ubiquitous across our code, and so I'm not sure that I'm on board with undoing it only in libpq. I'd be happier if we made a push to get rid of it everywhere. Sure, here is a more comprehensive pat

Re: libpq: Remove redundant null pointer checks before free()

2022-06-17 Thread Peter Eisentraut
On 17.06.22 05:25, Michael Paquier wrote: On Thu, Jun 16, 2022 at 10:07:33PM +0200, Peter Eisentraut wrote: calls, where the "if" part is unnecessary. This is of course pretty harmless, but some functions like scram_free() and freePGconn() have become so bulky that it becomes annoying. So whil

Re: libpq: Remove redundant null pointer checks before free()

2022-06-16 Thread Tom Lane
Michael Paquier writes: > On Thu, Jun 16, 2022 at 10:07:33PM +0200, Peter Eisentraut wrote: >> calls, where the "if" part is unnecessary. This is of course pretty >> harmless, but some functions like scram_free() and freePGconn() have become >> so bulky that it becomes annoying. So while I was d

Re: libpq: Remove redundant null pointer checks before free()

2022-06-16 Thread Michael Paquier
On Thu, Jun 16, 2022 at 10:07:33PM +0200, Peter Eisentraut wrote: > calls, where the "if" part is unnecessary. This is of course pretty > harmless, but some functions like scram_free() and freePGconn() have become > so bulky that it becomes annoying. So while I was doing some work in that > area

libpq: Remove redundant null pointer checks before free()

2022-06-16 Thread Peter Eisentraut
undertook to simplify this.From f7a10c1fca10c76b89dbf402ad9418ed8f0675d7 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Thu, 16 Jun 2022 21:50:56 +0200 Subject: [PATCH] libpq: Remove redundant null pointer checks before free() --- src/interfaces/libpq/fe-auth-scram.c| 33 ++-- src/