From: "Carlo Marcelo Arenas Belón" <carenas@gmail.com>
To: git@vger.kernel.org
Cc: j6t@kdbg.org, gitster@pobox.com, avarab@gmail.com,
jonathantanmy@google.com, ramsay@ramsayjones.plus.com,
"Carlo Marcelo Arenas Belón" <carenas@gmail.com>
Subject: [PATCH v5 1/3] lazyload.h: fix warnings about mismatching function pointer types
Date: Tue, 28 Sep 2021 20:19:38 -0700 [thread overview]
Message-ID: <20210929031940.97092-2-carenas@gmail.com> (raw)
In-Reply-To: <20210929031940.97092-1-carenas@gmail.com>
From: Johannes Sixt <j6t@kdbg.org>
Here, GCC warns about every use of the INIT_PROC_ADDR macro, for example:
In file included from compat/mingw.c:8:
compat/mingw.c: In function 'mingw_strftime':
compat/win32/lazyload.h:38:12: warning: assignment to
'size_t (*)(char *, size_t, const char *, const struct tm *)'
{aka 'long long unsigned int (*)(char *, long long unsigned int,
const char *, const struct tm *)'} from incompatible pointer type
'FARPROC' {aka 'long long int (*)()'} [-Wincompatible-pointer-types]
38 | (function = get_proc_addr(&proc_addr_##function))
| ^
compat/mingw.c:1014:6: note: in expansion of macro 'INIT_PROC_ADDR'
1014 | if (INIT_PROC_ADDR(strftime))
| ^~~~~~~~~~~~~~
(message wrapped for convenience). Insert a cast to keep the compiler
happy. A cast is fine in these cases because they are generic function
pointer values that have been looked up in a DLL.
Helped-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
compat/win32/lazyload.h | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/compat/win32/lazyload.h b/compat/win32/lazyload.h
index d2056cdadf..121ee24ed2 100644
--- a/compat/win32/lazyload.h
+++ b/compat/win32/lazyload.h
@@ -26,7 +26,8 @@ struct proc_addr {
#define DECLARE_PROC_ADDR(dll, rettype, function, ...) \
static struct proc_addr proc_addr_##function = \
{ #dll, #function, NULL, 0 }; \
- static rettype (WINAPI *function)(__VA_ARGS__)
+ typedef rettype (WINAPI *proc_type_##function)(__VA_ARGS__); \
+ static proc_type_##function function
/*
* Loads a function from a DLL (once-only).
@@ -35,7 +36,7 @@ struct proc_addr {
* This function is not thread-safe.
*/
#define INIT_PROC_ADDR(function) \
- (function = get_proc_addr(&proc_addr_##function))
+ (function = (proc_type_##function)get_proc_addr(&proc_addr_##function))
static inline FARPROC get_proc_addr(struct proc_addr *proc)
{
--
2.33.0.955.gee03ddbf0e
next prev parent reply other threads:[~2021-09-29 3:19 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-22 19:56 [PATCH cb/pedantic-build-for-developers] lazyload.h: fix warnings about mismatching function pointer types Johannes Sixt
2021-09-22 20:16 ` Carlo Arenas
2021-09-22 21:21 ` Johannes Sixt
2021-09-23 6:20 ` Carlo Arenas
2021-09-23 6:03 ` [PATCH] lazyload.h: use an even more generic function pointer than FARPROC Carlo Marcelo Arenas Belón
2021-09-23 6:33 ` Johannes Sixt
2021-09-23 6:49 ` Carlo Arenas
2021-09-23 6:52 ` [PATCH v2] " Carlo Marcelo Arenas Belón
2021-09-26 10:05 ` [PATCH v3 0/2] js/win-lazyload-buildfix Carlo Marcelo Arenas Belón
2021-09-26 10:05 ` [PATCH v3 1/2] lazyload.h: fix warnings about mismatching function pointer types Carlo Marcelo Arenas Belón
2021-09-27 2:58 ` Eric Sunshine
2021-09-26 10:05 ` [PATCH v3 2/2] lazyload.h: use an even more generic function pointer than FARPROC Carlo Marcelo Arenas Belón
2021-09-27 16:35 ` Junio C Hamano
2021-09-27 18:50 ` Carlo Arenas
2021-09-27 20:13 ` Junio C Hamano
2021-09-29 0:48 ` [PATCH v4 0/3] js/win-lazyload-buildfix Carlo Marcelo Arenas Belón
2021-09-29 0:48 ` [PATCH v4 1/3] lazyload.h: fix warnings about mismatching function pointer types Carlo Marcelo Arenas Belón
2021-09-29 0:48 ` [PATCH v4 2/3] lazyload.h: use an even more generic function pointer than FARPROC Carlo Marcelo Arenas Belón
2021-09-29 0:48 ` [PATCH v4 3/3] Makefile: restrict -Wpedantic and -Wno-pedantic-ms-format better Carlo Marcelo Arenas Belón
2021-09-29 1:14 ` Ramsay Jones
2021-09-29 3:19 ` [PATCH v5 0/3] js/win-lazyload-buildfix Carlo Marcelo Arenas Belón
2021-09-29 3:19 ` Carlo Marcelo Arenas Belón [this message]
2021-09-29 3:19 ` [PATCH v5 2/3] lazyload.h: use an even more generic function pointer than FARPROC Carlo Marcelo Arenas Belón
2021-09-29 3:19 ` [PATCH v5 3/3] Makefile: restrict -Wpedantic and -Wno-pedantic-ms-format better Carlo Marcelo Arenas Belón
2021-09-23 21:00 ` [PATCH cb/pedantic-build-for-developers] lazyload.h: fix warnings about mismatching function pointer types Carlo Arenas
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210929031940.97092-2-carenas@gmail.com \
--to=carenas@gmail.com \
--cc=avarab@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=j6t@kdbg.org \
--cc=jonathantanmy@google.com \
--cc=ramsay@ramsayjones.plus.com \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).