* Fixing fmode_t warnings
@ 2008-11-18 16:41 Steve French
2008-11-18 16:49 ` Steve French
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Steve French @ 2008-11-18 16:41 UTC (permalink / raw)
To: Dave Kleikamp, Jeff Layton, Shirish Pargaonkar, linux-fsdevel
Do you think it is worthwhile fixing this "sparse" warning ? oflags
is an int since the lookup intent open.flags is an int ...
CHECK fs/cifs/dir.c
fs/cifs/dir.c:169:16: warning: restricted fmode_t degrades to integer
fs/cifs/dir.c:171:16: warning: restricted fmode_t degrades to integer
int oflags = nd->intent.open.flags;
desiredAccess = 0;
(line 169) if (oflags & FMODE_READ)
desiredAccess |= GENERIC_READ;
(line 171) if (oflags & FMODE_WRITE) {
--
Thanks,
Steve
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Fixing fmode_t warnings
2008-11-18 16:41 Fixing fmode_t warnings Steve French
@ 2008-11-18 16:49 ` Steve French
2008-11-18 17:00 ` Al Viro
2008-11-18 17:03 ` Jeff Layton
2 siblings, 0 replies; 5+ messages in thread
From: Steve French @ 2008-11-18 16:49 UTC (permalink / raw)
To: Dave Kleikamp, Jeff Layton, Shirish Pargaonkar, linux-fsdevel
The same kind of thing causes a sparse warning in fs/open.c (and
fs/namei.c and fs/locks.c too)
CHECK fs/open.c
fs/open.c:270:29: warning: incorrect type in argument 2 (different base types)
fs/open.c:270:29: expected unsigned int [unsigned] mode
fs/open.c:270:29: got restricted fmode_t [usertype] <noident>
fs/open.c: error = break_lease(inode, FMODE_WRITE);
On Tue, Nov 18, 2008 at 10:41 AM, Steve French <smfrench@gmail.com> wrote:
> Do you think it is worthwhile fixing this "sparse" warning ? oflags
> is an int since the lookup intent open.flags is an int ...
>
> CHECK fs/cifs/dir.c
> fs/cifs/dir.c:169:16: warning: restricted fmode_t degrades to integer
> fs/cifs/dir.c:171:16: warning: restricted fmode_t degrades to integer
>
> int oflags = nd->intent.open.flags;
> desiredAccess = 0;
> (line 169) if (oflags & FMODE_READ)
> desiredAccess |= GENERIC_READ;
> (line 171) if (oflags & FMODE_WRITE) {
>
>
> --
> Thanks,
>
> Steve
>
--
Thanks,
Steve
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Fixing fmode_t warnings
2008-11-18 16:41 Fixing fmode_t warnings Steve French
2008-11-18 16:49 ` Steve French
@ 2008-11-18 17:00 ` Al Viro
2008-11-18 17:03 ` Jeff Layton
2 siblings, 0 replies; 5+ messages in thread
From: Al Viro @ 2008-11-18 17:00 UTC (permalink / raw)
To: Steve French
Cc: Dave Kleikamp, Jeff Layton, Shirish Pargaonkar, linux-fsdevel
On Tue, Nov 18, 2008 at 10:41:17AM -0600, Steve French wrote:
> Do you think it is worthwhile fixing this "sparse" warning ? oflags
> is an int since the lookup intent open.flags is an int ...
>
> CHECK fs/cifs/dir.c
> fs/cifs/dir.c:169:16: warning: restricted fmode_t degrades to integer
> fs/cifs/dir.c:171:16: warning: restricted fmode_t degrades to integer
>
> int oflags = nd->intent.open.flags;
> desiredAccess = 0;
> (line 169) if (oflags & FMODE_READ)
> desiredAccess |= GENERIC_READ;
> (line 171) if (oflags & FMODE_WRITE) {
It's worse than that; open.flags *mixes* FMODE_... with O_...
The right solution is to get rid of the damn thing and pass struct file
with pre-fill ->f_mode to (split-off) variant of create.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Fixing fmode_t warnings
2008-11-18 16:41 Fixing fmode_t warnings Steve French
2008-11-18 16:49 ` Steve French
2008-11-18 17:00 ` Al Viro
@ 2008-11-18 17:03 ` Jeff Layton
2008-11-18 17:12 ` Dave Kleikamp
2 siblings, 1 reply; 5+ messages in thread
From: Jeff Layton @ 2008-11-18 17:03 UTC (permalink / raw)
To: Steve French; +Cc: Dave Kleikamp, Shirish Pargaonkar, linux-fsdevel
On Tue, 18 Nov 2008 10:41:17 -0600
"Steve French" <smfrench@gmail.com> wrote:
> Do you think it is worthwhile fixing this "sparse" warning ? oflags
> is an int since the lookup intent open.flags is an int ...
>
> CHECK fs/cifs/dir.c
> fs/cifs/dir.c:169:16: warning: restricted fmode_t degrades to integer
> fs/cifs/dir.c:171:16: warning: restricted fmode_t degrades to integer
>
> int oflags = nd->intent.open.flags;
> desiredAccess = 0;
> (line 169) if (oflags & FMODE_READ)
> desiredAccess |= GENERIC_READ;
> (line 171) if (oflags & FMODE_WRITE) {
>
>
In general, I'm for fixing most warnings unless there is a good reason
not to. When things compile and checkers run cleanly it can really help
you to detect bugs...
My suggestion would be to go ahead and make oflags a fmode_t and just
cast the intent.open.flags to fmode_t.
--
Jeff Layton <jlayton@redhat.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Fixing fmode_t warnings
2008-11-18 17:03 ` Jeff Layton
@ 2008-11-18 17:12 ` Dave Kleikamp
0 siblings, 0 replies; 5+ messages in thread
From: Dave Kleikamp @ 2008-11-18 17:12 UTC (permalink / raw)
To: Jeff Layton; +Cc: Steve French, Shirish Pargaonkar, linux-fsdevel
On Tue, 2008-11-18 at 12:03 -0500, Jeff Layton wrote:
> On Tue, 18 Nov 2008 10:41:17 -0600
> "Steve French" <smfrench@gmail.com> wrote:
>
> > Do you think it is worthwhile fixing this "sparse" warning ? oflags
> > is an int since the lookup intent open.flags is an int ...
> >
> > CHECK fs/cifs/dir.c
> > fs/cifs/dir.c:169:16: warning: restricted fmode_t degrades to integer
> > fs/cifs/dir.c:171:16: warning: restricted fmode_t degrades to integer
> >
> > int oflags = nd->intent.open.flags;
> > desiredAccess = 0;
> > (line 169) if (oflags & FMODE_READ)
> > desiredAccess |= GENERIC_READ;
> > (line 171) if (oflags & FMODE_WRITE) {
> >
> >
>
> In general, I'm for fixing most warnings unless there is a good reason
> not to. When things compile and checkers run cleanly it can really help
> you to detect bugs...
>
> My suggestion would be to go ahead and make oflags a fmode_t and just
> cast the intent.open.flags to fmode_t.
I agree with Al that mixing O_* flags and FMODE_* flags in the same
field is broken. I'd just as well leave the warning until a real
cleanup can separate the two. There are other places that simply
changing the type isn't going to work.
--
David Kleikamp
IBM Linux Technology Center
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2008-11-18 17:12 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-18 16:41 Fixing fmode_t warnings Steve French
2008-11-18 16:49 ` Steve French
2008-11-18 17:00 ` Al Viro
2008-11-18 17:03 ` Jeff Layton
2008-11-18 17:12 ` Dave Kleikamp
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox