Skip to contentSkip to conversation

mm/pagewalk.c break const constraint.

PATCH In review KOSAKI Motohiro 4 participants 8 messages Apr 19, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm/pagewalk.c break const constraint.

patch against 2.6.25

when compile 2.6.25, following warnings was outputed.

CC mm/pagewalk.o
mm/pagewalk.c: In function 'walk_page_range':
mm/pagewalk.c:111: warning: passing argument 1 of 'pgd_offset' discards qualifiers from p\
ointer target type

mm argument of walk_page_range() is unnecessary const restriction. this patch is no functional change. it's only remove warning.

Thanks!

---
 include/linux/mm.h |    2 +-
 mm/pagewalk.c      |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
mm/pagewalk.c 2008-04-19 18:43:58.000000000 +0900 renamed from mm/pagewalk.c 2008-04-19 17:46:34.000000000 +0900 +1 -1
Index: b/mm/pagewalk.c
===================================================================
@@ -97,7 +97,7 @@ static int walk_pud_range(pgd_t *pgd, un
  * If any callback returns a non-zero value, the walk is aborted and
  * the return value is propagated back to the caller. Otherwise 0 is returned.
  */
-int walk_page_range(const struct mm_struct *mm,
+int walk_page_range(struct mm_struct *mm,
                    unsigned long addr, unsigned long end,
                    const struct mm_walk *walk, void *private)
 {
include/linux/mm.h 2008-04-19 18:44:14.000000000 +0900 renamed from include/linux/mm.h 2008-04-19 17:46:12.000000000 +0900 +1 -1
Index: b/include/linux/mm.h
===================================================================
@@ -746,7 +746,7 @@ struct mm_walk {
        int (*pte_hole)(unsigned long, unsigned long, void *);
 };
 
-int walk_page_range(const struct mm_struct *, unsigned long addr,
+int walk_page_range(struct mm_struct *, unsigned long addr,
                    unsigned long end, const struct mm_walk *walk,
                    void *private);
 void free_pgd_range(struct mmu_gather **tlb, unsigned long addr,
#1 lore raw
Quoted 11 lines · KOSAKI Motohiro

patch against 2.6.25

when compile 2.6.25, following warnings was outputed.

CC mm/pagewalk.o
mm/pagewalk.c: In function 'walk_page_range':
mm/pagewalk.c:111: warning: passing argument 1 of 'pgd_offset' discards qualifiers from p\
ointer target type

mm argument of walk_page_range() is unnecessary const restriction. this patch is no functional change. it's only remove warning.

Is this ia64 or cris? I think the correct way to resolve this is to make pgd_offset() take a const struct mm_struct * instead.

Vegard

Signature · 4 lines
"The animistic metaphor of the bug that maliciously sneaked in while
the programmer was not looking is intellectually dishonest as it
disguises that the error is the programmer's own creation."
	-- E. W. Dijkstra, EWD1036
#2 lore raw

Hi

Quoted 11 lines
Quoted 9 lines

when compile 2.6.25, following warnings was outputed.

CC mm/pagewalk.o
mm/pagewalk.c: In function 'walk_page_range':
mm/pagewalk.c:111: warning: passing argument 1 of 'pgd_offset' discards qualifiers from p\
ointer target type

mm argument of walk_page_range() is unnecessary const restriction. this patch is no functional change. it's only remove warning.

Is this ia64 or cris?

Yes, I use IA64.

Quoted 2 lines

I think the correct way to resolve this is to make pgd_offset() take a const struct mm_struct * instead.

that makes sense.
OK, I will make patch again.

Thank you for very good opinion.

#3 lore raw

cover mm/pagewalk.c break const constraint. take2

this patch is against 2.6.25

when compile 2.6.25 on ia64, following warnings was outputed.

CC mm/pagewalk.o
mm/pagewalk.c: In function 'walk_page_range':
mm/pagewalk.c:111: warning: passing argument 1 of 'pgd_offset' discards qualifiers from p\
ointer target type

the type of mm argument of walk_page_range() is "const struct mm *", but pgd_offset() on ia64 declare "struct mm*".
cris port has the same problems.

I propse add const to pgd_offset() for solve this problem.

Thanks!

#4 lore raw

PATCH 1/2 ia64: add constfy to pgd_offset()

add constfy to pgd_offset() for avoid following warnings.

CC mm/pagewalk.o
mm/pagewalk.c: In function 'walk_page_range':
mm/pagewalk.c:111: warning: passing argument 1 of 'pgd_offset' discards qualifiers from p\
ointer target type

CC Matt Mackall <[email protected]>
CC "Vegard Nossum" <[email protected]>
CC "Luck, Tony" <[email protected]>
---
 include/asm-ia64/pgtable.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: b/include/asm-ia64/pgtable.h
=================================--- a/include/asm-ia64/pgtable.h 2008-04-19 17:46:11.000000000 +0900
+++ b/include/asm-ia64/pgtable.h 2008-04-19 19:20:16.000000000 +0900
@@ -371,7 +371,7 @@ pgd_index (unsigned long address)
/* The offset in the 1-level directory is given by the 3 region bits

    (61..63) and the level-1 bits.  */
 static inline pgd_t*
-pgd_offset (struct mm_struct *mm, unsigned long address)
+pgd_offset (const struct mm_struct *mm, unsigned long address)
 {
        return mm->pgd + pgd_index(address);

}

#5 lore raw

PATCH 2/2 cris: add constfy to pgd_offset()

add constfy to pgd_offset() for avoid following warnings.

CC mm/pagewalk.o
mm/pagewalk.c: In function 'walk_page_range':
mm/pagewalk.c:111: warning: passing argument 1 of 'pgd_offset' discards qualifiers from p\
ointer target type

CC Matt Mackall <[email protected]>
CC "Vegard Nossum" <[email protected]>
CC Mikael Starvik <[email protected]>
CC Jesper Nilsson <[email protected]>
---
 include/asm-cris/pgtable.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/asm-cris/pgtable.h 2008-04-19 19:27:31.000000000 +0900 renamed from include/asm-cris/pgtable.h 2008-04-19 19:25:50.000000000 +0900 +1 -1
Index: b/include/asm-cris/pgtable.h
===================================================================
@@ -229,7 +229,7 @@ static inline void pmd_set(pmd_t * pmdp,
 #define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD-1))
 
 /* to find an entry in a page-table-directory */
-static inline pgd_t * pgd_offset(struct mm_struct * mm, unsigned long address)
+static inline pgd_t * pgd_offset(const struct mm_struct * mm, unsigned long address)
 {
        return mm->pgd + pgd_index(address);
 }
#6 lore raw

Re: [PATCH][trivial][2/2] cris: add constfy to pgd_offset()

KOSAKI Motohiro пишет:

Quoted 22 lines

add constfy to pgd_offset() for avoid following warnings.

CC mm/pagewalk.o
mm/pagewalk.c: In function 'walk_page_range':
mm/pagewalk.c:111: warning: passing argument 1 of 'pgd_offset' discards qualifiers from p\
ointer target type

CC Matt Mackall <[email protected]>
CC "Vegard Nossum" <[email protected]>
CC Mikael Starvik <[email protected]>
CC Jesper Nilsson <[email protected]>
---
 include/asm-cris/pgtable.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: b/include/asm-cris/pgtable.h
===================================================================

include/asm-cris/pgtable.h 2008-04-19 19:27:31.000000000 +0900 static inline void pmd_set(pmd_t * pmdp, · line 232

Quoted 5 lines
include/asm-cris/pgtable.h 2008-04-19 19:27:31.000000000 +0900 renamed from include/asm-cris/pgtable.h 2008-04-19 19:25:50.000000000 +0900 +1 -1
@@ -229,7 +229,7 @@ static inline void pmd_set(pmd_t * pmdp,
 #define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD-1))
 
 /* to find an entry in a page-table-directory */
-static inline pgd_t * pgd_offset(struct mm_struct * mm, unsigned long address)
+static inline pgd_t * pgd_offset(const struct mm_struct * mm, unsigned long address)

^ ^
I think that while at it, you could also delete these superfluous spaces after the asterisks thereby making the code conform to the kernel coding style.

Dmitri

Quoted 12 lines
include/asm-cris/pgtable.h 2008-04-19 19:27:31.000000000 +0900 renamed from include/asm-cris/pgtable.h 2008-04-19 19:25:50.000000000 +0900 +0 -1
 {
        return mm->pgd + pgd_index(address);
 }
 
 
 
--

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

#7 lore raw

Re: [PATCH][trivial][2/2] cris: add constfy to pgd_offset()

In reply to KOSAKI Motohiro
Quoted 22 lines · KOSAKI Motohiro

add constfy to pgd_offset() for avoid following warnings.

CC mm/pagewalk.o
mm/pagewalk.c: In function 'walk_page_range':
mm/pagewalk.c:111: warning: passing argument 1 of 'pgd_offset' discards qualifiers from p\
ointer target type

CC Matt Mackall <[email protected]>
CC "Vegard Nossum" <[email protected]>
CC Mikael Starvik <[email protected]>
CC Jesper Nilsson <[email protected]>
---
 include/asm-cris/pgtable.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: b/include/asm-cris/pgtable.h
===================================================================

include/asm-cris/pgtable.h 2008-04-19 19:27:31.000000000 +0900 static inline void pmd_set(pmd_t * pmdp, · line 235

Quoted 8 lines
include/asm-cris/pgtable.h 2008-04-19 19:27:31.000000000 +0900 renamed from include/asm-cris/pgtable.h 2008-04-19 19:25:50.000000000 +0900 +1 -1
@@ -229,7 +229,7 @@ static inline void pmd_set(pmd_t * pmdp,
 #define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD-1))
 
 /* to find an entry in a page-table-directory */
-static inline pgd_t * pgd_offset(struct mm_struct * mm, unsigned long address)
+static inline pgd_t * pgd_offset(const struct mm_struct * mm, unsigned long address)
 {
        return mm->pgd + pgd_index(address);
 }

Thanks, I've added the following to the CRIS-tree.

---
 include/asm-cris/pgtable.h |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
include/asm-cris/pgtable.h +2 -1
index a260757..a307ed6 100644
@@ -229,7 +229,8 @@ static inline void pmd_set(pmd_t * pmdp, pte_t * ptep)
 #define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD-1))
 
 /* to find an entry in a page-table-directory */
-static inline pgd_t * pgd_offset(struct mm_struct * mm, unsigned long address)
+static inline pgd_t *pgd_offset(const struct mm_struct *mm,
+				unsigned long address)
 {
 	return mm->pgd + pgd_index(address);
 }
Signature · 5 lines
1.5.4.2.133.g3d51e

/^JN - Jesper Nilsson
-- 
               Jesper Nilsson -- [email protected]