Fix cases of discarding result from list API functions
authorPeter Eisentraut <peter@eisentraut.org>
Sat, 17 Oct 2020 06:38:39 +0000 (08:38 +0200)
committerPeter Eisentraut <peter@eisentraut.org>
Wed, 11 Nov 2020 07:03:51 +0000 (08:03 +0100)
Two cases violated list APIs by throwing away the return value.  While
the code was technically correct, it relied on internal knowledge of
the list implementation, and the code wasn't really gaining anything
that way.  It is planned to make this a compiler warning in the
future, so just fix these cases by assigning the return value
properly.

Reviewed-by: Michael Paquier <michael@paquier.xyz>
Discussion: https://www.postgresql.org/message-id/flat/e3753562-99cd-b65f-5aca-687dfd1ec2fc@2ndquadrant.com

src/backend/commands/lockcmds.c
src/backend/parser/analyze.c

index 2846ef3b7bdf797e6da633ac14fea72ca064f7b8..098227656a823d8dcdb631a102efba20d6316edf 100644 (file)
@@ -266,7 +266,7 @@ LockViewRecurse(Oid reloid, LOCKMODE lockmode, bool nowait,
 
    LockViewRecurse_walker((Node *) viewquery, &context);
 
-   (void) list_delete_last(context.ancestor_views);
+   context.ancestor_views = list_delete_last(context.ancestor_views);
 
    table_close(view, NoLock);
 }
index 575e22ce0d2bd0acf40a5fdbdc22eebaca0ec97c..084e00f73d8188168f04110f91b81d7dac0773f1 100644 (file)
@@ -1475,8 +1475,7 @@ transformValuesClause(ParseState *pstate, SelectStmt *stmt)
            Node       *col = (Node *) lfirst(lc);
            List       *sublist = lfirst(lc2);
 
-           /* sublist pointer in exprsLists won't need adjustment */
-           (void) lappend(sublist, col);
+           sublist = lappend(sublist, col);
        }
        list_free(colexprs[i]);
    }