Skip to contentSkip to conversation

Cleanup line-wrapping in pgtable.h

RFC In review Adam Litke 7 participants 7 messages Aug 17, 2005 – Aug 22, 2005

lore
Share & tools
lore

Adam Litke

author
#0 lore raw

RFC 1/1 Cleanup line-wrapping in pgtable.h

The line-wrapping in most of the include/asm/pgtable.h pte test/set macros looks horrible in my 80 column terminal. The following "test the waters" patch is how I would like to see them laid out. I realize that the braces don't adhere to CodingStyle but the advantage is (when taking wrapping into account) that the code takes up no additional space. How do people feel about making this change? Any better suggestions? I personally wouldn't like a lone closing brace like normal functions because of the extra lines eaten. I volunteer to patch up the other architectures if we reach a consensus.

 pgtable.h |   51 ++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 34 insertions(+), 17 deletions(-)
include/asm-i386/pgtable.h +34 -17
diff -upN reference/include/asm-i386/pgtable.h current/include/asm-i386/pgtable.h
@@ -215,28 +215,45 @@ extern unsigned long pg0[];
  * The following only work if pte_present() is true.
  * Undefined behaviour if not..
  */
-static inline int pte_user(pte_t pte)		{ return (pte).pte_low & _PAGE_USER; }
-static inline int pte_read(pte_t pte)		{ return (pte).pte_low & _PAGE_USER; }
-static inline int pte_dirty(pte_t pte)		{ return (pte).pte_low & _PAGE_DIRTY; }
-static inline int pte_young(pte_t pte)		{ return (pte).pte_low & _PAGE_ACCESSED; }
-static inline int pte_write(pte_t pte)		{ return (pte).pte_low & _PAGE_RW; }
+static inline int pte_user(pte_t pte)
+	{ return (pte).pte_low & _PAGE_USER; }
+static inline int pte_read(pte_t pte)
+	{ return (pte).pte_low & _PAGE_USER; }
+static inline int pte_dirty(pte_t pte)
+	{ return (pte).pte_low & _PAGE_DIRTY; }
+static inline int pte_young(pte_t pte)
+	{ return (pte).pte_low & _PAGE_ACCESSED; }
+static inline int pte_write(pte_t pte)
+	{ return (pte).pte_low & _PAGE_RW; }
 
 /*
  * The following only works if pte_present() is not true.
  */
-static inline int pte_file(pte_t pte)		{ return (pte).pte_low & _PAGE_FILE; }
+static inline int pte_file(pte_t pte)
+	{ return (pte).pte_low & _PAGE_FILE; }
 
