pganalyze / libpg_query

C library for accessing the PostgreSQL parser outside of the server environment
BSD 3-Clause "New" or "Revised" License
1.21k stars 182 forks source link

Warnings issued by gcc compiling deparse.c #200

Closed lelit closed 1 year ago

lelit commented 1 year ago

Trying out recently released 4.2.2, I see the following:

...
compiling src/pg_query_scan.c
compiling src/pg_query_split.c
compiling src/postgres_deparse.c
In file included from ./src/postgres/include/nodes/primnodes.h:22,
                 from ./src/postgres/include/nodes/parsenodes.h:27,
                 from ./src/postgres/include/catalog/objectaddress.h:17,
                 from ./src/postgres/include/catalog/index.h:17,
                 from src/postgres_deparse.c:2:
src/postgres_deparse.c: In function ‘deparseCreateFunctionStmt’:
src/postgres_deparse.c:4906:58: warning: passing argument 1 of ‘list_nth_cell’ from incompatible pointer type [-Wincompatible-pointer-types]
 4906 |                         if (linitial(create_function_stmt->sql_body) != NULL)
      |                                      ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
      |                                                          |
      |                                                          Node *
./src/postgres/include/nodes/pg_list.h:169:51: note: in definition of macro ‘lfirst’
  169 | #define lfirst(lc)                              ((lc)->ptr_value)
      |                                                   ^~
src/postgres_deparse.c:4906:29: note: in expansion of macro ‘linitial’
 4906 |                         if (linitial(create_function_stmt->sql_body) != NULL)
      |                             ^~~~~~~~
./src/postgres/include/nodes/pg_list.h:256:27: note: expected ‘const List *’ but argument is of type ‘Node *’
  256 | list_nth_cell(const List *list, int n)
      |               ~~~~~~~~~~~~^~~~
In file included from ./src/postgres/include/nodes/pg_list.h:40:
src/postgres_deparse.c:4908:100: warning: passing argument 1 of ‘list_nth_cell’ from incompatible pointer type [-Wincompatible-pointer-types]
 4908 |                                 List *body_stmt_list = castNode(List, linitial(create_function_stmt->sql_body));
      |                                                                                ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
      |                                                                                                    |
      |                                                                                                    Node *
./src/postgres/include/nodes/nodes.h:614:48: note: in definition of macro ‘castNode’
  614 | #define castNode(_type_, nodeptr) ((_type_ *) (nodeptr))
      |                                                ^~~~~~~
./src/postgres/include/nodes/pg_list.h:174:49: note: in expansion of macro ‘lfirst’
  174 | #define linitial(l)                             lfirst(list_nth_cell(l, 0))
      |                                                 ^~~~~~
src/postgres_deparse.c:4908:71: note: in expansion of macro ‘linitial’
 4908 |                                 List *body_stmt_list = castNode(List, linitial(create_function_stmt->sql_body));
      |                                                                       ^~~~~~~~
./src/postgres/include/nodes/pg_list.h:256:27: note: expected ‘const List *’ but argument is of type ‘Node *’
  256 | list_nth_cell(const List *list, int n)
      |               ~~~~~~~~~~~~^~~~
compiling src/postgres/src_backend_catalog_namespace.c
compiling src/postgres/src_backend_catalog_pg_proc.c
...
lfittl commented 1 year ago

Thanks for the report!

This is fixed in https://github.com/pganalyze/libpg_query/pull/199 - aiming to release this as 15-4.2.3 soon.

lelit commented 1 year ago

Thank you, I missed that!

lelit commented 1 year ago

This is solved in just released 15-4.2.3, thanks.