TVL depot development (mail to depot@tvl.su)
 help / color / mirror / code / Atom feed
From: Luke Granger-Brown <lukegb@lukegb•com>
To: depot@tazj.in
Subject: [PATCH] fix(3p/cgit): Fix compilation under Clang
Date: Mon, 1 Jun 2020 10:10:34 +0100	[thread overview]
Message-ID: <CALE3ZjXiSBJpXLXWJ8a+f8WER6OaGooMXObL2EzQaoY_QzM4kw@mail.gmail.com> (raw)

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



                 reply	other threads:[~2020-06-01  9:10 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=CALE3ZjXiSBJpXLXWJ8a+f8WER6OaGooMXObL2EzQaoY_QzM4kw@mail.gmail.com \
    --to=lukegb@lukegb$(echo .)com \
    --cc=depot@tazj.in \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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://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).