From: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Ingo Molnar <mingo@redhat.com>,
linux-kernel@vger.kernel.org,
Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Subject: [PATCH] fix cast of gfp_t to ulong in __def_gfpflag_names
Date: Wed, 4 Dec 2019 18:54:25 +0100 [thread overview]
Message-ID: <20191204175425.71855-1-luc.vanoostenryck@gmail.com> (raw)
The macro '__def_gfpflag_names' is used to define arrays of
struct trace_print_flags. This structure is defined as being
a pair of 'unsigned long' - 'const char *'.
However, the macro __def_gfpflag_names is used to for GFP flags
and thus take entries of type gfp_t (plus their name) which
is a bitwise type, non-convertible to usual integers.
These entries are casted to 'unsigned long' but this doesn't
prevent Sparse to rughtfully complain:
warning: cast from restricted gfp_t
The correct way to cast a bitwise type to a normal integer
(which is OK here) is to use '__force'.
So, fix the cast by adding the '__force' required for such casts.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
include/trace/events/mmflags.h | 70 +++++++++++++++++-----------------
1 file changed, 35 insertions(+), 35 deletions(-)
diff --git a/include/trace/events/mmflags.h b/include/trace/events/mmflags.h
index a1675d43777e..3b85bbf79115 100644
--- a/include/trace/events/mmflags.h
+++ b/include/trace/events/mmflags.h
@@ -14,41 +14,41 @@
*/
#define __def_gfpflag_names \
- {(unsigned long)GFP_TRANSHUGE, "GFP_TRANSHUGE"}, \
- {(unsigned long)GFP_TRANSHUGE_LIGHT, "GFP_TRANSHUGE_LIGHT"}, \
- {(unsigned long)GFP_HIGHUSER_MOVABLE, "GFP_HIGHUSER_MOVABLE"},\
- {(unsigned long)GFP_HIGHUSER, "GFP_HIGHUSER"}, \
- {(unsigned long)GFP_USER, "GFP_USER"}, \
- {(unsigned long)GFP_KERNEL_ACCOUNT, "GFP_KERNEL_ACCOUNT"}, \
- {(unsigned long)GFP_KERNEL, "GFP_KERNEL"}, \
- {(unsigned long)GFP_NOFS, "GFP_NOFS"}, \
- {(unsigned long)GFP_ATOMIC, "GFP_ATOMIC"}, \
- {(unsigned long)GFP_NOIO, "GFP_NOIO"}, \
- {(unsigned long)GFP_NOWAIT, "GFP_NOWAIT"}, \
- {(unsigned long)GFP_DMA, "GFP_DMA"}, \
- {(unsigned long)__GFP_HIGHMEM, "__GFP_HIGHMEM"}, \
- {(unsigned long)GFP_DMA32, "GFP_DMA32"}, \
- {(unsigned long)__GFP_HIGH, "__GFP_HIGH"}, \
- {(unsigned long)__GFP_ATOMIC, "__GFP_ATOMIC"}, \
- {(unsigned long)__GFP_IO, "__GFP_IO"}, \
- {(unsigned long)__GFP_FS, "__GFP_FS"}, \
- {(unsigned long)__GFP_NOWARN, "__GFP_NOWARN"}, \
- {(unsigned long)__GFP_RETRY_MAYFAIL, "__GFP_RETRY_MAYFAIL"}, \
- {(unsigned long)__GFP_NOFAIL, "__GFP_NOFAIL"}, \
- {(unsigned long)__GFP_NORETRY, "__GFP_NORETRY"}, \
- {(unsigned long)__GFP_COMP, "__GFP_COMP"}, \
- {(unsigned long)__GFP_ZERO, "__GFP_ZERO"}, \
- {(unsigned long)__GFP_NOMEMALLOC, "__GFP_NOMEMALLOC"}, \
- {(unsigned long)__GFP_MEMALLOC, "__GFP_MEMALLOC"}, \
- {(unsigned long)__GFP_HARDWALL, "__GFP_HARDWALL"}, \
- {(unsigned long)__GFP_THISNODE, "__GFP_THISNODE"}, \
- {(unsigned long)__GFP_RECLAIMABLE, "__GFP_RECLAIMABLE"}, \
- {(unsigned long)__GFP_MOVABLE, "__GFP_MOVABLE"}, \
- {(unsigned long)__GFP_ACCOUNT, "__GFP_ACCOUNT"}, \
- {(unsigned long)__GFP_WRITE, "__GFP_WRITE"}, \
- {(unsigned long)__GFP_RECLAIM, "__GFP_RECLAIM"}, \
- {(unsigned long)__GFP_DIRECT_RECLAIM, "__GFP_DIRECT_RECLAIM"},\
- {(unsigned long)__GFP_KSWAPD_RECLAIM, "__GFP_KSWAPD_RECLAIM"}\
+ {(__force ulong)GFP_TRANSHUGE, "GFP_TRANSHUGE"}, \
+ {(__force ulong)GFP_TRANSHUGE_LIGHT, "GFP_TRANSHUGE_LIGHT"}, \
+ {(__force ulong)GFP_HIGHUSER_MOVABLE, "GFP_HIGHUSER_MOVABLE"},\
+ {(__force ulong)GFP_HIGHUSER, "GFP_HIGHUSER"}, \
+ {(__force ulong)GFP_USER, "GFP_USER"}, \
+ {(__force ulong)GFP_KERNEL_ACCOUNT, "GFP_KERNEL_ACCOUNT"}, \
+ {(__force ulong)GFP_KERNEL, "GFP_KERNEL"}, \
+ {(__force ulong)GFP_NOFS, "GFP_NOFS"}, \
+ {(__force ulong)GFP_ATOMIC, "GFP_ATOMIC"}, \
+ {(__force ulong)GFP_NOIO, "GFP_NOIO"}, \
+ {(__force ulong)GFP_NOWAIT, "GFP_NOWAIT"}, \
+ {(__force ulong)GFP_DMA, "GFP_DMA"}, \
+ {(__force ulong)__GFP_HIGHMEM, "__GFP_HIGHMEM"}, \
+ {(__force ulong)GFP_DMA32, "GFP_DMA32"}, \
+ {(__force ulong)__GFP_HIGH, "__GFP_HIGH"}, \
+ {(__force ulong)__GFP_ATOMIC, "__GFP_ATOMIC"}, \
+ {(__force ulong)__GFP_IO, "__GFP_IO"}, \
+ {(__force ulong)__GFP_FS, "__GFP_FS"}, \
+ {(__force ulong)__GFP_NOWARN, "__GFP_NOWARN"}, \
+ {(__force ulong)__GFP_RETRY_MAYFAIL, "__GFP_RETRY_MAYFAIL"}, \
+ {(__force ulong)__GFP_NOFAIL, "__GFP_NOFAIL"}, \
+ {(__force ulong)__GFP_NORETRY, "__GFP_NORETRY"}, \
+ {(__force ulong)__GFP_COMP, "__GFP_COMP"}, \
+ {(__force ulong)__GFP_ZERO, "__GFP_ZERO"}, \
+ {(__force ulong)__GFP_NOMEMALLOC, "__GFP_NOMEMALLOC"}, \
+ {(__force ulong)__GFP_MEMALLOC, "__GFP_MEMALLOC"}, \
+ {(__force ulong)__GFP_HARDWALL, "__GFP_HARDWALL"}, \
+ {(__force ulong)__GFP_THISNODE, "__GFP_THISNODE"}, \
+ {(__force ulong)__GFP_RECLAIMABLE, "__GFP_RECLAIMABLE"}, \
+ {(__force ulong)__GFP_MOVABLE, "__GFP_MOVABLE"}, \
+ {(__force ulong)__GFP_ACCOUNT, "__GFP_ACCOUNT"}, \
+ {(__force ulong)__GFP_WRITE, "__GFP_WRITE"}, \
+ {(__force ulong)__GFP_RECLAIM, "__GFP_RECLAIM"}, \
+ {(__force ulong)__GFP_DIRECT_RECLAIM, "__GFP_DIRECT_RECLAIM"},\
+ {(__force ulong)__GFP_KSWAPD_RECLAIM, "__GFP_KSWAPD_RECLAIM"}\
#define show_gfp_flags(flags) \
(flags) ? __print_flags(flags, "|", \
--
2.24.0
next reply other threads:[~2019-12-04 17:54 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-04 17:54 Luc Van Oostenryck [this message]
2019-12-05 2:08 ` [PATCH] fix cast of gfp_t to ulong in __def_gfpflag_names Al Viro
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=20191204175425.71855-1-luc.vanoostenryck@gmail.com \
--to=luc.vanoostenryck@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=rostedt@goodmis.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).