postgres.git / summary / log / commit / refs

commit    e890ce7a4feb9d72cd502d52c5a4c4d853801974
Author:   Peter Eisentraut <peter@eisentraut.org>
Date:     Fri Aug 26 17:16:28 2022 +0000
First released in: 16.0

    Remove unneeded null pointer checks before PQfreemem()
    
    PQfreemem() just calls free(), and the latter already checks for null
    pointers.
    
    Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
    Discussion: https://www.postgresql.org/message-id/flat/cf26e970-8e92-59f1-247a-aa265235075b%40enterprisedb.com


contrib/vacuumlo/vacuumlo.c | 9 +++------ src/backend/replication/libpqwalreceiver/libpqwalreceiver.c | 6 ++---- src/bin/pg_basebackup/receivelog.c | 9 +++------ 3 files changed, 8 insertions(+), 16 deletions(-) diff --git a/contrib/vacuumlo/vacuumlo.c b/contrib/vacuumlo/vacuumlo.c index b7c8f2c805e..264b879bd39 100644 --- a/contrib/vacuumlo/vacuumlo.c +++ b/contrib/vacuumlo/vacuumlo.c @@ -231,12 +231,9 @@ vacuumlo(const char *database, const struct _param *param) pg_log_error("%s", PQerrorMessage(conn)); PQclear(res); PQfinish(conn); - if (schema != NULL) - PQfreemem(schema); - if (table != NULL) - PQfreemem(table); - if (field != NULL) - PQfreemem(field); + PQfreemem(schema); + PQfreemem(table); + PQfreemem(field); return -1; } diff --git a/src/backend/replication/libpqwalreceiver/libpqwalreceiver.c b/src/backend/replication/libpqwalreceiver/libpqwalreceiver.c index 28650245245..7f697b0f292 100644 --- a/src/backend/replication/libpqwalreceiver/libpqwalreceiver.c +++ b/src/backend/replication/libpqwalreceiver/libpqwalreceiver.c @@ -741,8 +741,7 @@ static void libpqrcv_disconnect(WalReceiverConn *conn) { PQfinish(conn->streamConn); - if (conn->recvBuf != NULL) - PQfreemem(conn->recvBuf); + PQfreemem(conn->recvBuf); pfree(conn); } @@ -768,8 +767,7 @@ libpqrcv_receive(WalReceiverConn *conn, char **buffer, { int rawlen; - if (conn->recvBuf != NULL) - PQfreemem(conn->recvBuf); + PQfreemem(conn->recvBuf); conn->recvBuf = NULL; /* Try to receive a CopyData message */ diff --git a/src/bin/pg_basebackup/receivelog.c b/src/bin/pg_basebackup/receivelog.c index 976d1e73b1f..5f6fd3201f3 100644 --- a/src/bin/pg_basebackup/receivelog.c +++ b/src/bin/pg_basebackup/receivelog.c @@ -858,8 +858,7 @@ HandleCopyStream(PGconn *conn, StreamCtl *stream, } error: - if (copybuf != NULL) - PQfreemem(copybuf); + PQfreemem(copybuf); return NULL; } @@ -940,8 +939,7 @@ CopyStreamReceive(PGconn *conn, long timeout, pgsocket stop_socket, char *copybuf = NULL; int rawlen; - if (*buffer != NULL) - PQfreemem(*buffer); + PQfreemem(*buffer); *buffer = NULL; /* Try to receive a CopyData message */ @@ -1204,8 +1202,7 @@ HandleEndOfCopyStream(PGconn *conn, StreamCtl *stream, char *copybuf, } still_sending = false; } - if (copybuf != NULL) - PQfreemem(copybuf); + PQfreemem(copybuf); *stoppos = blockpos; return res; } [parent: 45987aae260a]