[1/1] kconfig: fix lists definition for C++
diff mbox

Message ID 21ca352b71ca252e1933b1538fe89da8a04395c3.1367258255.git.yann.morin.1998@free.fr
State New, archived
Headers show

Commit Message

Yann E. MORIN April 29, 2013, 5:59 p.m. UTC
From: "Yann E. MORIN" <yann.morin.1998@free.fr>

The C++ compiler is more strict in that it refuses to assign
a void* to a struct list_head*.

Fix that by explicitly casting the poisonning constants.

(Tested with all 5 frontends, now.)

Reported-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Randy Dunlap <rdunlap@infradead.org>
Cc: Benjamin Poirier <bpoirier@suse.de>
---
 scripts/kconfig/list.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Randy Dunlap April 29, 2013, 7:28 p.m. UTC | #1
On 04/29/13 10:59, Yann E. MORIN wrote:
> From: "Yann E. MORIN" <yann.morin.1998@free.fr>
> 
> The C++ compiler is more strict in that it refuses to assign
> a void* to a struct list_head*.
> 
> Fix that by explicitly casting the poisonning constants.
> 
> (Tested with all 5 frontends, now.)
> 
> Reported-by: Randy Dunlap <rdunlap@infradead.org>
> Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
> Cc: Randy Dunlap <rdunlap@infradead.org>
> Cc: Benjamin Poirier <bpoirier@suse.de>

Acked-by: Randy Dunlap <rdunlap@infradead.org>

Thanks.

> ---
>  scripts/kconfig/list.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/scripts/kconfig/list.h b/scripts/kconfig/list.h
> index ea1d581..685d80e 100644
> --- a/scripts/kconfig/list.h
> +++ b/scripts/kconfig/list.h
> @@ -125,7 +125,7 @@ static inline void __list_del(struct list_head *prev, struct list_head *next)
>  static inline void list_del(struct list_head *entry)
>  {
>  	__list_del(entry->prev, entry->next);
> -	entry->next = LIST_POISON1;
> -	entry->prev = LIST_POISON2;
> +	entry->next = (struct list_head*)LIST_POISON1;
> +	entry->prev = (struct list_head*)LIST_POISON2;
>  }
>  #endif
>
Rob Landley April 29, 2013, 9:54 p.m. UTC | #2
On 04/29/2013 02:28:07 PM, Randy Dunlap wrote:
> On 04/29/13 10:59, Yann E. MORIN wrote:
> > From: "Yann E. MORIN" <yann.morin.1998@free.fr>
> >
> > The C++ compiler is more strict in that it refuses to assign
> > a void* to a struct list_head*.

Given that the code _isn't_ C++ (because C is not a subset of C++ but a  
separate langauge in its own right where "throw" is a legitimate  
variable name and so on), how is this an issue?

Rob--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Yann E. MORIN April 29, 2013, 10:30 p.m. UTC | #3
Rob, All,

On Mon, Apr 29, 2013 at 04:54:14PM -0500, Rob Landley wrote:
> On 04/29/2013 02:28:07 PM, Randy Dunlap wrote:
> >On 04/29/13 10:59, Yann E. MORIN wrote:
> >> From: "Yann E. MORIN" <yann.morin.1998@free.fr>
> >>
> >> The C++ compiler is more strict in that it refuses to assign
> >> a void* to a struct list_head*.
> 
> Given that the code _isn't_ C++ (because C is not a subset of C++ but a
> separate langauge in its own right where "throw" is a legitimate variable
> name and so on), how is this an issue?

It's an issue because the xconfig frontends is qconf, which as the name
implies is using Qt, which *is* C++, and includes list.h.

So, list.h is included by both by C and C++ code.

So yes, list.h can be compiled by a C++ compiler.

Now, granted: list.h should all be enclosed in:
    ifdef __cpluplus
    extern "C" {
    endif
    ...
    ifdef __cpluplus
    }
    endif

Was that the fix you were suggesting between the lines? ;-)

Regards,
Yann E. MORIN.
Rob Landley April 29, 2013, 10:57 p.m. UTC | #4
On 04/29/2013 05:30:54 PM, Yann E. MORIN wrote:
> Rob, All,
> 
> On Mon, Apr 29, 2013 at 04:54:14PM -0500, Rob Landley wrote:
> > On 04/29/2013 02:28:07 PM, Randy Dunlap wrote:
> > >On 04/29/13 10:59, Yann E. MORIN wrote:
> > >> From: "Yann E. MORIN" <yann.morin.1998@free.fr>
> > >>
> > >> The C++ compiler is more strict in that it refuses to assign
> > >> a void* to a struct list_head*.
> >
> > Given that the code _isn't_ C++ (because C is not a subset of C++  
> but a
> > separate langauge in its own right where "throw" is a legitimate  
> variable
> > name and so on), how is this an issue?
> 
> It's an issue because the xconfig frontends is qconf, which as the  
> name
> implies is using Qt, which *is* C++, and includes list.h.
> 
> So, list.h is included by both by C and C++ code.
> 
> So yes, list.h can be compiled by a C++ compiler.
> 
> Now, granted: list.h should all be enclosed in:
>     ifdef __cpluplus
>     extern "C" {
>     endif
>     ...
>     ifdef __cpluplus
>     }
>     endif
> 
> Was that the fix you were suggesting between the lines? ;-)

It does more clearly document the issue. (A comment about the QT  
front-end would also be nice. I don't use that one, so I didn't think  
of it.)

Thanks,

Rob--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch
diff mbox

diff --git a/scripts/kconfig/list.h b/scripts/kconfig/list.h
index ea1d581..685d80e 100644
--- a/scripts/kconfig/list.h
+++ b/scripts/kconfig/list.h
@@ -125,7 +125,7 @@  static inline void __list_del(struct list_head *prev, struct list_head *next)
 static inline void list_del(struct list_head *entry)
 {
 	__list_del(entry->prev, entry->next);
-	entry->next = LIST_POISON1;
-	entry->prev = LIST_POISON2;
+	entry->next = (struct list_head*)LIST_POISON1;
+	entry->prev = (struct list_head*)LIST_POISON2;
 }
 #endif