diff options
| author | Greg Steuck <greg@nest.cx> | 2022-09-04 09:11:23 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2022-09-05 10:51:00 +0200 |
| commit | 922294abb4c0bc72b24d8526d625110d73fa1b5a (patch) | |
| tree | a723c3df5be67c6d3dbc3eb1fe6fe13aa162117f | |
| parent | 4b7a93a60c7dd4f6ef7dd11c83ba528bd751cb5f (diff) | |
pkg/csource: inline void* cast into generated code
The previous indirection via conditional macros in platform specific
places was needless obfuscation.
| -rw-r--r-- | executor/common_fuchsia.h | 4 | ||||
| -rw-r--r-- | executor/common_linux.h | 3 | ||||
| -rw-r--r-- | pkg/csource/csource.go | 2 | ||||
| -rw-r--r-- | pkg/csource/generated.go | 2 |
4 files changed, 1 insertions, 10 deletions
diff --git a/executor/common_fuchsia.h b/executor/common_fuchsia.h index cb29f715e..19bdd280c 100644 --- a/executor/common_fuchsia.h +++ b/executor/common_fuchsia.h @@ -272,7 +272,3 @@ static int do_sandbox_none(void) return 0; } #endif - -// Ugly way to work around gcc's "error: function called through a non-compatible type". -// The macro is used in generated C code. -#define CAST(f) ({void* p = (void*)f; p; }) diff --git a/executor/common_linux.h b/executor/common_linux.h index 21bde3bb6..0cc94555f 100644 --- a/executor/common_linux.h +++ b/executor/common_linux.h @@ -4857,9 +4857,6 @@ static void setup_802154() #if GOARCH_s390x #include <sys/mman.h> -// Ugly way to work around gcc's "error: function called through a non-compatible type". -// The macro is used in generated C code. -#define CAST(f) ({void* p = (void*)f; p; }) #endif #if SYZ_EXECUTOR || __NR_syz_fuse_handle_req diff --git a/pkg/csource/csource.go b/pkg/csource/csource.go index 8671a57db..cec1d7847 100644 --- a/pkg/csource/csource.go +++ b/pkg/csource/csource.go @@ -343,7 +343,7 @@ func (ctx *context) emitCallBody(w *bytes.Buffer, call prog.ExecCall, native boo if args != "" { args = args[1:] } - fmt.Fprintf(w, "((intptr_t(*)(%v))CAST(%v))(", args, callName) + fmt.Fprintf(w, "((intptr_t(*)(%v))(void*)(%v))(", args, callName) } for ai, arg := range call.Args { if native || ai > 0 { diff --git a/pkg/csource/generated.go b/pkg/csource/generated.go index 874c8d72d..9e413e508 100644 --- a/pkg/csource/generated.go +++ b/pkg/csource/generated.go @@ -2312,7 +2312,6 @@ static int do_sandbox_none(void) return 0; } #endif -#define CAST(f) ({void* p = (void*)f; p; }) #elif GOOS_linux @@ -10414,7 +10413,6 @@ static void setup_802154() #if GOARCH_s390x #include <sys/mman.h> -#define CAST(f) ({void* p = (void*)f; p; }) #endif #if SYZ_EXECUTOR || __NR_syz_fuse_handle_req |
