From: Nicola Vetrini <nicola.vetrini@bugseng.com>
To: Xen Devel <xen-devel@lists.xenproject.org>
Cc: Consulting <consulting@bugseng.com>,
Stefano Stabellini <sstabellini@kernel.org>,
Julien Grall <julien@xen.org>,
Bertrand Marquis <bertrand.marquis@arm.com>,
Michal Orzel <michal.orzel@amd.com>, Jbeulich <jbeulich@suse.com>,
Andrew Cooper3 <andrew.cooper3@citrix.com>,
Roger Pau <roger.pau@citrix.com>,
George Dunlap <george.dunlap@citrix.com>, Wei Liu <wl@xen.org>
Subject: Return type of clean_and_invalidate_dcache_va_range
Date: Fri, 09 Feb 2024 16:52:04 +0100 [thread overview]
Message-ID: <e050b096ff39aa857f9c267a8dbb4ef6@bugseng.com> (raw)
Hi all,
In the context of violations of MISRA C:2012 Rule 17.7: "The value
returned by a function having non-void return type shall be used", I was
looking at the function "clean_and_invalidate_dcache_va_range". It has
the following signature on both arm and x86:
static inline int clean_and_invalidate_dcache_va_range
(const void *p, unsigned long size)
The commit that introduced it for Arm ~9 years ago (71d64afe3e12: "arm:
return int from *_dcache_va_range") [1] mentions that on Arm it can't
fail, but supposedly it can on x86.
However, as far as I can tell, for both arch-es the implementation now
always returns 0 [2][3], so perhaps the mention of -EOPNOTSUPP for x86
is no longer true (I wasn't able to reconstruct if there was a time at
which this was true, even in the same commit that changed the return
type to int).
The question is: should the return type be void, since it appears that
every user is ignoring the returned value (violating the rule), except
the one in common/grant_table.c [4]?
The other two resolution paths are either allowing this function's
result to be ignored or cast all ignored invocations to void, with the
first being cleaner from a code readability perspective.
[1] These functions cannot really fail on ARM, but their x86 equivalents
can (-EOPNOTSUPP). Change the prototype to return int.
[2]
https://gitlab.com/xen-project/xen/-/blob/staging/xen/arch/arm/include/asm/page.h#L218
[3]
https://gitlab.com/xen-project/xen/-/blob/staging/xen/arch/x86/include/asm/flushtlb.h#L188
[4]
https://gitlab.com/xen-project/xen/-/blob/staging/xen/common/grant_table.c#L3576
--
Nicola Vetrini, BSc
Software Engineer, BUGSENG srl (https://bugseng.com)
next reply other threads:[~2024-02-09 15:52 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-09 15:52 Nicola Vetrini [this message]
2024-02-09 22:02 ` Return type of clean_and_invalidate_dcache_va_range Stefano Stabellini
2024-02-10 10:17 ` Julien Grall
2024-02-12 8:26 ` Jan Beulich
2024-02-12 14:56 ` Nicola Vetrini
2024-02-12 18:38 ` Julien Grall
2024-02-13 7:13 ` Jan Beulich
2024-02-13 17:14 ` Julien Grall
2024-02-15 14:31 ` Nicola Vetrini
2024-02-15 15:23 ` Nicola Vetrini
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=e050b096ff39aa857f9c267a8dbb4ef6@bugseng.com \
--to=nicola.vetrini@bugseng.com \
--cc=andrew.cooper3@citrix.com \
--cc=bertrand.marquis@arm.com \
--cc=consulting@bugseng.com \
--cc=george.dunlap@citrix.com \
--cc=jbeulich@suse.com \
--cc=julien@xen.org \
--cc=michal.orzel@amd.com \
--cc=roger.pau@citrix.com \
--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.