* [PATCH] sparse: make __builtin_object_size argument const
@ 2016-10-04 8:54 Johannes Berg
2016-10-04 8:55 ` Johannes Berg
0 siblings, 1 reply; 2+ messages in thread
From: Johannes Berg @ 2016-10-04 8:54 UTC (permalink / raw)
To: sparse; +Cc: linux-sparse
gcc clearly allows that, and this makes no difference since we
can still pass a non-const pointer without warnings.
Add a test for it, while at it.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
---
lib.c | 2 +-
validation/builtin_object_size.c | 13 +++++++++++++
2 files changed, 14 insertions(+), 1 deletion(-)
create mode 100644 validation/builtin_object_size.c
diff --git a/lib.c b/lib.c
index 8dc5bcf9dc18..cade28c95a48 100644
--- a/lib.c
+++ b/lib.c
@@ -877,7 +877,7 @@ void declare_builtin_functions(void)
add_pre_buffer("extern int __builtin_isunordered(float, float);\n");
/* And some __FORTIFY_SOURCE ones.. */
- add_pre_buffer ("extern __SIZE_TYPE__ __builtin_object_size(void *, int);\n");
+ add_pre_buffer ("extern __SIZE_TYPE__ __builtin_object_size(const void *, int);\n");
add_pre_buffer ("extern void * __builtin___memcpy_chk(void *, const void *, __SIZE_TYPE__, __SIZE_TYPE__);\n");
add_pre_buffer ("extern void * __builtin___memmove_chk(void *, const void *, __SIZE_TYPE__, __SIZE_TYPE__);\n");
add_pre_buffer ("extern void * __builtin___mempcpy_chk(void *, const void *, __SIZE_TYPE__, __SIZE_TYPE__);\n");
diff --git a/validation/builtin_object_size.c b/validation/builtin_object_size.c
new file mode 100644
index 000000000000..a7013a80e7fd
--- /dev/null
+++ b/validation/builtin_object_size.c
@@ -0,0 +1,13 @@
+static void fn(void)
+{
+ static int i;
+ const void *ptr = (void *)0;
+
+ i = __builtin_object_size(ptr, 0);
+}
+
+/*
+ * check-name: __builtin_object_size
+ * check-error-start
+ * check-error-end
+ */
--
2.8.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] sparse: make __builtin_object_size argument const
2016-10-04 8:54 [PATCH] sparse: make __builtin_object_size argument const Johannes Berg
@ 2016-10-04 8:55 ` Johannes Berg
0 siblings, 0 replies; 2+ messages in thread
From: Johannes Berg @ 2016-10-04 8:55 UTC (permalink / raw)
To: sparse; +Cc: linux-sparse, Lance Richardson
On Tue, 2016-10-04 at 10:54 +0200, Johannes Berg wrote:
> gcc clearly allows that, and this makes no difference since we
> can still pass a non-const pointer without warnings.
>
> Add a test for it, while at it.
Oh, now I see Lance already sent this patch, sorry. I have a test, if
you like that better, but whatever. Would be nice if you could apply
either one though :)
Thanks,
johannes
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-10-04 8:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-04 8:54 [PATCH] sparse: make __builtin_object_size argument const Johannes Berg
2016-10-04 8:55 ` Johannes Berg
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).