All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] add some builtin types for printf format checking
@ 2020-10-04 11:43 Luc Van Oostenryck
  2020-10-04 11:43 ` [PATCH 1/3] add builtin type for wide strings Luc Van Oostenryck
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Luc Van Oostenryck @ 2020-10-04 11:43 UTC (permalink / raw)
  To: linux-sparse; +Cc: Ben Dooks, Luc Van Oostenryck

The checking of printf format strings needs a few more builtin types.
For example, a type for wide string is needed for "%Ls" and more are
needed to support "%n" with the different possible lenght modifiers.


Luc Van Oostenryck (3):
  add builtin type for wide strings
  add builtin types for signed char* and short *
  add builtin types for size_t*, intmax_t* & ptrdiff_t*

 symbol.c | 19 +++++++++++++++++++
 symbol.h |  3 +++
 2 files changed, 22 insertions(+)

-- 
2.28.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/3] add builtin type for wide strings
  2020-10-04 11:43 [PATCH 0/3] add some builtin types for printf format checking Luc Van Oostenryck
@ 2020-10-04 11:43 ` Luc Van Oostenryck
  2020-10-04 11:43 ` [PATCH 2/3] add builtin types for signed char* and short * Luc Van Oostenryck
  2020-10-04 11:43 ` [PATCH 3/3] add builtin types for size_t*, intmax_t* & ptrdiff_t* Luc Van Oostenryck
  2 siblings, 0 replies; 4+ messages in thread
From: Luc Van Oostenryck @ 2020-10-04 11:43 UTC (permalink / raw)
  To: linux-sparse; +Cc: Ben Dooks, Luc Van Oostenryck

This is needed for printf format checking of "%Ls".

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 symbol.c | 8 ++++++++
 symbol.h | 1 +
 2 files changed, 9 insertions(+)

diff --git a/symbol.c b/symbol.c
index 7f0c85580f06..9065bd527d60 100644
--- a/symbol.c
+++ b/symbol.c
@@ -790,6 +790,7 @@ struct symbol	float64_ctype, float64x_ctype;
 struct symbol	float128_ctype;
 struct symbol	const_void_ctype, const_char_ctype;
 struct symbol	const_ptr_ctype, const_string_ctype;
+struct symbol	const_wchar_ctype, const_wstring_ctype;
 
 struct symbol	zero_int;
 
@@ -884,9 +885,11 @@ static const struct ctype_declare {
 	{ &ullong_ptr_ctype,   T_PTR(&ullong_ctype) },
 	{ &const_ptr_ctype,    T_PTR(&const_void_ctype) },
 	{ &const_string_ctype, T_PTR(&const_char_ctype) },
+	{ &const_wstring_ctype,T_PTR(&const_wchar_ctype) },
 
 	{ &const_void_ctype,   T_CONST(&void_ctype, NULL, NULL) },
 	{ &const_char_ctype,   T_CONST(&char_ctype, &bits_in_char, &max_int_alignment)},
+	{ &const_wchar_ctype,  T_CONST(&int_ctype, NULL, NULL) },
 	{ NULL, }
 };
 
@@ -931,4 +934,9 @@ void init_ctype(void)
 		intptr_ctype = ssize_t_ctype;
 	if (!uintptr_ctype)
 		uintptr_ctype = size_t_ctype;
+
+	const_wchar_ctype.ctype.base_type = wchar_ctype;
+	const_wchar_ctype.rank = wchar_ctype->rank;
+	const_wchar_ctype.ctype.alignment = wchar_ctype->ctype.alignment;
+	const_wchar_ctype.bit_size = wchar_ctype->bit_size;
 }
diff --git a/symbol.h b/symbol.h
index a3ed95678ee5..f82484f5c978 100644
--- a/symbol.h
+++ b/symbol.h
@@ -306,6 +306,7 @@ extern struct symbol	float64_ctype, float64x_ctype;
 extern struct symbol	float128_ctype;
 extern struct symbol	const_void_ctype, const_char_ctype;
 extern struct symbol	const_ptr_ctype, const_string_ctype;
