From: Ke Du <duke@naive.systems>
To: luc.vanoostenryck@gmail.com
Cc: linux-sparse@vger.kernel.org, Ke Du <duke@naive.systems>,
Xiao Jia <xjia@naive.systems>
Subject: [PATCH 2/2] make implicit type conversion explicit
Date: Thu, 12 Aug 2021 20:25:11 -0500 [thread overview]
Message-ID: <20210813012511.65397-3-duke@naive.systems> (raw)
In-Reply-To: <20210813012511.65397-1-duke@naive.systems>
Make implicit type converison from void* to other types explicit so
ptrlist.h and token.h can be included as C++ library. Without this
change, when including these in C++, clang complains that it cannot
initialize return object of a more specific type with an lvalue of type
void*.
Signed-off-by: Ke Du <duke@naive.systems>
Reviewed-by: Xiao Jia <xjia@naive.systems>
---
ptrlist.h | 2 +-
token.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/ptrlist.h b/ptrlist.h
index 67c7a208..9fd20f84 100644
--- a/ptrlist.h
+++ b/ptrlist.h
@@ -303,7 +303,7 @@ extern void split_ptr_list_head(struct ptr_list *);
static inline void update_tag(void *p, unsigned long tag)
{
- unsigned long *ptr = p;
+ unsigned long *ptr = (unsigned long *)p;
*ptr = tag | (~3UL & *ptr);
}
diff --git a/token.h b/token.h
index 804cc6f8..7a97a478 100644
--- a/token.h
+++ b/token.h
@@ -204,7 +204,7 @@ struct token {
static inline struct token *containing_token(struct token **p)
{
void *addr = (char *)p - ((char *)&((struct token *)0)->next - (char *)0);
- return addr;
+ return (struct token *)addr;
}
#define token_type(x) ((x)->pos.type)
--
2.31.1
prev parent reply other threads:[~2021-08-13 1:26 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-22 6:45 check idea: include sparse as a library in C++ Ke Du
2021-07-26 18:28 ` Luc Van Oostenryck
2021-08-13 1:25 ` [PATCH 0/2] fixes for using sparse as a C++ library Ke Du
2021-08-13 1:25 ` [PATCH 1/2] expose more functions to C++ in header files Ke Du
2021-11-17 9:44 ` Xiao Jia
2021-08-13 1:25 ` Ke Du [this message]
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=20210813012511.65397-3-duke@naive.systems \
--to=duke@naive.systems \
--cc=linux-sparse@vger.kernel.org \
--cc=luc.vanoostenryck@gmail.com \
--cc=xjia@naive.systems \
/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;
as well as URLs for NNTP newsgroup(s).