Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1320754 > unrolled thread

[PATCH tip v6 2/5] kbuild: Add option to turn incompatible pointer check into error

Started byDaniel Wagner <daniel.wagner@bmw-carit.de>
First post2016-01-28 16:00 +0100
Last post2016-02-07 05:50 +0100
Articles 6 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH tip v6 2/5] kbuild: Add option to turn incompatible pointer check into error Daniel Wagner <daniel.wagner@bmw-carit.de> - 2016-01-28 16:00 +0100
    Re: [PATCH tip v6 2/5] kbuild: Add option to turn incompatible  pointer check into error Daniel Wagner <daniel.wagner@bmw-carit.de> - 2016-01-29 13:30 +0100
      Re: [PATCH tip v6 2/5] kbuild: Add option to turn incompatible  pointer check into error Paul Gortmaker <paul.gortmaker@windriver.com> - 2016-01-29 20:00 +0100
        Re: [PATCH tip v6 2/5] kbuild: Add option to turn incompatible  pointer check into error Daniel Wagner <daniel.wagner@bmw-carit.de> - 2016-02-01 07:50 +0100
          Re: [PATCH tip v6 2/5] kbuild: Add option to turn incompatible  pointer check into error Daniel Wagner <daniel.wagner@bmw-carit.de> - 2016-02-05 09:20 +0100
            Re: [PATCH tip v6 2/5] kbuild: Add option to turn incompatible  pointer check into error Paul Gortmaker <paul.gortmaker@windriver.com> - 2016-02-07 05:50 +0100

#1320754 — [PATCH tip v6 2/5] kbuild: Add option to turn incompatible pointer check into error

FromDaniel Wagner <daniel.wagner@bmw-carit.de>
Date2016-01-28 16:00 +0100
Subject[PATCH tip v6 2/5] kbuild: Add option to turn incompatible pointer check into error
Message-ID<qVWdc-4Sp-17@gated-at.bofh.it>
With the introduction of the simple wait API we have two very
similar APIs in the kernel. For example wake_up() and swake_up()
is only one character away. Although the compiler will warn
happily the wrong usage it keeps on going an even links the kernel.
Thomas and Peter would rather like to see early missuses reported
as error early on.

In a first attempt we tried to wrap all swait and wait calls
into a macro which has an compile time type assertion. The result
was pretty ugly and wasn't able to catch all wrong usages.
woken_wake_function(), autoremove_wake_function() and wake_bit_function()
are assigned as function pointers. Wrapping them with a macro around is
not possible. Prefixing them with '_' was also not a real option
because there some users in the kernel which do use them as well.
All in all this attempt looked to intrusive and too ugly.

An alternative is to turn the pointer type check into an error which
catches wrong type uses. Obviously not only the swait/wait ones. That
isn't a bad thing either.

Signed-off-by: Daniel Wagner <daniel.wagner@bmw-carit.de>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
---
 Makefile | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/Makefile b/Makefile
index 9d94ade..653fd08 100644
--- a/Makefile
+++ b/Makefile
@@ -767,6 +767,9 @@ KBUILD_CFLAGS   += $(call cc-option,-Werror=strict-prototypes)
 # Prohibit date/time macros, which would make the build non-deterministic
 KBUILD_CFLAGS   += $(call cc-option,-Werror=date-time)
 
+# enforce correct pointer usage
+KBUILD_CFLAGS += $(call cc-option,-Werror=incompatible-pointer-types)
+
 # use the deterministic mode of AR if available
 KBUILD_ARFLAGS := $(call ar-option,D)
 
-- 
2.5.0

[toc] | [next] | [standalone]


#1321725 — Re: [PATCH tip v6 2/5] kbuild: Add option to turn incompatible pointer check into error

FromDaniel Wagner <daniel.wagner@bmw-carit.de>
Date2016-01-29 13:30 +0100
SubjectRe: [PATCH tip v6 2/5] kbuild: Add option to turn incompatible pointer check into error
Message-ID<qWglA-2Vi-9@gated-at.bofh.it>
In reply to#1320754
On 01/28/2016 03:44 PM, Daniel Wagner wrote:
> +# enforce correct pointer usage
> +KBUILD_CFLAGS += $(call cc-option,-Werror=incompatible-pointer-types)
> +

As it turns out there are a few fallouts by that one. I'll send fixes
for it.

[toc] | [prev] | [next] | [standalone]


#1322000 — Re: [PATCH tip v6 2/5] kbuild: Add option to turn incompatible pointer check into error

FromPaul Gortmaker <paul.gortmaker@windriver.com>
Date2016-01-29 20:00 +0100
SubjectRe: [PATCH tip v6 2/5] kbuild: Add option to turn incompatible pointer check into error
Message-ID<qWmr1-7on-33@gated-at.bofh.it>
In reply to#1321725
[Re: [PATCH tip v6 2/5] kbuild: Add option to turn incompatible pointer check into error] On 29/01/2016 (Fri 13:17) Daniel Wagner wrote:

> On 01/28/2016 03:44 PM, Daniel Wagner wrote:
> > +# enforce correct pointer usage
> > +KBUILD_CFLAGS += $(call cc-option,-Werror=incompatible-pointer-types)
> > +
> 
> As it turns out there are a few fallouts by that one. I'll send fixes
> for it.

Did you try non-x86 builds with this applied?   I'd be really surprised
if there were just a few, once you did allyesconfig/allmodconfig for
ARM, MIPS, PPC, etc.

P.
--

[toc] | [prev] | [next] | [standalone]


#1322850 — Re: [PATCH tip v6 2/5] kbuild: Add option to turn incompatible pointer check into error

