All of lore.kernel.org
 help / color / mirror / Atom feed
From: Roger Pau Monne <roger.pau@citrix.com>
To: xen-devel@lists.xenproject.org
Cc: Roger Pau Monne <roger.pau@citrix.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	George Dunlap <george.dunlap@citrix.com>,
	Jan Beulich <jbeulich@suse.com>, Julien Grall <julien@xen.org>,
	Stefano Stabellini <sstabellini@kernel.org>, Wei Liu <wl@xen.org>
Subject: [PATCH 5/5] mm: add the __must_check attribute to {gfn,mfn}_add()
Date: Wed, 14 Feb 2024 11:37:41 +0100	[thread overview]
Message-ID: <20240214103741.16189-6-roger.pau@citrix.com> (raw)
In-Reply-To: <20240214103741.16189-1-roger.pau@citrix.com>

It's not obvious from the function itself 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 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>
---
 xen/include/xen/mm-frame.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/xen/include/xen/mm-frame.h b/xen/include/xen/mm-frame.h
index 922ae418807a..c25e836f255a 100644
--- a/xen/include/xen/mm-frame.h
+++ b/xen/include/xen/mm-frame.h
@@ -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);
 }
-- 
2.43.0



  parent reply	other threads:[~2024-02-14 11:42 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-14 10:37 [PATCH 0/5] Fix fallout from IVMD/RMRR unification checks Roger Pau Monne
2024-02-14 10:37 ` [PATCH 1/5] iommu/x86: fix IVMD/RMRR range checker loop increment Roger Pau Monne
2024-02-14 11:51   ` Jan Beulich
2024-02-14 12:04     ` Roger Pau Monné
2024-02-14 10:37 ` [PATCH 2/5] iommu/x86: print RMRR/IVMD ranges using full addresses Roger Pau Monne
2024-02-14 13:22   ` Jan Beulich
2024-02-14 14:03     ` Roger Pau Monné
2024-02-14 10:37 ` [PATCH 3/5] iommu/x86: use full addresses internally for the IVMD/RMRR range checks Roger Pau Monne
2024-02-14 13:29   ` Jan Beulich
2024-02-14 14:05     ` Roger Pau Monné
2024-02-14 14:31       ` Jan Beulich
2024-02-14 10:37 ` [PATCH 4/5] iommu/x86: print page type in IVMD/RMRR check in case of error Roger Pau Monne
2024-02-14 13:30   ` Jan Beulich
2024-02-14 10:37 ` Roger Pau Monne [this message]
2024-02-14 12:02   ` [PATCH 5/5] mm: add the __must_check attribute to {gfn,mfn}_add() Julien Grall
2024-02-14 13:42   ` Jan Beulich
2024-02-14 14:00     ` Roger Pau Monné
2024-02-14 14:11   ` [PATCH v2 5/5] mm: add the __must_check attribute to {gfn,mfn,dfn}_add() Roger Pau Monne
2024-02-14 14:32     ` Jan Beulich
2024-02-19  5:07   ` [PATCH 5/5] mm: add the __must_check attribute to {gfn,mfn}_add() George Dunlap
2024-02-19  8:50     ` Jan Beulich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240214103741.16189-6-roger.pau@citrix.com \
    --to=roger.pau@citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=george.dunlap@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=julien@xen.org \
    --cc=sstabellini@kernel.org \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.