]> xenbits.xensource.com Git - xen.git/commitdiff
mm: add the __must_check attribute to {gfn,mfn,dfn}_add()
authorRoger Pau Monné <roger.pau@citrix.com>
Mon, 19 Feb 2024 11:44:50 +0000 (12:44 +0100)
committerJan Beulich <jbeulich@suse.com>
Mon, 19 Feb 2024 11:44:50 +0000 (12:44 +0100)
It's not obvious from just the function name whether the incremented value will
be stored in the parameter, or returned to the caller.  That has leads to bugs
in the past as callers may assume the incremented value is stored in the
parameter.

Add the __must_check attribute to the function to easily spot callers that
don't consume the returned value, which signals an error in the caller logic.

No functional change intended.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Julien Grall <jgrall@amazon.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/include/xen/iommu.h
xen/include/xen/mm-frame.h

index 7aa6a77209774be97570f955f1fb25efb215d553..9621459c63ee6d18ce87f7af7e91a174489705c0 100644 (file)
@@ -42,7 +42,7 @@ TYPE_SAFE(uint64_t, dfn);
 #undef dfn_x
 #endif
 
-static inline dfn_t dfn_add(dfn_t dfn, unsigned long i)
+static inline dfn_t __must_check dfn_add(dfn_t dfn, unsigned long i)
 {
     return _dfn(dfn_x(dfn) + i);
 }
index 922ae418807ace374296d68da8a1b6ba05023924..c25e836f255a3b32dd4b9a287ea3a997f09af5ef 100644 (file)
@@ -23,7 +23,7 @@ TYPE_SAFE(unsigned long, mfn);
 #undef mfn_x
 #endif
 
-static inline mfn_t mfn_add(mfn_t mfn, unsigned long i)
+static inline mfn_t __must_check mfn_add(mfn_t mfn, unsigned long i)
 {
     return _mfn(mfn_x(mfn) + i);
 }
@@ -62,7 +62,7 @@ TYPE_SAFE(unsigned long, gfn);
 #undef gfn_x
 #endif
 
-static inline gfn_t gfn_add(gfn_t gfn, unsigned long i)
+static inline gfn_t __must_check gfn_add(gfn_t gfn, unsigned long i)
 {
     return _gfn(gfn_x(gfn) + i);
 }