+extern struct symbol	const_wchar_ctype, const_wstring_ctype;
 
 /* Special internal symbols */
 extern struct symbol	zero_int;
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/3] add builtin types for signed char* and short *
  2020-10-04 11:43 [PATCH 0/3] add some builtin types for printf format checking Luc Van Oostenryck
  2020-10-04 11:43 ` [PATCH 1/3] add builtin type for wide strings Luc Van Oostenryck
@ 2020-10-04 11:43 ` Luc Van Oostenryck
  2020-10-04 11:43 ` [PATCH 3/3] add builtin types for size_t*, intmax_t* & ptrdiff_t* Luc Van Oostenryck
  2 siblings, 0 replies; 4+ messages in thread
From: Luc Van Oostenryck @ 2020-10-04 11:43 UTC (permalink / raw)
  To: linux-sparse; +Cc: Ben Dooks, Luc Van Oostenryck

This is needed for printf format checking of "%hhn" & "%hn".

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

diff --git a/symbol.c b/symbol.c
index 9065bd527d60..a29e0b140d16 100644
--- a/symbol.c
+++ b/symbol.c
@@ -782,6 +782,7 @@ struct symbol	bool_ctype, void_ctype, type_ctype,
 		incomplete_ctype, label_ctype, bad_ctype,
 		null_ctype;
 struct symbol	autotype_ctype;
+struct symbol	schar_ptr_ctype, short_ptr_ctype;
 struct symbol	int_ptr_ctype, uint_ptr_ctype;
 struct symbol	long_ptr_ctype, ulong_ptr_ctype;
 struct symbol	llong_ptr_ctype, ullong_ptr_ctype;
@@ -877,6 +878,8 @@ static const struct ctype_declare {
 	{ &null_ctype,         T_PTR(&void_ctype) },
 	{ &label_ctype,        T_PTR(&void_ctype) },
 	{ &lazy_ptr_ctype,     T_PTR(&void_ctype) },
+	{ &schar_ptr_ctype,    T_PTR(&schar_ctype) },
+	{ &short_ptr_ctype,    T_PTR(&short_ctype) },
 	{ &int_ptr_ctype,      T_PTR(&int_ctype) },
 	{ &uint_ptr_ctype,     T_PTR(&uint_ctype) },
 	{ &long_ptr_ctype,     T_PTR(&long_ctype) },
diff --git a/symbol.h b/symbol.h
index f82484f5c978..d39048cb478d 100644
--- a/symbol.h
+++ b/symbol.h
@@ -298,6 +298,7 @@ extern struct symbol	bool_ctype, void_ctype, type_ctype,
 			incomplete_ctype, label_ctype, bad_ctype,
 			null_ctype;
 extern struct symbol	autotype_ctype;
+extern struct symbol	schar_ptr_ctype, short_ptr_ctype;
 extern struct symbol	int_ptr_ctype, uint_ptr_ctype;
 extern struct symbol	long_ptr_ctype, ulong_ptr_ctype;
 extern struct symbol	llong_ptr_ctype, ullong_ptr_ctype;
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 3/3] add builtin types for size_t*, intmax_t* & ptrdiff_t*
  2020-10-04 11:43 [PATCH 0/3] add some builtin types for printf format checking Luc Van Oostenryck
  2020-10-04 11:43 ` [PATCH 1/3] add builtin type for wide strings Luc Van Oostenryck
  2020-10-04 11:43 ` [PATCH 2/3] add builtin types for signed char* and short * Luc Van Oostenryck
@ 2020-10-04 11:43 ` Luc Van Oostenryck
  2 siblings, 0 replies; 4+ messages in thread
From: Luc Van Oostenryck @ 2020-10-04 11:43 UTC (permalink / raw)
  To: linux-sparse; +Cc: Ben Dooks, Luc Van Oostenryck