-static inline pte_t pte_rdprotect(pte_t pte)	{ (pte).pte_low &= ~_PAGE_USER; return pte; }
-static inline pte_t pte_exprotect(pte_t pte)	{ (pte).pte_low &= ~_PAGE_USER; return pte; }
-static inline pte_t pte_mkclean(pte_t pte)	{ (pte).pte_low &= ~_PAGE_DIRTY; return pte; }
-static inline pte_t pte_mkold(pte_t pte)	{ (pte).pte_low &= ~_PAGE_ACCESSED; return pte; }
-static inline pte_t pte_wrprotect(pte_t pte)	{ (pte).pte_low &= ~_PAGE_RW; return pte; }
-static inline pte_t pte_mkread(pte_t pte)	{ (pte).pte_low |= _PAGE_USER; return pte; }
-static inline pte_t pte_mkexec(pte_t pte)	{ (pte).pte_low |= _PAGE_USER; return pte; }
-static inline pte_t pte_mkdirty(pte_t pte)	{ (pte).pte_low |= _PAGE_DIRTY; return pte; }
-static inline pte_t pte_mkyoung(pte_t pte)	{ (pte).pte_low |= _PAGE_ACCESSED; return pte; }
-static inline pte_t pte_mkwrite(pte_t pte)	{ (pte).pte_low |= _PAGE_RW; return pte; }
-static inline pte_t pte_mkhuge(pte_t pte)	{ (pte).pte_low |= _PAGE_PRESENT | _PAGE_PSE; return pte; }
+static inline pte_t pte_rdprotect(pte_t pte)
+	{ (pte).pte_low &= ~_PAGE_USER; return pte; }
+static inline pte_t pte_exprotect(pte_t pte)
+	{ (pte).pte_low &= ~_PAGE_USER; return pte; }
+static inline pte_t pte_mkclean(pte_t pte)
+	{ (pte).pte_low &= ~_PAGE_DIRTY; return pte; }
+static inline pte_t pte_mkold(pte_t pte)
+	{ (pte).pte_low &= ~_PAGE_ACCESSED; return pte; }
+static inline pte_t pte_wrprotect(pte_t pte)
+	{ (pte).pte_low &= ~_PAGE_RW; return pte; }
+static inline pte_t pte_mkread(pte_t pte)
+	{ (pte).pte_low |= _PAGE_USER; return pte; }
+static inline pte_t pte_mkexec(pte_t pte)
+	{ (pte).pte_low |= _PAGE_USER; return pte; }
+static inline pte_t pte_mkdirty(pte_t pte)
+	{ (pte).pte_low |= _PAGE_DIRTY; return pte; }
+static inline pte_t pte_mkyoung(pte_t pte)
+	{ (pte).pte_low |= _PAGE_ACCESSED; return pte; }
+static inline pte_t pte_mkwrite(pte_t pte)
+	{ (pte).pte_low |= _PAGE_RW; return pte; }
+static inline pte_t pte_mkhuge(pte_t pte)
+	{ (pte).pte_low |= _PAGE_PRESENT | _PAGE_PSE; return pte; }
 
 #ifdef CONFIG_X86_PAE
 # include <asm/pgtable-3level.h>
#1 lore raw

Review

Quoted 2 lines
(quoted diff) +2 -0
+static inline int pte_user(pte_t pte)
+	{ return (pte).pte_low & _PAGE_USER; }

Once you start reformatting things please make sure the result version matches the documented codingstyle. That would be:

static inline int pte_user(pte_t pte)

{
	return (pte).pte_low & _PAGE_USER;
}

Quite a bit more verbose, but also a lot better readable.

#2 lore raw
Quoted 9 lines · Christoph Hellwig

Review

Quoted 2 lines
(quoted diff) +2 -0
+static inline int pte_user(pte_t pte)
+	{ return (pte).pte_low & _PAGE_USER; }

Once you start reformatting things please make sure the result version matches the documented codingstyle. That would be:

static inline int pte_user(pte_t pte)

{
	return (pte).pte_low & _PAGE_USER;
	       ^   ^
Quoted 3 lines

}

Quite a bit more verbose, but also a lot better readable.

Don't forget to drop "(" and ")".

#3 lore raw
In reply to Adam Litke

Uttered Adam Litke <[email protected]>, spake thus:

Quoted 9 lines

The line-wrapping in most of the include/asm/pgtable.h pte test/set macros looks horrible in my 80 column terminal. The following "test the waters" patch is how I would like to see them laid out. I realize that the braces don't adhere to CodingStyle but the advantage is (when taking wrapping into account) that the code takes up no additional space. How do people feel about making this change? Any better suggestions? I personally wouldn't like a lone closing brace like normal functions because of the extra lines eaten. I volunteer to patch up the other architectures if we reach a consensus.

Congratulations for keeping your 80-column display. The coding standard assumes that and 8-character tabs for carefully thought-out software development reasons -- they are functional, not traditional.

Since these are inline procedures, make them follow the coding standard; that's why we have one.

Cheers

#4 lore raw
In reply to Adam Litke
Quoted 9 lines · Adam Litke

The line-wrapping in most of the include/asm/pgtable.h pte test/set macros looks horrible in my 80 column terminal. The following "test the waters" patch is how I would like to see them laid out. I realize that the braces don't adhere to CodingStyle but the advantage is (when taking wrapping into account) that the code takes up no additional space. How do people feel about making this change? Any better suggestions? I personally wouldn't like a lone closing brace like normal functions because of the extra lines eaten. I volunteer to patch up the other architectures if we reach a consensus.

I'd probably just leave it alone. Those are things that are virtually never touched, and are quite unlikely to have any bugs in them.

