Skip to contentSkip to conversation

alpha: Define pgprot_modify to silence tautological comparison warnings

PATCH In review Matt Turner 2 participants 2 messages Apr 3 – Apr 12 Alpha port

lore
Share & tools
lore

Matt Turner

author maintainer
#0 lore raw

PATCH 1/1 alpha: Define pgprot_modify to silence tautological comparison warnings

Alpha's pgprot_noncached, pgprot_writecombine, and pgprot_device are all identity macros, so the generic pgprot_modify() produces tautological self-comparisons that GCC warns about:

include/linux/pgtable.h:1701:25: warning: self-comparison always evaluates to true [-Wtautological-compare]

Since all caching attributes are no-ops on Alpha, define pgprot_modify() to simply return newprot.

Assisted-by Claude:claude-opus-4-6
---
 arch/alpha/include/asm/pgtable.h | 11 +++++++++++
 1 file changed, 11 insertions(+)
arch/alpha/include/asm/pgtable.h +11 -0
index e786f630de5c..849abe2a1f98 100644
@@ -126,6 +126,17 @@ struct vm_area_struct;
  */
 #define pgprot_noncached(prot)	(prot)
 
+/*
+ * All caching attribute macros are identity on Alpha, so the generic
+ * pgprot_modify() degenerates to tautological self-comparisons.
+ * Override it to just return newprot directly.
+ */
+#define pgprot_modify pgprot_modify
+static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot)
+{
+	return newprot;
+}
+
 /*
  * ZERO_PAGE is a global shared page that is always zero:  used
  * for zero-mapped memory areas etc..
Signature · 1 line
2.52.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 30 lines · Matt Turner

Alpha's pgprot_noncached, pgprot_writecombine, and pgprot_device are all identity macros, so the generic pgprot_modify() produces tautological self-comparisons that GCC warns about:

include/linux/pgtable.h:1701:25: warning: self-comparison always evaluates to true [-Wtautological-compare]

Since all caching attributes are no-ops on Alpha, define pgprot_modify() to simply return newprot.

Assisted-by Claude:claude-opus-4-6
---
 arch/alpha/include/asm/pgtable.h | 11 +++++++++++
 1 file changed, 11 insertions(+)
arch/alpha/include/asm/pgtable.h +5 -0
index e786f630de5c..849abe2a1f98 100644
@@ -126,6 +126,17 @@ struct vm_area_struct;
  */
 #define pgprot_noncached(prot) (prot)
 
+/*
+ * All caching attribute macros are identity on Alpha, so the generic
+ * pgprot_modify() degenerates to tautological self-comparisons.
+ * Override it to just return newprot directly.
+ */

arch/alpha/include/asm/pgtable.h struct vm_area_struct;

Quoted 10 lines
arch/alpha/include/asm/pgtable.h +6 -1
+#define pgprot_modify pgprot_modify
+static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot)
+{
+       return newprot;
+}
+
 /*
  * ZERO_PAGE is a global shared page that is always zero:  used
  * for zero-mapped memory areas etc..
--

Looks good to me.