This is needed for printf format checking of "%zn", "%jn" & "%tn".

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 symbol.c | 8 ++++++++
 symbol.h | 1 +
 2 files changed, 9 insertions(+)

diff --git a/symbol.c b/symbol.c
index a29e0b140d16..130071ab0381 100644
--- a/symbol.c
+++ b/symbol.c
@@ -786,6 +786,7 @@ struct symbol	schar_ptr_ctype, short_ptr_ctype;
 struct symbol	int_ptr_ctype, uint_ptr_ctype;
 struct symbol	long_ptr_ctype, ulong_ptr_ctype;
 struct symbol	llong_ptr_ctype, ullong_ptr_ctype;
+struct symbol	size_t_ptr_ctype, intmax_ptr_ctype, ptrdiff_ptr_ctype;
 struct symbol	float32_ctype, float32x_ctype;
 struct symbol	float64_ctype, float64x_ctype;
 struct symbol	float128_ctype;
@@ -886,6 +887,9 @@ static const struct ctype_declare {
 	{ &ulong_ptr_ctype,    T_PTR(&ulong_ctype) },
 	{ &llong_ptr_ctype,    T_PTR(&llong_ctype) },
 	{ &ullong_ptr_ctype,   T_PTR(&ullong_ctype) },
+	{ &size_t_ptr_ctype,   T_PTR(&void_ctype) },	// will be adjusted
+	{ &intmax_ptr_ctype,   T_PTR(&void_ctype) },	// will be adjusted
+	{ &ptrdiff_ptr_ctype,  T_PTR(&void_ctype) },	// will be adjusted
 	{ &const_ptr_ctype,    T_PTR(&const_void_ctype) },
 	{ &const_string_ctype, T_PTR(&const_char_ctype) },
 	{ &const_wstring_ctype,T_PTR(&const_wchar_ctype) },
@@ -938,6 +942,10 @@ void init_ctype(void)
 	if (!uintptr_ctype)
 		uintptr_ctype = size_t_ctype;
 
+	size_t_ptr_ctype.ctype.base_type = size_t_ctype;
+	intmax_ptr_ctype.ctype.base_type = intmax_ctype;
+	ptrdiff_ptr_ctype.ctype.base_type = ptrdiff_ctype;
+
 	const_wchar_ctype.ctype.base_type = wchar_ctype;
 	const_wchar_ctype.rank = wchar_ctype->rank;
 	const_wchar_ctype.ctype.alignment = wchar_ctype->ctype.alignment;
diff --git a/symbol.h b/symbol.h
index d39048cb478d..6d25e7fc8bad 100644
--- a/symbol.h
+++ b/symbol.h
@@ -302,6 +302,7 @@ extern struct symbol	schar_ptr_ctype, short_ptr_ctype;
 extern struct symbol	int_ptr_ctype, uint_ptr_ctype;
 extern struct symbol	long_ptr_ctype, ulong_ptr_ctype;
 extern struct symbol	llong_ptr_ctype, ullong_ptr_ctype;
+extern struct symbol	size_t_ptr_ctype, intmax_ptr_ctype, ptrdiff_ptr_ctype;
 extern struct symbol	float32_ctype, float32x_ctype;
 extern struct symbol	float64_ctype, float64x_ctype;
 extern struct symbol	float128_ctype;
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-10-04 11:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-04 11:43 [PATCH 0/3] add some builtin types for printf format checking Luc Van Oostenryck
2020-10-04 11:43 ` [PATCH 1/3] add builtin type for wide strings Luc Van Oostenryck
2020-10-04 11:43 ` [PATCH 2/3] add builtin types for signed char* and short * Luc Van Oostenryck
2020-10-04 11:43 ` [PATCH 3/3] add builtin types for size_t*, intmax_t* & ptrdiff_t* Luc Van Oostenryck

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.