But, if you do decide to change them, it might also be a nice idea to consolidate some of the ones that are duplicated across architectures. They could probably even go into the existing include/asm-generic/pgtable.h. Please use full, proper CodingStyle if you do decide to split them across several lines.

-- Dave

#5 lore raw
In reply to Adam Litke
Quoted 26 lines · Adam Litke

The line-wrapping in most of the include/asm/pgtable.h pte test/set macros looks horrible in my 80 column terminal. The following "test the waters" patch is how I would like to see them laid out. I realize that the braces don't adhere to CodingStyle but the advantage is (when taking wrapping into account) that the code takes up no additional space. How do people feel about making this change? Any better suggestions? I personally wouldn't like a lone closing brace like normal functions because of the extra lines eaten. I volunteer to patch up the other architectures if we reach a consensus.

 pgtable.h |   51 ++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 34 insertions(+), 17 deletions(-)

diff -upN reference/include/asm-i386/pgtable.h current/include/asm-i386/pgtable.h

include/asm-i386/pgtable.h +0 -5
@@ -215,28 +215,45 @@ extern unsigned long pg0[];
  * The following only work if pte_present() is true.
  * Undefined behaviour if not..
  */
-static inline int pte_user(pte_t pte)		{ return (pte).pte_low & _PAGE_USER; }
-static inline int pte_read(pte_t pte)		{ return (pte).pte_low & _PAGE_USER; }
-static inline int pte_dirty(pte_t pte)		{ return (pte).pte_low & _PAGE_DIRTY; }
-static inline int pte_young(pte_t pte)		{ return (pte).pte_low & _PAGE_ACCESSED; }
-static inline int pte_write(pte_t pte)		{ return (pte).pte_low & _PAGE_RW; }

include/asm-i386/pgtable.h extern unsigned long pg0[]; · line 227

Quoted 10 lines
include/asm-i386/pgtable.h +10 -0
+static inline int pte_user(pte_t pte)
+	{ return (pte).pte_low & _PAGE_USER; }
+static inline int pte_read(pte_t pte)
+	{ return (pte).pte_low & _PAGE_USER; }
+static inline int pte_dirty(pte_t pte)
+	{ return (pte).pte_low & _PAGE_DIRTY; }
+static inline int pte_young(pte_t pte)
+	{ return (pte).pte_low & _PAGE_ACCESSED; }
+static inline int pte_write(pte_t pte)
+	{ return (pte).pte_low & _PAGE_RW; }

I think removing the whitespace preceding the opening braces is closer
to CodingStyle, allows for longer lines in the future (however gross they may be), and does not alter the vertical space consumed on your display.

include/asm-i386/pgtable.h extern unsigned long pg0[]; · line 233

Quoted 12 lines
include/asm-i386/pgtable.h +2 -6
 /*
  * The following only works if pte_present() is not true.
  */
-static inline int pte_file(pte_t pte)		{ return (pte).pte_low & _PAGE_FILE; }
+static inline int pte_file(pte_t pte)
+	{ return (pte).pte_low & _PAGE_FILE; }
 
-static inline pte_t pte_rdprotect(pte_t pte)	{ (pte).pte_low &= ~_PAGE_USER; return pte; }
-static inline pte_t pte_exprotect(pte_t pte)	{ (pte).pte_low &= ~_PAGE_USER; return pte; }
-static inline pte_t pte_mkclean(pte_t pte)	{ (pte).pte_low &= ~_PAGE_DIRTY; return pte; }
-static inline pte_t pte_mkold(pte_t pte)	{ (pte).pte_low &= ~_PAGE_ACCESSED; return pte; }
-static inline pte_t pte_wrprotect(pte_t pte)	{ (pte).pte_low &= ~_PAGE_RW; return pte; }

As long as this file is being polished, you might move pte_wrprotect() up so it is between pte_rdprotect() and pte_exprotect().

