linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
To: linux-sparse@vger.kernel.org
Cc: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Subject: [PATCH 1/3] fix hardcoded size of wide chars
Date: Fri, 19 May 2017 13:20:51 +0200	[thread overview]
Message-ID: <20170519112053.24632-2-luc.vanoostenryck@gmail.com> (raw)
In-Reply-To: <20170519112053.24632-1-luc.vanoostenryck@gmail.com>

The size of wide chars was hardcoded to 32.

Fix this by using a variable to hold this 'bits_in_wchar',
like done for all others datatypes.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 char.c   | 4 ++--
 target.c | 2 ++
 target.h | 2 ++
 3 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/char.c b/char.c
index e2b3863be..c52521bc8 100644
--- a/char.c
+++ b/char.c
@@ -84,7 +84,7 @@ void get_char_constant(struct token *token, unsigned long long *val)
 		end = p + type - TOKEN_WIDE_CHAR;
 	}
 	p = parse_escape(p, &v, end,
-			type < TOKEN_WIDE_CHAR ? bits_in_char : 32, token->pos);
+			type < TOKEN_WIDE_CHAR ? bits_in_char : bits_in_wchar, token->pos);
 	if (p != end)
 		warning(token->pos,
 			"multi-character character constant");
@@ -113,7 +113,7 @@ struct token *get_string_constant(struct token *token, struct expression *expr)
 			done = next;
 		}
 	}
-	bits = is_wide ? 32 : bits_in_char;
+	bits = is_wide ? bits_in_wchar : bits_in_char;
 	while (token != done) {
 		unsigned v;
 		const char *p = token->string->data;
diff --git a/target.c b/target.c
index 17b228ae9..86a9e2e63 100644
--- a/target.c
+++ b/target.c
@@ -22,6 +22,8 @@ int bits_in_long = 32;
 int bits_in_longlong = 64;
 int bits_in_longlonglong = 128;
 
+int bits_in_wchar = 32;
+
 int max_int_alignment = 4;
 
 /*
diff --git a/target.h b/target.h
index 78c85cf7e..8326fa21a 100644
--- a/target.h
+++ b/target.h
@@ -20,6 +20,8 @@ extern int bits_in_long;
 extern int bits_in_longlong;
 extern int bits_in_longlonglong;
 
+extern int bits_in_wchar;
+
 extern int max_int_alignment;
 
 /*
-- 
2.13.0


  reply	other threads:[~2017-05-19 11:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-19 11:20 [PATCH 0/3] use internal size for __INT_MAX__ & friends Luc Van Oostenryck
2017-05-19 11:20 ` Luc Van Oostenryck [this message]
2017-05-19 11:20 ` [PATCH 2/3] avoid to redefine __INT_MAX__ and friends Luc Van Oostenryck
2017-05-19 11:20 ` [PATCH 3/3] fix definition of __SCHAR_MAX__ & friends Luc Van Oostenryck

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=20170519112053.24632-2-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).