From: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
To: linux-sparse@vger.kernel.org
Cc: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Subject: [PATCH 2/2] predefine: fix multi-token predefine
Date: Sun, 5 Jul 2020 15:11:46 +0200 [thread overview]
Message-ID: <20200705131146.26439-3-luc.vanoostenryck@gmail.com> (raw)
In-Reply-To: <20200705131146.26439-1-luc.vanoostenryck@gmail.com>
The function predefine() and its variants are only valid
if they define a single-token value.
However, when a type is signed, predefine_min() will produce
a multi-token value.
Fix this by using add_pre_buffer() instead of predefine().
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
predefine.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/predefine.c b/predefine.c
index ff457b389480..d05b1018fdce 100644
--- a/predefine.c
+++ b/predefine.c
@@ -52,7 +52,7 @@ static void predefined_min(const char *name, struct symbol *type)
snprintf(buf, sizeof(buf), "__%s_MIN__", name);
if (is_signed_type(type))
- predefine(buf, 1, "(-__%s_MAX__ - 1)", name);
+ add_pre_buffer("#weak_define %s (-__%s_MAX__ - 1)\n", buf, name);
else
predefine(buf, 1, "0%s", suffix);
}
--
2.27.0
prev parent reply other threads:[~2020-07-05 13:11 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-05 13:11 [PATCH 0/2] predefine: fix multi-token predefine Luc Van Oostenryck
2020-07-05 13:11 ` [PATCH 1/2] predefine: add testcase for multi-token predefines Luc Van Oostenryck
2020-07-05 13:11 ` Luc Van Oostenryck [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=20200705131146.26439-3-luc.vanoostenryck@gmail.com \
--to=luc.vanoostenryck@gmail.com \
--cc=linux-sparse@vger.kernel.org \
/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).