[PATCH 5/6] wstring: extend is_string_type() to also detect wide strings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When evaluating initializers, it must be known if it is for a string
or not. But sparse doesn't known about wide strings.

Fix this by modifying is_string_type() to use is_wchar_type()
in addition of is_byte_type().

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
---
 evaluate.c                | 5 ++++-
 validation/init-wstring.c | 1 -
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/evaluate.c b/evaluate.c
index bbfa77c3a79d..8d09c560e7fe 100644
--- a/evaluate.c
+++ b/evaluate.c
@@ -406,7 +406,10 @@ static inline int is_string_type(struct symbol *type)
 {
 	if (type->type == SYM_NODE)
 		type = type->ctype.base_type;
-	return type->type == SYM_ARRAY && is_byte_type(type->ctype.base_type);
+	if (type->type != SYM_ARRAY)
+		return 0;
+	type = type->ctype.base_type;
+	return is_byte_type(type) || is_wchar_type(type);
 }
 
 static struct symbol *bad_expr_type(struct expression *expr)
diff --git a/validation/init-wstring.c b/validation/init-wstring.c
index 846b6e2c3efd..d9ce3b3c883b 100644
--- a/validation/init-wstring.c
+++ b/validation/init-wstring.c
@@ -32,7 +32,6 @@ static const __WCHAR_TYPE__ ko2[2] = L"abc";
 /*
  * check-name: init-wstring
  * check-command: sparse -Winit-cstring $file
- * check-known-to-fail
  *
  * check-error-start
 init-wstring.c:29:38: warning: too long initializer-string for array of char(no space for nul char)
-- 
2.28.0




[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux