i386 pgd_index() doesn't parenthesize its arg
pgd_index() doesn't parenthesize its argument. This is a bad idea for macros, since it's legitimate to pass expressions to them that will get misinterpreted given operator precedence and the shift.
vs. 2.5.59
-- wli
===== include/asm-i386/pgtable.h 1.22 vs edited =====
include/asm-i386/pgtable.h +1 -1
@@ -242,7 +242,7 @@ ((pmd_val (pmd) & (_PAGE_PSE|_PAGE_PRESENT)) == (_PAGE_PSE|_PAGE_PRESENT)) /* to find an entry in a page-table-directory. */ -#define pgd_index (address) ((address >> PGDIR_SHIFT) & (PTRS_PER_PGD-1)) +#define pgd_index (address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD-1))#define __pgd_offset (address) pgd_index(address)
PAE's pte_none() and pte_pfn() evaluate their arguments twice; analogous fixes have been made to other things; c.f. pgtable.h's long list of one-line inlines with parentheses still around their args.
===== include/asm-i386/pgtable-3level.h 1.8 vs edited =====
include/asm-i386/pgtable-3level.h +2 -2
@@ -89,8 +89,8 @@ }#define pte_page (x) pfn_to_page(pte_pfn(x)) -#define pte_none (x) (!(x).pte_low && !(x).pte_high) -#define pte_pfn (x) (((x).pte_low >> PAGE_SHIFT) | ((x).pte_high << (32 - PAGE_SHIFT))) +static inline int pte_none (pte_t pte) {return !pte.pte_low && !pte.pte_high; } +static inline unsigned long pte_pfn (pte_t pte) {return (pte.pte_low >>PAGE_SHIFT ) | (pte.pte_high << (32 -PAGE_SHIFT )); }static inline pte_t pfn_pte (unsigned long page_nr,pgprot_t pgprot) {