recognize binary constants
A message that is not in the archive (sent off-list or not yet received): 1315434714.1892.7.camel@marconi
A message that is not in the archive (sent off-list or not yet received): 20110908170734.GB17041@mwanda
A small change to your patch, Dan: I added a call to tolower(), since "0B11" is also a valid syntax.
-Kamal
---------------------------------------------------------------------------
From a9273391fe5f410321a0668e18beaebce086e23d Mon Sep 17 00:00:00 2001
From: Kamal Mostafa <[email protected]>
Date: Thu, 8 Sep 2011 10:34:27 -0700
Subject: [PATCH] recognize binary constants
Sparse doesn't parse binary constants properly so the following code generates an error:
x = 0b11;
test.c:5:17: error: constant 0b11 is not a valid number
--- expression.c | 9 ++++++++- 1 files changed, 8 insertions(+), 1 deletions(-)
expression.c +8 -1
@@ -268,6 +268,13 @@ static struct token *string_expression(struct token *token, struct expression *e#define ULLONG_MAX (~0ULL)#endif +static unsigned long long parse_num (const char *nptr,char **end) +{ +if (nptr[0 ] =='0' &&tolower (nptr[1 ]) =='b' ) +return strtoull (&nptr[2 ], end,2 ); +return strtoull (nptr, end,0 ); +} +static void get_number_value (struct expression *expr,struct token *token) {const char *str = token->number;
@@ -279,7 +286,7 @@ static void get_number_value(struct expression *expr, struct token *token)int bits; errno =0 ; - value =strtoull (str, &end,0 ); + value =parse_num (str, &end);if (end == str) goto Float;if (value ==ULLONG_MAX && errno ==ERANGE )
Signature · 1 line
1.7.4.1
Quoted 3 lines · Kamal Mostafa
A small change to your patch, Dan: I added a call to
tolower(), since "0B11" is also a valid syntax.
Doh... Good point. Thanks.
regards,
dan carpenter
Quoted 9 lines · Dan Carpenter
Sparse doesn't parse binary constants properly so the following code generates an error:
x = 0b11;test.c:5:17: error: constant 0b11 is not a valid number
Reported-by Kamal Mostafa <[email protected]>Signed-off-by Dan Carpenter <[email protected]>
I sent this patch before but the git tree was offline so everything was dead.
regards,
dan carpenter
Christopher Li
maintainerQuoted 6 lines · Dan Carpenter
Quoted 5 lines · Dan Carpenter
Sparse doesn't parse binary constants properly so the following code generates an error:
x = 0b11;
Quoted 7 lines
Quoted 4 lines
test.c:5:17: error: constant 0b11 is not a valid number
Reported-by Kamal Mostafa <[email protected]>Signed-off-by Dan Carpenter <[email protected]>I sent this patch before but the git tree was offline so everything was dead.
Thanks for the reminder. The patch looks fine.
I will apply it.
Chris
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html