linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] cris: fix a couple of incompatible pointer types
@ 2016-09-19  6:27 Daniel Wagner
  2016-09-19  6:27 ` [PATCH 1/2] cris: don't compare incompatible pointer type Daniel Wagner
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Daniel Wagner @ 2016-09-19  6:27 UTC (permalink / raw)
  To: linux-cris-kernel
  Cc: Jesper Nilsson, Mikael Starvik, Paul Gortmaker, linux-kernel,
	Daniel Wagner

From: Daniel Wagner <daniel.wagner@bmw-carit.de>

Hi,

I got a love letter from kbuild about incompatible pointer types. I
added the new compiler flag [1] so it seems I am in charge cleaning up.

kbuild tells me:

All errors (new ones prefixed by >>):

   arch/cris/arch-v32/mm/intmem.c: In function 'crisv32_intmem_free':
   arch/cris/arch-v32/mm/intmem.c:116:14: warning: comparison of distinct pointer types lacks a cast
       if ((prev != &intmem_allocations) &&
                 ^~
   arch/cris/arch-v32/mm/intmem.c:123:14: warning: comparison of distinct pointer types lacks a cast
       if ((next != &intmem_allocations) &&
                 ^~
   In file included from include/linux/printk.h:5:0,
                    from include/linux/kernel.h:13,
                    from include/linux/list.h:8,
                    from arch/cris/arch-v32/mm/intmem.c:7:
   arch/cris/arch-v32/mm/intmem.c: At top level:
>> arch/cris/arch-v32/mm/intmem.c:148:17: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
    device_initcall(crisv32_intmem_init);
                    ^
   include/linux/init.h:184:58: note: in definition of macro '__define_initcall'
     __attribute__((__section__(".initcall" #id ".init"))) = fn; \
                                                             ^~
   arch/cris/arch-v32/mm/intmem.c:148:1: note: in expansion of macro 'device_initcall'
    device_initcall(crisv32_intmem_init);
    ^~~~~~~~~~~~~~~
   cc1: some warnings being treated as errors

cheers,
daniel

[1] ea8daa7b9784 ("kbuild: Add option to turn incompatible pointer check
into error")

Daniel Wagner (2):
  cris: don't compare incompatible pointer type
  cris: use correct device_init() function signature

 arch/cris/arch-v32/mm/intmem.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

-- 
2.7.4

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

* [PATCH 1/2] cris: don't compare incompatible pointer type
  2016-09-19  6:27 [PATCH 0/2] cris: fix a couple of incompatible pointer types Daniel Wagner
@ 2016-09-19  6:27 ` Daniel Wagner
  2016-09-19  6:27 ` [PATCH 2/2] cris: use correct device_init() function signature Daniel Wagner
  2016-09-19  6:59 ` [PATCH 0/2] cris: fix a couple of incompatible pointer types Niklas Cassel
  2 siblings, 0 replies; 5+ messages in thread
From: Daniel Wagner @ 2016-09-19  6:27 UTC (permalink / raw)
  To: linux-cris-kernel
  Cc: Jesper Nilsson, Mikael Starvik, Paul Gortmaker, linux-kernel,
	Daniel Wagner

From: Daniel Wagner <daniel.wagner@bmw-carit.de>

intmem_allocaionts is list head. Comparing the list head with prev and
next works so far because the entry was placed at the beginning of
struct intmem_allocation. Let's use list_entry to recover the correct
pointer and which makes this code slightly more robust.

Newer gcc version are checking the pointer types and through an error if
they don't match.

Reported-by: kbuild test robot <fengguang.wu@intel.com>
Cc: Mikael Starvik <starvik@axis.com>
Cc: Jesper Nilsson <jesper.nilsson@axis.com>
Cc: linux-cris-kernel@axis.com
---
 arch/cris/arch-v32/mm/intmem.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/arch/cris/arch-v32/mm/intmem.c b/arch/cris/arch-v32/mm/intmem.c
