diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/utils/fmgr/dfmgr.c | 14 | ||||
-rw-r--r-- | src/backend/utils/hash/dynahash.c | 11 | ||||
-rw-r--r-- | src/include/c.h | 7 | ||||
-rw-r--r-- | src/include/fmgr.h | 6 | ||||
-rw-r--r-- | src/pl/plpython/plpy_plpymodule.c | 14 |
5 files changed, 34 insertions, 18 deletions
diff --git a/src/backend/utils/fmgr/dfmgr.c b/src/backend/utils/fmgr/dfmgr.c index 9dff1f5e829..bd779fdaf7a 100644 --- a/src/backend/utils/fmgr/dfmgr.c +++ b/src/backend/utils/fmgr/dfmgr.c @@ -95,7 +95,7 @@ static const Pg_magic_struct magic_data = PG_MODULE_MAGIC_DATA; * named funcname in it. * * If the function is not found, we raise an error if signalNotFound is true, - * else return (PGFunction) NULL. Note that errors in loading the library + * else return NULL. Note that errors in loading the library * will provoke ereport() regardless of signalNotFound. * * If filehandle is not NULL, then *filehandle will be set to a handle @@ -103,13 +103,13 @@ static const Pg_magic_struct magic_data = PG_MODULE_MAGIC_DATA; * lookup_external_function to lookup additional functions in the same file * at less cost than repeating load_external_function. */ -PGFunction +void * load_external_function(const char *filename, const char *funcname, bool signalNotFound, void **filehandle) { char *fullname; void *lib_handle; - PGFunction retval; + void *retval; /* Expand the possibly-abbreviated filename to an exact path name */ fullname = expand_dynamic_library_name(filename); @@ -122,7 +122,7 @@ load_external_function(const char *filename, const char *funcname, *filehandle = lib_handle; /* Look up the function within the library. */ - retval = (PGFunction) dlsym(lib_handle, funcname); + retval = dlsym(lib_handle, funcname); if (retval == NULL && signalNotFound) ereport(ERROR, @@ -165,12 +165,12 @@ load_file(const char *filename, bool restricted) /* * Lookup a function whose library file is already loaded. - * Return (PGFunction) NULL if not found. + * Return NULL if not found. */ -PGFunction +void * lookup_external_function(void *filehandle, const char *funcname) { - return (PGFunction) dlsym(filehandle, funcname); + return dlsym(filehandle, funcname); } diff --git a/src/backend/utils/hash/dynahash.c b/src/backend/utils/hash/dynahash.c index 2688e277267..5948b01abc3 100644 --- a/src/backend/utils/hash/dynahash.c +++ b/src/backend/utils/hash/dynahash.c @@ -398,7 +398,16 @@ hash_create(const char *tabname, long nelem, HASHCTL *info, int flags) if (flags & HASH_KEYCOPY) hashp->keycopy = info->keycopy; else if (hashp->hash == string_hash) - hashp->keycopy = (HashCopyFunc) strlcpy; + { + /* + * The signature of keycopy is meant for memcpy(), which returns + * void*, but strlcpy() returns size_t. Since we never use the return + * value of keycopy, and size_t is pretty much always the same size as + * void *, this should be safe. The extra cast in the middle is to + * avoid warnings from -Wcast-function-type. + */ + hashp->keycopy = (HashCopyFunc) (pg_funcptr_t) strlcpy; + } else hashp->keycopy = memcpy; diff --git a/src/include/c.h b/src/include/c.h index a904b49a37f..f242e32edbe 100644 --- a/src/include/c.h +++ b/src/include/c.h @@ -266,6 +266,13 @@ #endif /* + * Generic function pointer. This can be used in the rare cases where it's + * necessary to cast a function pointer to a seemingly incompatible function + * pointer type while avoiding gcc's -Wcast-function-type warnings. + */ +typedef void (*pg_funcptr_t) (void); + +/* * We require C99, hence the compiler should understand flexible array * members. However, for documentation purposes we still consider it to be * project style to write "field[FLEXIBLE_ARRAY_MEMBER]" not just "field[]". diff --git a/src/include/fmgr.h b/src/include/fmgr.h index d349510b7c7..f25068fae20 100644 --- a/src/include/fmgr.h +++ b/src/include/fmgr.h @@ -716,9 +716,9 @@ extern bool CheckFunctionValidatorAccess(Oid validatorOid, Oid functionOid); */ extern char *Dynamic_library_path; -extern PGFunction load_external_function(const char *filename, const char *funcname, - bool signalNotFound, void **filehandle); -extern PGFunction lookup_external_function(void *filehandle, const char *funcname); +extern void *load_external_function(const char *filename, const char *funcname, + bool signalNotFound, void **filehandle); +extern void *lookup_external_function(void *filehandle, const char *funcname); extern void load_file(const char *filename, bool restricted); extern void **find_rendezvous_variable(const char *varName); extern Size EstimateLibraryStateSpace(void); diff --git a/src/pl/plpython/plpy_plpymodule.c b/src/pl/plpython/plpy_plpymodule.c index e308c61d50f..7f54d093ace 100644 --- a/src/pl/plpython/plpy_plpymodule.c +++ b/src/pl/plpython/plpy_plpymodule.c @@ -61,13 +61,13 @@ static PyMethodDef PLy_methods[] = { /* * logging methods */ - {"debug", (PyCFunction) PLy_debug, METH_VARARGS | METH_KEYWORDS, NULL}, - {"log", (PyCFunction) PLy_log, METH_VARARGS | METH_KEYWORDS, NULL}, - {"info", (PyCFunction) PLy_info, METH_VARARGS | METH_KEYWORDS, NULL}, - {"notice", (PyCFunction) PLy_notice, METH_VARARGS | METH_KEYWORDS, NULL}, - {"warning", (PyCFunction) PLy_warning, METH_VARARGS | METH_KEYWORDS, NULL}, - {"error", (PyCFunction) PLy_error, METH_VARARGS | METH_KEYWORDS, NULL}, - {"fatal", (PyCFunction) PLy_fatal, METH_VARARGS | METH_KEYWORDS, NULL}, + {"debug", (PyCFunction) (pg_funcptr_t) PLy_debug, METH_VARARGS | METH_KEYWORDS, NULL}, + {"log", (PyCFunction) (pg_funcptr_t) PLy_log, METH_VARARGS | METH_KEYWORDS, NULL}, + {"info", (PyCFunction) (pg_funcptr_t) PLy_info, METH_VARARGS | METH_KEYWORDS, NULL}, + {"notice", (PyCFunction) (pg_funcptr_t) PLy_notice, METH_VARARGS | METH_KEYWORDS, NULL}, + {"warning", (PyCFunction) (pg_funcptr_t) PLy_warning, METH_VARARGS | METH_KEYWORDS, NULL}, + {"error", (PyCFunction) (pg_funcptr_t) PLy_error, METH_VARARGS | METH_KEYWORDS, NULL}, + {"fatal", (PyCFunction) (pg_funcptr_t) PLy_fatal, METH_VARARGS | METH_KEYWORDS, NULL}, /* * create a stored plan |