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]>
Signed-off-by: Jeff Layton <[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]
diff --git a/include/linux/gfp.h b/include/linux/gfp.h
index 6523109e136d..b76c92073b1b 100644
--- a/include/linux/gfp.h
+++ b/include/linux/gfp.h
@@ -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
--
2.4.3
On Mon 23-11-15 07:23:29, Jeff Layton wrote:
> 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]>
> Signed-off-by: Jeff Layton <[email protected]>
Acked-by: Michal Hocko <[email protected]>
Thanks!
> ---
> include/linux/gfp.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> [v2: use a compare instead of forced cast, as suggested by Michal]
>
> diff --git a/include/linux/gfp.h b/include/linux/gfp.h
> index 6523109e136d..b76c92073b1b 100644
> --- a/include/linux/gfp.h
> +++ b/include/linux/gfp.h
> @@ -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
> --
> 2.4.3
--
Michal Hocko
SUSE Labs
On Mon, 23 Nov 2015 13:45:04 +0100
Michal Hocko <[email protected]> wrote:
> On Mon 23-11-15 07:23:29, Jeff Layton wrote:
> > 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]>
> > Signed-off-by: Jeff Layton <[email protected]>
>
> Acked-by: Michal Hocko <[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
> > ---
> > include/linux/gfp.h | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > [v2: use a compare instead of forced cast, as suggested by Michal]
> >
> > diff --git a/include/linux/gfp.h b/include/linux/gfp.h
> > index 6523109e136d..b76c92073b1b 100644
> > --- a/include/linux/gfp.h
> > +++ b/include/linux/gfp.h
> > @@ -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
> > --
> > 2.4.3
>
--
Jeff Layton <[email protected]>