pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Fix -Wcast-function-type warnings
2+ messages / 2 participants
[nested] [flat]

* pgsql: Fix -Wcast-function-type warnings
@ 2020-07-14 18:10 Peter Eisentraut <peter@eisentraut.org>
  0 siblings, 0 replies; 2+ messages in thread

From: Peter Eisentraut @ 2020-07-14 18:10 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix -Wcast-function-type warnings

Three groups of issues needed to be addressed:

load_external_function() and related functions returned PGFunction,
even though not necessarily all callers are looking for a function of
type PGFunction.  Since these functions are really just wrappers
around dlsym(), change to return void * just like dlsym().

In dynahash.c, we are using strlcpy() where a function with a
signature like memcpy() is expected.  This should be safe, as the new
comment there explains, but the cast needs to be augmented to avoid
the warning.

In PL/Python, methods all need to be cast to PyCFunction, per Python
API, but this now runs afoul of these warnings.  (This issue also
exists in core CPython.)

To fix the second and third case, we add a new type pg_funcptr_t that
is defined specifically so that gcc accepts it as a special function
pointer that can be cast to any other function pointer without the
warning.

Also add -Wcast-function-type to the standard warning flags, subject
to configure check.

Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://www.postgresql.org/message-id/flat/1e97628e-6447-b4fd-e230-d109cec2d584%402ndquadrant.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/de8feb1f3a23465b5737e8a8c160e8ca62f61339

Modified Files
--------------
configure                         | 91 +++++++++++++++++++++++++++++++++++++++
configure.in                      |  2 +
src/backend/utils/fmgr/dfmgr.c    | 14 +++---
src/backend/utils/hash/dynahash.c | 11 ++++-
src/include/c.h                   |  7 +++
src/include/fmgr.h                |  6 +--
src/pl/plpython/plpy_plpymodule.c | 14 +++---
7 files changed, 127 insertions(+), 18 deletions(-)



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* pgsql: Fix -Wcast-function-type warnings
@ 2024-11-07 23:19 Andrew Dunstan <andrew@dunslane.net>
  0 siblings, 0 replies; 2+ messages in thread

From: Andrew Dunstan @ 2024-11-07 23:19 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix -Wcast-function-type warnings

Three groups of issues needed to be addressed:

load_external_function() and related functions returned PGFunction,
even though not necessarily all callers are looking for a function of
type PGFunction.  Since these functions are really just wrappers
around dlsym(), change to return void * just like dlsym().

In dynahash.c, we are using strlcpy() where a function with a
signature like memcpy() is expected.  This should be safe, as the new
comment there explains, but the cast needs to be augmented to avoid
the warning.

In PL/Python, methods all need to be cast to PyCFunction, per Python
API, but this now runs afoul of these warnings.  (This issue also
exists in core CPython.)

To fix the second and third case, we add a new type pg_funcptr_t that
is defined specifically so that gcc accepts it as a special function
pointer that can be cast to any other function pointer without the
warning.

Also add -Wcast-function-type to the standard warning flags, subject
to configure check.

Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://www.postgresql.org/message-id/flat/1e97628e-6447-b4fd-e230-d109cec2d584%402ndquadrant.com
(cherry picked from commit de8feb1f3a23465b5737e8a8c160e8ca62f61339)

Author: Peter Eisentraut <peter@eisentraut.org>
Author: Alexandra Wang <alexandra.wang.oss@gmail.com>

Branch
------
REL_13_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/a5abacecb46358a7b771841e2ee0acbb1c353b79
Author: Peter Eisentraut <peter@eisentraut.org>

Modified Files
--------------
configure                         | 91 +++++++++++++++++++++++++++++++++++++++
configure.in                      |  2 +
src/backend/utils/fmgr/dfmgr.c    | 14 +++---
src/backend/utils/hash/dynahash.c | 11 ++++-
src/include/c.h                   |  7 +++
src/include/fmgr.h                |  6 +--
src/pl/plpython/plpy_plpymodule.c | 14 +++---
7 files changed, 127 insertions(+), 18 deletions(-)



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2024-11-07 23:19 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-07-14 18:10 pgsql: Fix -Wcast-function-type warnings Peter Eisentraut <peter@eisentraut.org>
2024-11-07 23:19 pgsql: Fix -Wcast-function-type warnings Andrew Dunstan <andrew@dunslane.net>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox