Openembedded Core Discussions
 help / color / mirror / Atom feed
* [pseudo][PATCH] wrappers: Avoid -Wcast-function-type warning
@ 2021-05-17 19:22 philip
  0 siblings, 0 replies; only message in thread
From: philip @ 2021-05-17 19:22 UTC (permalink / raw)
  To: openembedded-core; +Cc: Philip Lorenz

GCC emits this warning for mismatched function types unless the generic
void (*) (void) signature is used ([1]) - e.g.:

  warning: cast between incompatible function types from ‘int (*)(const
  char *)’ to ‘int (*)(void)’ [-Wcast-function-type]

[1] https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wcast-function-type

Signed-off-by: Philip Lorenz <philip@bithub.de>
---
 ports/linux/pseudo_wrappers.c | 4 ++--
 pseudo_wrappers.c             | 2 +-
 templates/wrapper_table       | 8 ++++----
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/ports/linux/pseudo_wrappers.c b/ports/linux/pseudo_wrappers.c
index ed34115..7659897 100644
--- a/ports/linux/pseudo_wrappers.c
+++ b/ports/linux/pseudo_wrappers.c
@@ -96,7 +96,7 @@ syscall(long number, ...) {
 	 * guess about the number of args; the docs discuss calling conventions
 	 * up to 7, so let's try that?
 	 */
-	void *res = __builtin_apply((void (*)()) real_syscall, __builtin_apply_args(), sizeof(long) * 7);
+	void *res = __builtin_apply((void (*)(void)) real_syscall, __builtin_apply_args(), sizeof(long) * 7);
 	__builtin_return(res);
 }
 
@@ -137,7 +137,7 @@ prctl(int option, ...) {
 	 * guess about the number of args; the docs discuss calling conventions
 	 * up to 5, so let's try that?
 	 */
-	void *res = __builtin_apply((void (*)()) real_prctl, __builtin_apply_args(), sizeof(long) * 5);
+	void *res = __builtin_apply((void (*)(void)) real_prctl, __builtin_apply_args(), sizeof(long) * 5);
 	__builtin_return(res);
 }
 
diff --git a/pseudo_wrappers.c b/pseudo_wrappers.c
index 99aabff..9ae1200 100644
--- a/pseudo_wrappers.c
+++ b/pseudo_wrappers.c
@@ -140,7 +140,7 @@ pseudo_init_one_wrapper(pseudo_function *func) {
 #endif
 	f = dlsym(RTLD_NEXT, func->name);
 	if (f) {
-		*func->real = f;
+		*func->real = (void (*)(void)) f;
 	}
 	/* it turns out that in some cases, we get apparently-harmless
 	 * errors if a function is missing, and that printing output
diff --git a/templates/wrapper_table b/templates/wrapper_table
index bb30530..498ca81 100644
--- a/templates/wrapper_table
+++ b/templates/wrapper_table
@@ -6,8 +6,8 @@
  * script if you want to modify this. */
 typedef struct {
 	char *name;		/* the name */
-	int (**real)(void);	/* the underlying syscall */
-	int (*wrapper)(void);	/* the wrapper from guts/name.c */
+	void (**real)(void);	/* the underlying syscall */
+	void (*wrapper)(void);	/* the wrapper from guts/name.c */
 	char *version;		/* the version, if we know and care */
 } pseudo_function;
 
@@ -15,8 +15,8 @@ static pseudo_function pseudo_functions[] = {
 @body
 	{ /* ${comment}; */
 		"${name}${maybe_inode64}",
-		(int (**)(void)) &real_${name},
-		(int (*)(void)) wrap_${name},
+		(void (**)(void)) &real_${name},
+		(void (*)(void)) wrap_${name},
 		${version}
 	},
 @footer
-- 
2.31.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2021-05-17 19:22 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-05-17 19:22 [pseudo][PATCH] wrappers: Avoid -Wcast-function-type warning philip

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox