From: philip@bithub.de
To: openembedded-core@lists.openembedded.org
Cc: Philip Lorenz <philip@bithub.de>
Subject: [pseudo][PATCH] wrappers: Avoid -Wcast-function-type warning
Date: Mon, 17 May 2021 21:22:46 +0200 [thread overview]
Message-ID: <20210517192246.47874-1-philip@bithub.de> (raw)
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
reply other threads:[~2021-05-17 19:22 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210517192246.47874-1-philip@bithub.de \
--to=philip@bithub.de \
--cc=openembedded-core@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox