Re: [PATCH v1 3/3] lib/vsprintf: Force type of flags for gfp_t

Andy Shevchenko
2020-07-31T15:50:05Z

On Fri, Jul 31, 2020 at 6:38 PM Steven Rostedt <rostedt@goodmis.org> wrote:
>
> On Fri, 31 Jul 2020 15:31:45 +0300
> Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:
>
> > Sparse is not happy about restricted type being assigned:
> > lib/vsprintf.c:1940:23: warning: incorrect type in assignment (different base types)
> > lib/vsprintf.c:1940:23: expected unsigned long [assigned] flags
> > lib/vsprintf.c:1940:23: got restricted gfp_t [usertype]
> >
> > Force type of flags to make sparse happy.
> >
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > ---
> > lib/vsprintf.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/lib/vsprintf.c b/lib/vsprintf.c
> > index 90d818ef03c5..118e2727d058 100644
> > --- a/lib/vsprintf.c
> > +++ b/lib/vsprintf.c
> > @@ -1937,7 +1937,7 @@ char *flags_string(char *buf, char *end, void *flags_ptr,
> > names = vmaflag_names;
> > break;
> > case 'g':
> > - flags = *(gfp_t *)flags_ptr;
> > + flags = (__force typeof(flags))(*(gfp_t *)flags_ptr);
>
> Do we really need to say "typeof(flags)" ? What about simply using
> flags' type?

Whatever you prefer. I actually came with the latter and switched to the former.
So, I'll switch back for v2.

>
> flags = (__force unsigned long)(*(gfp_t *)flags_ptr);
>
> ?
>
> I mean, it's not like flags is a global. It's defined a few lines above.
>
> -- Steve
>
>
> > names = gfpflag_names;
> > break;
> > default:
>

--
With Best Regards,
Andy Shevchenko