index 9ef5609..cfe393e 100644
--- a/arch/cris/arch-v32/mm/intmem.c
+++ b/arch/cris/arch-v32/mm/intmem.c
@@ -93,6 +93,7 @@ void* crisv32_intmem_alloc(unsigned size, unsigned align)
 
 void crisv32_intmem_free(void* addr)
 {
+	struct intmem_allocation* intmem_head;
 	struct intmem_allocation* allocation;
 	struct intmem_allocation* tmp;
 
@@ -102,6 +103,8 @@ void crisv32_intmem_free(void* addr)
 	preempt_disable();
 	crisv32_intmem_init();
 
+	intmem_head = list_entry(&intmem_allocations,
+				 struct intmem_allocation, entry);
 	list_for_each_entry_safe(allocation, tmp, &intmem_allocations, entry) {
 		if (allocation->offset == (int)(addr - intmem_virtual)) {
 			struct intmem_allocation *prev =
@@ -113,14 +116,14 @@ void crisv32_intmem_free(void* addr)
 
 			allocation->status = STATUS_FREE;
 			/* Join with prev and/or next if also free */
-			if ((prev != &intmem_allocations) &&
+			if ((prev != intmem_head) &&
 					(prev->status == STATUS_FREE)) {
 				prev->size += allocation->size;
 				list_del(&allocation->entry);
 				kfree(allocation);
 				allocation = prev;
 			}
-			if ((next != &intmem_allocations) &&
+			if ((next != intmem_head) &&
 					(next->status == STATUS_FREE)) {
 				allocation->size += next->size;
 				list_del(&next->entry);
-- 
2.7.4

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

* [PATCH 2/2] cris: use correct device_init() function signature
  2016-09-19  6:27 [PATCH 0/2] cris: fix a couple of incompatible pointer types Daniel Wagner
  2016-09-19  6:27 ` [PATCH 1/2] cris: don't compare incompatible pointer type Daniel Wagner
@ 2016-09-19  6:27 ` Daniel Wagner
  2016-09-19  6:59 ` [PATCH 0/2] cris: fix a couple of incompatible pointer types Niklas Cassel
  2 siblings, 0 replies; 5+ messages in thread
From: Daniel Wagner @ 2016-09-19  6:27 UTC (permalink / raw)
  To: linux-cris-kernel
  Cc: Jesper Nilsson, Mikael Starvik, Paul Gortmaker, linux-kernel,
	Daniel Wagner

From: Daniel Wagner <daniel.wagner@bmw-carit.de>

The crisv32_intem_init() function doesn't match the necessary callback
function signature. Newer gcc version are checking the pointer types
and through an error if they don't match.

Reported-by: kbuild test robot <fengguang.wu@intel.com>
Signed-off-by: Daniel Wagner <daniel.wagner@bmw-carit.de>
Cc: Mikael Starvik <starvik@axis.com>
Cc: Jesper Nilsson <jesper.nilsson@axis.com>
Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
Cc: linux-cris-kernel@axis.com
---
 arch/cris/arch-v32/mm/intmem.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/cris/arch-v32/mm/intmem.c b/arch/cris/arch-v32/mm/intmem.c
index cfe393e..f5c2273 100644
--- a/arch/cris/arch-v32/mm/intmem.c
+++ b/arch/cris/arch-v32/mm/intmem.c
@@ -29,7 +29,7 @@ struct intmem_allocation {
 static struct list_head intmem_allocations;
 static void* intmem_virtual;
 
-static void crisv32_intmem_init(void)
+static int __init crisv32_intmem_init(void)
 {
 	static int initiated = 0;
 	if (!initiated) {
@@ -44,6 +44,8 @@ static void crisv32_intmem_init(void)
 		alloc->status = STATUS_FREE;
 		list_add_tail(&alloc->entry, &intmem_allocations);
 	}
+
+	return 0;
 }
 
 void* crisv32_intmem_alloc(unsigned size, unsigned align)
-- 
2.7.4

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

* Re: [PATCH 0/2] cris: fix a couple of incompatible pointer types
  2016-09-19  6:27 [PATCH 0/2] cris: fix a couple of incompatible pointer types Daniel Wagner
  2016-09-19  6:27 ` [PATCH 1/2] cris: don't compare incompatible pointer type Daniel Wagner
  2016-09-19  6:27 ` [PATCH 2/2] cris: use correct device_init() function signature Daniel Wagner
@ 2016-09-19  6:59 ` Niklas Cassel
  2016-09-19  7:08   ` Daniel Wagner
  2 siblings, 1 reply; 5+ messages in thread
From: Niklas Cassel @ 2016-09-19  6:59 UTC (permalink / raw)
  To: Daniel Wagner
  Cc: linux-cris-kernel, Jesper Nilsson, Mikael Starvik,
	Paul Gortmaker, linux-kernel, Daniel Wagner

Hi

I've already sent patches for these errors (among others errors)

http://marc.info/?l=linux-kernel&m=144873518310721&w=2
http://marc.info/?l=linux-kernel&m=144873519510723&w=2

Regards,
Niklas

On Mon, Sep 19, 2016 at 8:27 AM, Daniel Wagner <wagi@monom.org> wrote:
> From: Daniel Wagner <daniel.wagner@bmw-carit.de>
>
> Hi,
>
> I got a love letter from kbuild about incompatible pointer types. I
> added the new compiler flag [1] so it seems I am in charge cleaning up.
>
> kbuild tells me:
>
> All errors (new ones prefixed by >>):
>
>    arch/cris/arch-v32/mm/intmem.c: In function 'crisv32_intmem_free':
>    arch/cris/arch-v32/mm/intmem.c:116:14: warning: comparison of distinct pointer types lacks a cast
>        if ((prev != &intmem_allocations) &&
>                  ^~
>    arch/cris/arch-v32/mm/intmem.c:123:14: warning: comparison of distinct pointer types lacks a cast
>        if ((next != &intmem_allocations) &&
>                  ^~
>    In file included from include/linux/printk.h:5:0,
>                     from include/linux/kernel.h:13,
>                     from include/linux/list.h:8,
>                     from arch/cris/arch-v32/mm/intmem.c:7:
>    arch/cris/arch-v32/mm/intmem.c: At top level:
>>> arch/cris/arch-v32/mm/intmem.c:148:17: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
>     device_initcall(crisv32_intmem_init);
>                     ^
>    include/linux/init.h:184:58: note: in definition of macro '__define_initcall'
>      __attribute__((__section__(".initcall" #id ".init"))) = fn; \
>                                                              ^~
>    arch/cris/arch-v32/mm/intmem.c:148:1: note: in expansion of macro 'device_initcall'
>     device_initcall(crisv32_intmem_init);
>     ^~~~~~~~~~~~~~~
>    cc1: some warnings being treated as errors
>
> cheers,
> daniel
>
> [1] ea8daa7b9784 ("kbuild: Add option to turn incompatible pointer check
> into error")
>
> Daniel Wagner (2):
>   cris: don't compare incompatible pointer type
>   cris: use correct device_init() function signature
>
>  arch/cris/arch-v32/mm/intmem.c | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
>
> --
> 2.7.4

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

* Re: [PATCH 0/2] cris: fix a couple of incompatible pointer types
  2016-09-19  6:59 ` [PATCH 0/2] cris: fix a couple of incompatible pointer types Niklas Cassel
@ 2016-09-19  7:08   ` Daniel Wagner
  0 siblings, 0 replies; 5+ messages in thread
From: Daniel Wagner @ 2016-09-19  7:08 UTC (permalink / raw)
  To: Niklas Cassel
  Cc: linux-cris-kernel, Jesper Nilsson, Mikael Starvik,
	Paul Gortmaker, linux-kernel, Daniel Wagner

On 09/19/2016 08:59 AM, Niklas Cassel wrote:
> I've already sent patches for these errors (among others errors)
>
> http://marc.info/?l=linux-kernel&m=144873518310721&w=2
> http://marc.info/?l=linux-kernel&m=144873519510723&w=2

Excellent! As I said, the build robot keeps nagging me about such errors 
and I somehow feel responsible to fix them up. As long as it gets fixed 
I am fine :)

cheers,
daniel

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

end of thread, other threads:[~2016-09-19  7:08 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-19  6:27 [PATCH 0/2] cris: fix a couple of incompatible pointer types Daniel Wagner
2016-09-19  6:27 ` [PATCH 1/2] cris: don't compare incompatible pointer type Daniel Wagner
2016-09-19  6:27 ` [PATCH 2/2] cris: use correct device_init() function signature Daniel Wagner
2016-09-19  6:59 ` [PATCH 0/2] cris: fix a couple of incompatible pointer types Niklas Cassel
2016-09-19  7:08   ` Daniel Wagner

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).