Quoted 21 lines
include/asm-i386/pgtable.h +15 -6
-static inline pte_t pte_mkread(pte_t pte)	{ (pte).pte_low |= _PAGE_USER; return pte; }
-static inline pte_t pte_mkexec(pte_t pte)	{ (pte).pte_low |= _PAGE_USER; return pte; }
-static inline pte_t pte_mkdirty(pte_t pte)	{ (pte).pte_low |= _PAGE_DIRTY; return pte; }
-static inline pte_t pte_mkyoung(pte_t pte)	{ (pte).pte_low |= _PAGE_ACCESSED; return pte; }
-static inline pte_t pte_mkwrite(pte_t pte)	{ (pte).pte_low |= _PAGE_RW; return pte; }
-static inline pte_t pte_mkhuge(pte_t pte)	{ (pte).pte_low |= _PAGE_PRESENT | _PAGE_PSE; return pte; }
+static inline pte_t pte_rdprotect(pte_t pte)
+	{ (pte).pte_low &= ~_PAGE_USER; return pte; }
+static inline pte_t pte_exprotect(pte_t pte)
+	{ (pte).pte_low &= ~_PAGE_USER; return pte; }
+static inline pte_t pte_mkclean(pte_t pte)
+	{ (pte).pte_low &= ~_PAGE_DIRTY; return pte; }
+static inline pte_t pte_mkold(pte_t pte)
+	{ (pte).pte_low &= ~_PAGE_ACCESSED; return pte; }
+static inline pte_t pte_wrprotect(pte_t pte)
+	{ (pte).pte_low &= ~_PAGE_RW; return pte; }
+static inline pte_t pte_mkread(pte_t pte)
+	{ (pte).pte_low |= _PAGE_USER; return pte; }
+static inline pte_t pte_mkexec(pte_t pte)
+	{ (pte).pte_low |= _PAGE_USER; return pte; }
+static inline pte_t pte_mkdirty(pte_t pte)

include/asm-i386/pgtable.h extern unsigned long pg0[]; · line 259

Quoted 10 lines
include/asm-i386/pgtable.h +7 -0
+	{ (pte).pte_low |= _PAGE_DIRTY; return pte; }
+static inline pte_t pte_mkyoung(pte_t pte)
+	{ (pte).pte_low |= _PAGE_ACCESSED; return pte; }
+static inline pte_t pte_mkwrite(pte_t pte)
+	{ (pte).pte_low |= _PAGE_RW; return pte; }
+static inline pte_t pte_mkhuge(pte_t pte)
+	{ (pte).pte_low |= _PAGE_PRESENT | _PAGE_PSE; return pte; }
 
 #ifdef CONFIG_X86_PAE
 # include <asm/pgtable-3level.h>

Cheers,
-Matt Helsley

#6 lore raw
In reply to Adam Litke

Hi!

Quoted 9 lines

The line-wrapping in most of the include/asm/pgtable.h pte test/set macros looks horrible in my 80 column terminal. The following "test the waters" patch is how I would like to see them laid out. I realize that the braces don't adhere to CodingStyle but the advantage is (when taking wrapping into account) that the code takes up no additional space. How do people feel about making this change? Any better suggestions? I personally wouldn't like a lone closing brace like normal functions because of the extra lines eaten. I volunteer to patch up the other architectures if we reach a consensus.

I'm afraid that original version looks better than new one...
Pavel

Quoted 70 lines
 pgtable.h |   51 ++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 34 insertions(+), 17 deletions(-)

diff -upN reference/include/asm-i386/pgtable.h current/include/asm-i386/pgtable.h

include/asm-i386/pgtable.h +34 -17
@@ -215,28 +215,45 @@ extern unsigned long pg0[];
  * The following only work if pte_present() is true.
  * Undefined behaviour if not..
  */
