Skip to contentSkip to conversation

mm: fix up sparse warning in gfpflags_allow_blocking

PATCH Superseded Jeff Layton 2 participants 3 messages Nov 20, 2015 – Nov 23, 2015

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm: fix up sparse warning in gfpflags_allow_blocking

sparse says:

include/linux/gfp.h:274:26: warning: incorrect type in return expression (different base types)
include/linux/gfp.h:274:26: expected bool
include/linux/gfp.h:274:26: got restricted gfp_t

...add a forced cast to silence the warning.

---
 include/linux/gfp.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/gfp.h +1 -1
index 6523109e136d..8942af0813e3 100644
@@ -271,7 +271,7 @@ static inline int gfpflags_to_migratetype(const gfp_t gfp_flags)
 
 static inline bool gfpflags_allow_blocking(const gfp_t gfp_flags)
 {
-	return gfp_flags & __GFP_DIRECT_RECLAIM;
+	return (bool __force)(gfp_flags & __GFP_DIRECT_RECLAIM);
 }
 
 #ifdef CONFIG_HIGHMEM
Signature · 7 lines
2.4.3

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#1 lore raw
Quoted 19 lines · Jeff Layton

sparse says:

include/linux/gfp.h:274:26: warning: incorrect type in return expression (different base types)
include/linux/gfp.h:274:26: expected bool
include/linux/gfp.h:274:26: got restricted gfp_t

...add a forced cast to silence the warning.

---
 include/linux/gfp.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/gfp.h +0 -0
index 6523109e136d..8942af0813e3 100644

include/linux/gfp.h static inline int gfpflags_to_migratetype(const gfp_t gfp_flags) · line 274

Quoted 5 lines
include/linux/gfp.h +1 -1
@@ -271,7 +271,7 @@ static inline int gfpflags_to_migratetype(const gfp_t gfp_flags)
 
 static inline bool gfpflags_allow_blocking(const gfp_t gfp_flags)
 {
-	return gfp_flags & __GFP_DIRECT_RECLAIM;
+	return (bool __force)(gfp_flags & __GFP_DIRECT_RECLAIM);

Wouldn't (gfp_flags & __GFP_DIRECT_RECLAIM) != 0 be easier/better to read?

Signature · 8 lines
Michal Hocko
SUSE Labs

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#2 lore raw
Quoted 21 lines · On Mon, 23 Nov 2015 10:50:49 +0100 Michal Hocko <[email protected]> wrote:
Quoted 20 lines · Jeff Layton

sparse says:

include/linux/gfp.h:274:26: warning: incorrect type in return expression (different base types)
include/linux/gfp.h:274:26: expected bool
include/linux/gfp.h:274:26: got restricted gfp_t

...add a forced cast to silence the warning.

---
 include/linux/gfp.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/gfp.h +0 -0
index 6523109e136d..8942af0813e3 100644
@@ -271,7 +271,7 @@ static inline int gfpflags_to_migratetype(const gfp_t gfp_flags)
 
Quoted 7 lines

include/linux/gfp.h static inline int gfpflags_to_migratetype(const gfp_t gfp_flags) · line 274

Quoted 4 lines
include/linux/gfp.h +1 -1
 static inline bool gfpflags_allow_blocking(const gfp_t gfp_flags)
 {
-	return gfp_flags & __GFP_DIRECT_RECLAIM;
+	return (bool __force)(gfp_flags & __GFP_DIRECT_RECLAIM);

Wouldn't (gfp_flags & __GFP_DIRECT_RECLAIM) != 0 be easier/better to read?

Yeah, good point. Andrew, do you want me to respin that?

Signature · 7 lines
Jeff Layton <[email protected]>

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>