From 4cb824699e12c39fad97fb3d9085ced0d14c067c Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Thu, 9 Mar 2017 15:18:59 -0500 Subject: Cast result of copyObject() to correct type copyObject() is declared to return void *, which allows easily assigning the result independent of the input, but it loses all type checking. If the compiler supports typeof or something similar, cast the result to the input type. This creates a greater amount of type safety. In some cases, where the result is assigned to a generic type such as Node * or Expr *, new casts are now necessary, but in general casts are now unnecessary in the normal case and indicate that something unusual is happening. Reviewed-by: Mark Dilger --- src/backend/parser/parse_utilcmd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/backend/parser/parse_utilcmd.c') diff --git a/src/backend/parser/parse_utilcmd.c b/src/backend/parser/parse_utilcmd.c index 673276a9d3d..1ae43dc25dc 100644 --- a/src/backend/parser/parse_utilcmd.c +++ b/src/backend/parser/parse_utilcmd.c @@ -167,7 +167,7 @@ transformCreateStmt(CreateStmt *stmt, const char *queryString) * We must not scribble on the passed-in CreateStmt, so copy it. (This is * overkill, but easy.) */ - stmt = (CreateStmt *) copyObject(stmt); + stmt = copyObject(stmt); /* Set up pstate */ pstate = make_parsestate(NULL); @@ -2107,7 +2107,7 @@ transformIndexStmt(Oid relid, IndexStmt *stmt, const char *queryString) * We must not scribble on the passed-in IndexStmt, so copy it. (This is * overkill, but easy.) */ - stmt = (IndexStmt *) copyObject(stmt); + stmt = copyObject(stmt); /* Set up pstate */ pstate = make_parsestate(NULL); @@ -2521,7 +2521,7 @@ transformAlterTableStmt(Oid relid, AlterTableStmt *stmt, * We must not scribble on the passed-in AlterTableStmt, so copy it. (This * is overkill, but easy.) */ - stmt = (AlterTableStmt *) copyObject(stmt); + stmt = copyObject(stmt); /* Caller is responsible for locking the relation */ rel = relation_open(relid, NoLock); -- cgit v1.2.3