-static inline int pte_user(pte_t pte)		{ return (pte).pte_low & _PAGE_USER; }
-static inline int pte_read(pte_t pte)		{ return (pte).pte_low & _PAGE_USER; }
-static inline int pte_dirty(pte_t pte)		{ return (pte).pte_low & _PAGE_DIRTY; }
-static inline int pte_young(pte_t pte)		{ return (pte).pte_low & _PAGE_ACCESSED; }
-static inline int pte_write(pte_t pte)		{ return (pte).pte_low & _PAGE_RW; }
+static inline int pte_user(pte_t pte)
+	{ return (pte).pte_low & _PAGE_USER; }
+static inline int pte_read(pte_t pte)
+	{ return (pte).pte_low & _PAGE_USER; }
+static inline int pte_dirty(pte_t pte)
+	{ return (pte).pte_low & _PAGE_DIRTY; }
+static inline int pte_young(pte_t pte)
+	{ return (pte).pte_low & _PAGE_ACCESSED; }
+static inline int pte_write(pte_t pte)
+	{ return (pte).pte_low & _PAGE_RW; }
 
 /*
  * The following only works if pte_present() is not true.
  */
-static inline int pte_file(pte_t pte)		{ return (pte).pte_low & _PAGE_FILE; }
+static inline int pte_file(pte_t pte)
+	{ return (pte).pte_low & _PAGE_FILE; }
 
-static inline pte_t pte_rdprotect(pte_t pte)	{ (pte).pte_low &= ~_PAGE_USER; return pte; }
-static inline pte_t pte_exprotect(pte_t pte)	{ (pte).pte_low &= ~_PAGE_USER; return pte; }
-static inline pte_t pte_mkclean(pte_t pte)	{ (pte).pte_low &= ~_PAGE_DIRTY; return pte; }
-static inline pte_t pte_mkold(pte_t pte)	{ (pte).pte_low &= ~_PAGE_ACCESSED; return pte; }
-static inline pte_t pte_wrprotect(pte_t pte)	{ (pte).pte_low &= ~_PAGE_RW; return pte; }
-static inline pte_t pte_mkread(pte_t pte)	{ (pte).pte_low |= _PAGE_USER; return pte; }
-static inline pte_t pte_mkexec(pte_t pte)	{ (pte).pte_low |= _PAGE_USER; return pte; }
-static inline pte_t pte_mkdirty(pte_t pte)	{ (pte).pte_low |= _PAGE_DIRTY; return pte; }
-static inline pte_t pte_mkyoung(pte_t pte)	{ (pte).pte_low |= _PAGE_ACCESSED; return pte; }
-static inline pte_t pte_mkwrite(pte_t pte)	{ (pte).pte_low |= _PAGE_RW; return pte; }
-static inline pte_t pte_mkhuge(pte_t pte)	{ (pte).pte_low |= _PAGE_PRESENT | _PAGE_PSE; return pte; }
+static inline pte_t pte_rdprotect(pte_t pte)
+	{ (pte).pte_low &= ~_PAGE_USER; return pte; }
+static inline pte_t pte_exprotect(pte_t pte)
+	{ (pte).pte_low &= ~_PAGE_USER; return pte; }
+static inline pte_t pte_mkclean(pte_t pte)
+	{ (pte).pte_low &= ~_PAGE_DIRTY; return pte; }
+static inline pte_t pte_mkold(pte_t pte)
+	{ (pte).pte_low &= ~_PAGE_ACCESSED; return pte; }
+static inline pte_t pte_wrprotect(pte_t pte)
+	{ (pte).pte_low &= ~_PAGE_RW; return pte; }
+static inline pte_t pte_mkread(pte_t pte)
+	{ (pte).pte_low |= _PAGE_USER; return pte; }
+static inline pte_t pte_mkexec(pte_t pte)
+	{ (pte).pte_low |= _PAGE_USER; return pte; }
+static inline pte_t pte_mkdirty(pte_t pte)
+	{ (pte).pte_low |= _PAGE_DIRTY; return pte; }
+static inline pte_t pte_mkyoung(pte_t pte)
+	{ (pte).pte_low |= _PAGE_ACCESSED; return pte; }
+static inline pte_t pte_mkwrite(pte_t pte)
+	{ (pte).pte_low |= _PAGE_RW; return pte; }
+static inline pte_t pte_mkhuge(pte_t pte)
+	{ (pte).pte_low |= _PAGE_PRESENT | _PAGE_PSE; return pte; }
 
 #ifdef CONFIG_X86_PAE
 # include <asm/pgtable-3level.h>
Signature · 1 line
if you have sharp zaurus hardware you don't need... you know my address