Skip to contentSkip to conversation

mm: fix up sparse warning in gfpflags_allow_blocking

PATCH In review Jeff Layton 2 participants 3 messages Nov 23, 2015

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 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 comparison to zero to have it return bool.

Cc Michal Hocko <[email protected]>
Cc Mel Gorman <[email protected]>
---
 include/linux/gfp.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

[v2: use a compare instead of forced cast, as suggested by Michal]

include/linux/gfp.h +1 -1
index 6523109e136d..b76c92073b1b 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 (gfp_flags & __GFP_DIRECT_RECLAIM) != 0;
 }
 
 #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>
Acked-by on v2 1/1
#1 lore raw
Quoted 11 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 comparison to zero to have it return bool.

Cc Michal Hocko <[email protected]>
Cc Mel Gorman <[email protected]>

Thanks!

Quoted 21 lines
---
 include/linux/gfp.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

[v2: use a compare instead of forced cast, as suggested by Michal]

include/linux/gfp.h +1 -1
index 6523109e136d..b76c92073b1b 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 (gfp_flags & __GFP_DIRECT_RECLAIM) != 0;
 }
 
 #ifdef CONFIG_HIGHMEM
Signature · 1 line
2.4.3
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 9 lines · On Mon, 23 Nov 2015 13:45:04 +0100 Michal Hocko <[email protected]> wrote:
Quoted 8 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 comparison to zero to have it return bool.

Quoted 8 lines
Quoted 3 lines
Cc Michal Hocko <[email protected]>
Cc Mel Gorman <[email protected]>

Thanks!

Doh! The original version has already been merged. I'll spin up a new patch that will apply to mainline when I get a bit of time.

Thanks,
Jeff

Quoted 22 lines
Quoted 21 lines
---
 include/linux/gfp.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

[v2: use a compare instead of forced cast, as suggested by Michal]

include/linux/gfp.h +1 -1
index 6523109e136d..b76c92073b1b 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 (gfp_flags & __GFP_DIRECT_RECLAIM) != 0;
 }
 
 #ifdef CONFIG_HIGHMEM
Signature · 1 line
2.4.3
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>