* i386 pgd_index() doesn't parenthesize its arg
@ 2003-01-17 5:51 William Lee Irwin III
2003-01-17 6:03 ` William Lee Irwin III
0 siblings, 1 reply; 2+ messages in thread
From: William Lee Irwin III @ 2003-01-17 5:51 UTC (permalink / raw)
To: akpm; +Cc: linux-kernel, linux-mm
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 =====
--- 1.22/include/asm-i386/pgtable.h Mon Nov 25 14:41:15 2002
+++ edited/include/asm-i386/pgtable.h Thu Jan 16 21:08:06 2003
@@ -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)
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: i386 pgd_index() doesn't parenthesize its arg
2003-01-17 5:51 i386 pgd_index() doesn't parenthesize its arg William Lee Irwin III
@ 2003-01-17 6:03 ` William Lee Irwin III
0 siblings, 0 replies; 2+ messages in thread
From: William Lee Irwin III @ 2003-01-17 6:03 UTC (permalink / raw)
To: akpm, linux-kernel, linux-mm
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 =====
--- 1.8/include/asm-i386/pgtable-3level.h Fri Jul 26 06:23:51 2002
+++ edited/include/asm-i386/pgtable-3level.h Thu Jan 16 21:59:08 2003
@@ -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)
{
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2003-01-17 6:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-01-17 5:51 i386 pgd_index() doesn't parenthesize its arg William Lee Irwin III
2003-01-17 6:03 ` William Lee Irwin III
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox