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


Groups > linux.kernel > #1486172

[PATCH 1/2] cris: don't compare incompatible pointer type

From Daniel Wagner <wagi@monom.org>
Newsgroups linux.kernel
Subject [PATCH 1/2] cris: don't compare incompatible pointer type
Date 2016-09-19 08:30 +0200
Message-ID <sj0fw-1Rv-13@gated-at.bofh.it> (permalink)
References <sj0fv-1Rv-9@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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

Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/2] cris: fix a couple of incompatible pointer types Daniel Wagner <wagi@monom.org> - 2016-09-19 08:30 +0200
  [PATCH 2/2] cris: use correct device_init() function signature Daniel Wagner <wagi@monom.org> - 2016-09-19 08:30 +0200
  [PATCH 1/2] cris: don't compare incompatible pointer type Daniel Wagner <wagi@monom.org> - 2016-09-19 08:30 +0200
  Re: [PATCH 0/2] cris: fix a couple of incompatible pointer types Daniel Wagner <wagi@monom.org> - 2016-09-19 09:10 +0200
  Re: [PATCH 0/2] cris: fix a couple of incompatible pointer types Niklas Cassel <nks.gnu@gmail.com> - 2016-09-19 09:10 +0200

csiph-web