FromDaniel Wagner <daniel.wagner@bmw-carit.de>
Date2016-02-01 07:50 +0100
SubjectRe: [PATCH tip v6 2/5] kbuild: Add option to turn incompatible pointer check into error
Message-ID<qXgtc-765-9@gated-at.bofh.it>
In reply to#1322000
On 01/29/2016 07:55 PM, Paul Gortmaker wrote:
> [Re: [PATCH tip v6 2/5] kbuild: Add option to turn incompatible pointer check into error] On 29/01/2016 (Fri 13:17) Daniel Wagner wrote:
> 
>> On 01/28/2016 03:44 PM, Daniel Wagner wrote:
>>> +# enforce correct pointer usage
>>> +KBUILD_CFLAGS += $(call cc-option,-Werror=incompatible-pointer-types)
>>> +
>>
>> As it turns out there are a few fallouts by that one. I'll send fixes
>> for it.
> 
> Did you try non-x86 builds with this applied?   I'd be really surprised
> if there were just a few, once you did allyesconfig/allmodconfig for
> ARM, MIPS, PPC, etc.

I have tried this with non-x86 builds and apart of a few problems all
looked fine. As it turns out I was using too old cross tools from
kernel.org [1]. Luckily Fengguang's kbuild robot did catch a bunch of
them (see the patches in this series).

Since Thomas was also surprised that only a bunch of them showed up,
I'll better give it another go with more recent compilers.

cheers,
daniel

[1] https://www.kernel.org/pub/tools/crosstool

[toc] | [prev] | [next] | [standalone]


#1327528 — Re: [PATCH tip v6 2/5] kbuild: Add option to turn incompatible pointer check into error

FromDaniel Wagner <daniel.wagner@bmw-carit.de>
Date2016-02-05 09:20 +0100
SubjectRe: [PATCH tip v6 2/5] kbuild: Add option to turn incompatible pointer check into error
Message-ID<qYJMt-64X-1@gated-at.bofh.it>
In reply to#1322850
On 02/01/2016 07:49 AM, Daniel Wagner wrote:
> On 01/29/2016 07:55 PM, Paul Gortmaker wrote:
>> [Re: [PATCH tip v6 2/5] kbuild: Add option to turn incompatible pointer check into error] On 29/01/2016 (Fri 13:17) Daniel Wagner wrote:
>>
>>> On 01/28/2016 03:44 PM, Daniel Wagner wrote:
>>>> +# enforce correct pointer usage
>>>> +KBUILD_CFLAGS += $(call cc-option,-Werror=incompatible-pointer-types)
>>>> +
>>>
>>> As it turns out there are a few fallouts by that one. I'll send fixes
>>> for it.
>>
>> Did you try non-x86 builds with this applied?   I'd be really surprised
>> if there were just a few, once you did allyesconfig/allmodconfig for
>> ARM, MIPS, PPC, etc.
> 
> I have tried this with non-x86 builds and apart of a few problems all
> looked fine. As it turns out I was using too old cross tools from
> kernel.org [1]. Luckily Fengguang's kbuild robot did catch a bunch of
> them (see the patches in this series).

It turns out this week was particular bad for doing anything productive.
Anyway, I found some time to fire up some cross compilers and it looks
promising.

I used the cross compiler version 5.2.1 shipped by Fedora 23
and run allyesconfig/allmodconfig for ARM, ARM64, MIPS64, PPC64
(swait-v7 and 4.5-rc2). No new errors popped up.

With some luck I get some more architectures covered soon.

cheers,
daniel

[toc] | [prev] | [next] | [standalone]


#1328408 — Re: [PATCH tip v6 2/5] kbuild: Add option to turn incompatible pointer check into error

FromPaul Gortmaker <paul.gortmaker@windriver.com>
Date2016-02-07 05:50 +0100
SubjectRe: [PATCH tip v6 2/5] kbuild: Add option to turn incompatible pointer check into error
Message-ID<qZpsl-Ux-1@gated-at.bofh.it>
In reply to#1327528
[Re: [PATCH tip v6 2/5] kbuild: Add option to turn incompatible pointer check into error] On 05/02/2016 (Fri 09:16) Daniel Wagner wrote:

> On 02/01/2016 07:49 AM, Daniel Wagner wrote:
> > On 01/29/2016 07:55 PM, Paul Gortmaker wrote:
> >> [Re: [PATCH tip v6 2/5] kbuild: Add option to turn incompatible pointer check into error] On 29/01/2016 (Fri 13:17) Daniel Wagner wrote:
> >>
> >>> On 01/28/2016 03:44 PM, Daniel Wagner wrote:
> >>>> +# enforce correct pointer usage
> >>>> +KBUILD_CFLAGS += $(call cc-option,-Werror=incompatible-pointer-types)
> >>>> +
> >>>
> >>> As it turns out there are a few fallouts by that one. I'll send fixes
> >>> for it.
> >>
> >> Did you try non-x86 builds with this applied?   I'd be really surprised
> >> if there were just a few, once you did allyesconfig/allmodconfig for
> >> ARM, MIPS, PPC, etc.
> > 
> > I have tried this with non-x86 builds and apart of a few problems all
> > looked fine. As it turns out I was using too old cross tools from
> > kernel.org [1]. Luckily Fengguang's kbuild robot did catch a bunch of
> > them (see the patches in this series).
> 
> It turns out this week was particular bad for doing anything productive.
> Anyway, I found some time to fire up some cross compilers and it looks
> promising.
> 
> I used the cross compiler version 5.2.1 shipped by Fedora 23
> and run allyesconfig/allmodconfig for ARM, ARM64, MIPS64, PPC64
> (swait-v7 and 4.5-rc2). No new errors popped up.

SOunds good ; guess my gut feeling about this causing more fallout was
off the mark.

P.
--

> 
> With some luck I get some more architectures covered soon.
> 
> cheers,
> daniel

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web