Ignore PQcancel errors properly
authorAlvaro Herrera
Tue, 9 May 2017 17:58:51 +0000 (14:58 -0300)
committerAlvaro Herrera
Tue, 9 May 2017 17:58:51 +0000 (14:58 -0300)
Add a (void) cast to all PQcancel() calls that purposefully don't check
the return value, to keep compilers and static checkers happy.

Per Coverity.

src/bin/pg_dump/pg_backup_db.c
src/bin/scripts/vacuumdb.c

index 2e7d23409af0df4b04e4e2d4657cb5d54340c845..b01a5f0cf0edb4b8fe06c042a21e9db7dd651e6f 100644 (file)
@@ -351,12 +351,12 @@ DisconnectDatabase(Archive *AHX)
    if (AH->connCancel)
    {
        /*
-        * If we have an active query, send a cancel before closing.  This is
-        * of no use for a normal exit, but might be helpful during
-        * exit_horribly().
+        * If we have an active query, send a cancel before closing, ignoring
+        * any errors.  This is of no use for a normal exit, but might be
+        * helpful during exit_horribly().
         */
        if (PQtransactionStatus(AH->connection) == PQTRANS_ACTIVE)
-           PQcancel(AH->connCancel, errbuf, sizeof(errbuf));
+           (void) PQcancel(AH->connCancel, errbuf, sizeof(errbuf));
 
        /*
         * Prevent signal handler from sending a cancel after this.
index e2b187eab3ac3193fc37513edad4324c4cef9971..97792d0720ee4851072def7eb8c86ccfc7b5b70c 100644 (file)
@@ -860,7 +860,7 @@ DisconnectDatabase(ParallelSlot *slot)
 
        if ((cancel = PQgetCancel(slot->connection)))
        {
-           PQcancel(cancel, errbuf, sizeof(errbuf));
+           (void) PQcancel(cancel, errbuf, sizeof(errbuf));
            PQfreeCancel(cancel);
        }
    }