postgresql/src/backend/utils
Peter Eisentraut a5abacecb4 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 de8feb1f3a)

Author: Peter Eisentraut <peter@eisentraut.org>
Author: Alexandra Wang <alexandra.wang.oss@gmail.com>
2024-11-08 09:42:21 +10:30
..
adt Replace usages of xmlXPathCompile() with xmlXPathCtxtCompile(). 2024-09-15 13:33:09 -04:00
cache Revert "For inplace update, send nontransactional invalidations." 2024-11-02 09:05:07 -07:00
error Fix Y2038 issues with MyStartTime. 2024-10-07 13:51:03 -05:00
fmgr Fix -Wcast-function-type warnings 2024-11-08 09:42:21 +10:30
hash Fix -Wcast-function-type warnings 2024-11-08 09:42:21 +10:30
init Fix Y2038 issues with MyStartTime. 2024-10-07 13:51:03 -05:00
mb Dial back -Wimplicit-fallthrough to level 3 2020-05-13 15:31:14 -04:00
misc Clarify restrict_nonsystem_relation_kind description. 2024-08-30 15:05:57 -07:00
mmgr Ignore not-yet-defined Portals in pg_cursors view. 2024-10-06 16:03:48 -04:00
resowner Improve performance of "simple expressions" in PL/pgSQL. 2020-03-26 18:58:57 -04:00
sort Clarify comment for LogicalTapeSetBlocks(). 2024-03-25 12:01:11 -07:00
time Revert "Improve error message on snapshot import in snapmgr.c" 2023-09-14 16:00:43 +09:00
.gitignore Rearrange makefile rules for running Gen_fmgrtab.pl. 2018-05-03 17:54:18 -04:00
errcodes.txt Make SQL/JSON error code names match SQL standard 2020-04-30 09:34:54 +02:00
Gen_dummy_probes.pl Emit dummy statements for probes.d probes when disabled 2021-05-10 13:56:21 +02:00
Gen_dummy_probes.sed Emit dummy statements for probes.d probes when disabled 2021-05-10 13:56:21 +02:00
Gen_fmgrtab.pl Use perl warnings pragma consistently 2020-04-13 11:55:45 -04:00
generate-errcodes.pl Update copyrights for 2020 2020-01-01 12:21:45 -05:00
Makefile Update copyrights for 2020 2020-01-01 12:21:45 -05:00
probes.d Update copyrights for 2020 2020-01-01 12:21:45 -05:00