* [PATCH] fix(3p/cgit): Fix compilation under Clang
@ 2020-06-01 9:10 Luke Granger-Brown
0 siblings, 0 replies; only message in thread
From: Luke Granger-Brown @ 2020-06-01 9:10 UTC (permalink / raw)
To: depot
From: Luke Granger-Brown <git@lukegb•com>
Clang treats function-like macros "correctly", in that, per the C11 spec:
"Each subsequent instance of the function-like macro name followed by a (
[...] is replaced by the replacement list [...]".
Additionally, fprintf is also permitted to be defined as a function-like
macro rather than as a true function: "Any function declared in a header
may be additionally implemented as a function-like macro defined in the
header [...]". The specification then suggests surrounding the name of the
function in parens to avoid this, which is the technique we use here to avoid
the function-like macro being invoked.
The other fix here is to use uintptr_t for some arithmetic, since Git
is expecting an int as the value here and not a pointer.
---
third_party/cgit/filter.c | 2 +-
third_party/cgit/parsing.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/third_party/cgit/filter.c b/third_party/cgit/filter.c
index 70f5b7499..181d9a892 100644
--- a/third_party/cgit/filter.c
+++ b/third_party/cgit/filter.c
@@ -385,7 +385,7 @@ int cgit_close_filter(struct cgit_filter *filter)
void cgit_fprintf_filter(struct cgit_filter *filter, FILE *f, const
char *prefix)
{
- filter->fprintf(filter, f, prefix);
+ (filter->fprintf)(filter, f, prefix);
}
diff --git a/third_party/cgit/parsing.c b/third_party/cgit/parsing.c
index 7b3980e6b..b4b5f904d 100644
--- a/third_party/cgit/parsing.c
+++ b/third_party/cgit/parsing.c
@@ -72,7 +72,7 @@ static void parse_user(const char *t, char **name,
char **email, unsigned long *
struct ident_split ident;
unsigned email_len;
- if (!split_ident_line(&ident, t, strchrnul(t, '\n') - t)) {
+ if (!split_ident_line(&ident, t, (uintptr_t)strchrnul(t, '\n')
- (uintptr_t)t)) {
*name = substr(ident.name_begin, ident.name_end);
email_len = ident.mail_end - ident.mail_begin;
--
2.25.1
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-06-01 9:10 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-01 9:10 [PATCH] fix(3p/cgit): Fix compilation under Clang Luke Granger-Brown
Code repositories for project(s) associated with this public inbox
https://code.tvl.fyi
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).